You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2006/10/05 22:19:56 UTC
svn commit: r453355 [2/3] - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/phase/
api/src/main/java/org/apache/cxf/service/
api/src/main/java/org/apache/cxf/service/model/
api/src/main/java/org/apache/cxf/transport/ rt/bindings/soap/src/main...
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java Thu Oct 5 13:19:52 2006
@@ -33,10 +33,13 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXParseException;
+
import junit.framework.TestCase;
import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.BusException;
+import org.apache.cxf.bus.cxf.CXFBusFactory;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageImpl;
@@ -45,7 +48,6 @@
import org.apache.cxf.transport.ConduitInitiator;
import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.MessageObserver;
-import org.xmlsoap.schemas.wsdl.http.AddressType;
/**
* A basic test case meant for helping users unit test their services.
@@ -71,17 +73,15 @@
return bus;
}
- protected Bus createBus() {
- return BusFactoryHelper.newInstance().createBus();
+ protected Bus createBus() throws BusException {
+ return new CXFBusFactory().createBus();
}
protected Node invoke(String address,
String transport,
String message) throws Exception {
EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
- AddressType a = new AddressType();
- a.setLocation(address);
- ei.addExtensor(a);
+ ei.setAddress(address);
ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport);
@@ -104,7 +104,12 @@
byte[] bs = obs.getResponseStream().toByteArray();
ByteArrayInputStream input = new ByteArrayInputStream(bs);
- return DOMUtils.readXml(input);
+ try {
+ return DOMUtils.readXml(input);
+ } catch (SAXParseException e) {
+ throw new IllegalStateException("Could not parse message:\n"
+ + obs.getResponseStream().toString());
+ }
}
private void copy(final InputStream input, final OutputStream output, final int bufferSize)
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java Thu Oct 5 13:19:52 2006
@@ -62,7 +62,7 @@
if (nodes.getLength() == 0) {
throw new AssertionFailedError("Failed to select any nodes for expression:\n" + xpath
- + "From document:\n" + writeNodeToString(node));
+ + " from document:\n" + writeNodeToString(node));
}
return nodes;
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ConduitInitiatorManagerImpl.java Thu Oct 5 13:19:52 2006
@@ -103,7 +103,7 @@
factory = conduitInitiators.get(namespace);
}
if (null == factory) {
- throw new BusException(new Message("NO_CONDUIT_INITIATOR_EXC", BUNDLE, namespace));
+ throw new BusException(new Message("NO_CONDUIT_INITIATOR", BUNDLE, namespace));
}
return factory;
}
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java Thu Oct 5 13:19:52 2006
@@ -103,7 +103,7 @@
factory = destinationFactories.get(namespace);
}
if (null == factory) {
- throw new BusException(new Message("NO_CONDUIT_INITIATOR_EXC", BUNDLE, namespace));
+ throw new BusException(new Message("NO_DEST_FACTORY", BUNDLE, namespace));
}
return factory;
}
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/Messages.properties?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/Messages.properties (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/Messages.properties Thu Oct 5 13:19:52 2006
@@ -1 +1,2 @@
-NO_CONDUIT_INIT=No conduit initiator was found.
\ No newline at end of file
+NO_CONDUIT_INITIATOR=No conduit initiator was found for the namepsace {0}.
+NO_DEST_FACTORY=No DestinationFactory was found for the namespace {0}.
\ No newline at end of file
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Thu Oct 5 13:19:52 2006
@@ -97,7 +97,9 @@
def.setQName(service.getName());
def.setTargetNamespace(service.getTargetNamespace());
addExtensibiltyElements(def, service.getWSDL11Extensors());
- buildTypes(def, service.getTypeInfo());
+ if (service.getTypeInfo() != null) {
+ buildTypes(def, service.getTypeInfo());
+ }
buildPortType(def, service.getInterface());
buildBinding(def, service.getBindings());
buildService(def, service);
@@ -210,10 +212,15 @@
try {
portType = intf.getProperty(WSDLServiceBuilder.WSDL_PORTTYPE, PortType.class);
} catch (ClassCastException e) {
+ // do nothing
+ }
+
+ if (portType == null) {
portType = def.createPortType();
portType.setQName(intf.getName());
buildPortTypeOperation(def, portType, intf.getOperations());
}
+
def.addPortType(portType);
}
@@ -226,6 +233,10 @@
operation = operationInfo.getProperty(
WSDLServiceBuilder.WSDL_OPERATION, Operation.class);
} catch (ClassCastException e) {
+ // do nothing
+ }
+
+ if (operation == null) {
operation = def.createOperation();
operation.setName(operationInfo.getName().getLocalPart());
if (operationInfo.isOneWay()) {
Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java?view=auto&rev=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java (added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java Thu Oct 5 13:19:52 2006
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.wsdl11;
+
+import javax.wsdl.Port;
+
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+/**
+ * A factory to create an internal {@link EndpointInfo} from a WSDL4J {@link Port}.
+ */
+public interface WSDLEndpointFactory {
+ EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b, Port port);
+
+ void createPortExtensors(EndpointInfo ei, Service service);
+}
Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLEndpointFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Thu Oct 5 13:19:52 2006
@@ -43,7 +43,6 @@
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.UnknownExtensibilityElement;
import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.extensions.soap.SOAPHeader;
import javax.xml.namespace.QName;
import org.apache.cxf.Bus;
@@ -65,6 +64,8 @@
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.service.model.TypeInfo;
import org.apache.cxf.service.model.UnwrappedOperationInfo;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
@@ -83,8 +84,7 @@
public static final String WSDL_PORTTYPE = WSDLServiceBuilder.class.getName() + ".WSDL_PORTTYPE";
public static final String WSDL_PORT = WSDLServiceBuilder.class.getName() + ".PORT";
public static final String WSDL_BINDING = WSDLServiceBuilder.class.getName() + ".BINDING";
-
-
+
public static final String WSDL_OPERATION = WSDLServiceBuilder.class.getName() + ".OPERATION";
public static final String WSDL_BINDING_OPERATION = WSDLServiceBuilder.class.getName()
+ ".BINDING_OPERATION";
@@ -106,10 +106,10 @@
public ServiceInfo buildService(Definition d, QName name) {
Service service = d.getService(name);
-
+
return buildService(d, service);
}
-
+
public ServiceInfo buildService(Definition def, Service serv) {
ServiceInfo service = new ServiceInfo();
service.setProperty(WSDL_DEFINITION, def);
@@ -169,8 +169,7 @@
defList.add(impt.getDefinition());
}
}
-
-
+
private void extractSchema(Definition def, XmlSchemaCollection schemaCol, TypeInfo typeInfo) {
Types typesElement = def.getTypes();
if (typesElement != null) {
@@ -191,20 +190,37 @@
SchemaInfo schemaInfo = new SchemaInfo(typeInfo, xmlSchema.getTargetNamespace());
schemaInfo.setElement(schemaElem);
typeInfo.addSchema(schemaInfo);
-
+
}
}
}
-
+
}
public EndpointInfo buildEndpoint(ServiceInfo service, BindingInfo bi, Port port) {
String ns = ((ExtensibilityElement)port.getExtensibilityElements().get(0)).getElementType()
.getNamespaceURI();
- EndpointInfo ei = new EndpointInfo(service, ns);
+ EndpointInfo ei = null;
+
+ try {
+ DestinationFactory factory = bus.getExtension(DestinationFactoryManager.class)
+ .getDestinationFactory(ns);
+ if (factory instanceof WSDLEndpointFactory) {
+ WSDLEndpointFactory wFactory = (WSDLEndpointFactory)factory;
+ ei = wFactory.createEndpointInfo(service, bi, port);
+ }
+ } catch (BusException e) {
+ // do nothing
+ }
+
+ if (ei == null) {
+ ei = new EndpointInfo(service, ns);
+ }
+
ei.setName(new QName(service.getName().getNamespaceURI(), port.getName()));
ei.setBinding(bi);
copyExtensors(ei, port.getExtensibilityElements());
+
service.addEndpoint(ei);
return ei;
}
@@ -264,20 +280,20 @@
service.addBinding(bi);
return bi;
}
-
+
private void handleHeader(BindingMessageInfo bindingMessageInfo) {
- //mark all message part which should be in header
+ // mark all message part which should be in header
List<ExtensibilityElement> extensiblilityElement = bindingMessageInfo.getWSDL11Extensors();
- //for non-soap binding, the extensiblilityElement could be null
+ // for non-soap binding, the extensiblilityElement could be null
if (extensiblilityElement == null) {
return;
}
- for (ExtensibilityElement element : extensiblilityElement) {
- LOG.info("the extensibility is " + element.getClass().getName());
- if (element instanceof SOAPHeader) {
- LOG.info("the header is " + ((SOAPHeader)element).getPart());
- }
- }
+// for (ExtensibilityElement element : extensiblilityElement) {
+// LOG.info("the extensibility is " + element.getClass().getName());
+// if (element instanceof SOAPHeader) {
+// LOG.info("the header is " + ((SOAPHeader)element).getPart());
+// }
+// }
}
public void buildInterface(ServiceInfo si, PortType p) {
@@ -400,7 +416,7 @@
if (outputMessage != null) {
unwrappedOutput = new MessageInfo(opInfo, outputMessage.getName());
-
+
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct, unwrappedOutput)) {
@@ -475,6 +491,5 @@
}
}
}
-
}
Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java Thu Oct 5 13:19:52 2006
@@ -46,6 +46,7 @@
import org.apache.cxf.binding.BindingFactoryManager;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
@@ -65,6 +66,7 @@
private IMocksControl control;
private Bus bus;
private BindingFactoryManager bindingFactoryManager;
+ private DestinationFactoryManager destinationFactoryManager;
public void setUp() throws Exception {
@@ -78,6 +80,7 @@
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
+ destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
@@ -88,6 +91,9 @@
}
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
+ EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
+ .andReturn(destinationFactoryManager);
+
control.replay();
serviceInfo = wsdlServiceBuilder.buildService(def, service);
Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java Thu Oct 5 13:19:52 2006
@@ -42,6 +42,7 @@
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.service.model.TypeInfo;
+import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
@@ -58,15 +59,12 @@
private IMocksControl control;
private Bus bus;
private BindingFactoryManager bindingFactoryManager;
+ private DestinationFactoryManager destinationFactoryManager;
public void setUp() throws Exception {
setUpWSDL(WSDL_PATH);
}
- public void tearDown() throws Exception {
-
- }
-
private void setUpWSDL(String wsdl) throws Exception {
String wsdlUrl = getClass().getResource(wsdl).toString();
LOG.info("the path of wsdl file is " + wsdlUrl);
@@ -86,12 +84,19 @@
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
+ destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
wsdlServiceBuilder = new WSDLServiceBuilder(bus);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
+ EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
+ .andReturn(destinationFactoryManager);
control.replay();
serviceInfo = wsdlServiceBuilder.buildService(def, service);
+
+ }
+
+ public void tearDown() throws Exception {
control.verify();
}
@@ -136,7 +141,7 @@
assertTrue("greatMe should be wrapped", greetMe.isUnwrappedCapable());
OperationInfo greetMeUnwrapped = greetMe.getUnwrappedOperation();
-
+
assertNotNull(greetMeUnwrapped.getInput());
assertNotNull(greetMeUnwrapped.getOutput());
assertEquals("wrapped part not set", 1, greetMeUnwrapped.getInput().size());
@@ -150,9 +155,6 @@
.getMessagePartByIndex(0).getName().getLocalPart());
assertEquals("wrapper part type name wrong", "string", greetMeUnwrapped.getOutput()
.getMessagePartByIndex(0).getTypeQName().getLocalPart());
-
-
-
name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
OperationInfo greetMeOneWay = serviceInfo.getInterface().getOperation(name);
@@ -167,7 +169,7 @@
assertNotNull(greetMeOneWayUnwrapped.getInput());
assertNull(greetMeOneWayUnwrapped.getOutput());
assertEquals("wrapped part not set", 1, greetMeOneWayUnwrapped.getInput().size());
-
+
name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
OperationInfo pingMe = serviceInfo.getInterface().getOperation(name);
assertNotNull(pingMe);
@@ -273,11 +275,10 @@
assertEquals(elementName.getLocalPart(), "faultDetail");
assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
}
-
-
+
public void testSchema() {
- XmlSchemaCollection schemas =
- serviceInfo.getProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST, XmlSchemaCollection.class);
+ XmlSchemaCollection schemas = serviceInfo.getProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST,
+ XmlSchemaCollection.class);
assertNotNull(schemas);
TypeInfo typeInfo = serviceInfo.getTypeInfo();
assertNotNull(typeInfo);
@@ -288,7 +289,6 @@
assertEquals(schemas.read(schemaInfo.getElement()).getTargetNamespace(),
"http://apache.org/hello_world_soap_http/types");
}
-
public void testBare() throws Exception {
setUpWSDL(BARE_WSDL_PATH);
BindingInfo bindingInfo = null;
@@ -305,5 +305,3 @@
}
}
-
-
Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBServiceModelInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBServiceModelInitializer.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBServiceModelInitializer.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBServiceModelInitializer.java Thu Oct 5 13:19:52 2006
@@ -19,18 +19,15 @@
package org.apache.cxf.jaxb;
-import java.lang.reflect.AnnotatedElement;
-import java.util.ResourceBundle;
+import java.lang.reflect.Type;
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.i18n.UncheckedException;
+import com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
+import com.sun.xml.bind.v2.model.core.ElementInfo;
+import com.sun.xml.bind.v2.model.core.NonElement;
+import com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder;
+
import org.apache.cxf.service.ServiceModelVisitor;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.ServiceInfo;
@@ -40,79 +37,38 @@
*/
class JAXBServiceModelInitializer extends ServiceModelVisitor {
- private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXBServiceModelInitializer.class);
-
public JAXBServiceModelInitializer(ServiceInfo serviceInfo) {
super(serviceInfo);
}
@Override
public void begin(MessagePartInfo part) {
+ // Check to see if the WSDL information has been filled in for us.
+ if (part.getConcreteName() != null) {
+ return;
+ }
+
Class<?> clazz = (Class<?>)part.getProperty(Class.class.getName());
-
- XmlRootElement root = (XmlRootElement)clazz.getAnnotation(XmlRootElement.class);
- XmlType type = (XmlType)clazz.getAnnotation(XmlType.class);
- String local = null;
- String nsUri = null;
- boolean isElement = false;
-
- if (root != null) {
- isElement = false;
- local = root.name();
- nsUri = root.namespace();
- } else if (type != null) {
- isElement = true;
- local = type.name();
- nsUri = type.namespace();
- } else if (clazz.isAnnotationPresent(XmlEnum.class)) {
- isElement = true;
- local = clazz.getSimpleName();
- nsUri = "##default";
- } else {
- // we've got a non JAXB bean - i.e. String, etc
+ if (clazz == null) {
return;
}
- if ("##default".equals(local)) {
- local = clazz.getSimpleName();
- }
+ RuntimeModelBuilder builder = new RuntimeModelBuilder(new RuntimeInlineAnnotationReader(), null);
+ NonElement<Type, Class> typeInfo = builder.getTypeInfo(clazz, null);
- if ("##default".equals(nsUri)) {
- nsUri = getPackageNs(clazz);
+ QName typeName = typeInfo.getTypeName();
+ // TODO: this doesn't seem to work with elements yet
+ if (typeName == null) {
+ return;
}
+ boolean isElement = typeInfo instanceof ElementInfo;
+
part.setIsElement(isElement);
if (isElement) {
- part.setElementQName(new QName(nsUri, local));
- } else {
- part.setTypeQName(new QName(nsUri, local));
- }
- }
-
- public static String getPackageNs(Class clazz) {
- AnnotatedElement pack = clazz.getPackage();
- // getPackage isn't guaranteed to return a package
- if (pack == null) {
- try {
- pack = ClassLoaderUtils.loadClass(
- clazz.getName().substring(0, clazz.getName().lastIndexOf('.')) + ".package-info", clazz);
- } catch (Exception ex) {
- // do nothing
- }
- }
-
- if (pack == null) {
- throw new UncheckedException(new Message("UNKNOWN_PACKAGE_NS", BUNDLE, clazz));
- }
-
- javax.xml.bind.annotation.XmlSchema schema = pack
- .getAnnotation(javax.xml.bind.annotation.XmlSchema.class);
- String namespace = null;
- if (schema != null) {
- namespace = schema.namespace();
+ part.setElementQName(typeName);
} else {
- namespace = "";
+ part.setTypeQName(typeName);
}
- return namespace;
}
}
Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataReader.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataReader.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataReader.java Thu Oct 5 13:19:52 2006
@@ -19,6 +19,7 @@
package org.apache.cxf.jaxb.io;
+import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamReader;
@@ -69,11 +70,21 @@
if (source == null) {
return null;
}
- return JAXBEncoderDecoder.unmarshall(factory.getJAXBContext(),
- factory.getSchema(), source,
- name,
- cls,
- au);
+ Object o = JAXBEncoderDecoder.unmarshall(factory.getJAXBContext(),
+ factory.getSchema(), source,
+ name,
+ cls,
+ au);
+ o = getValue(o);
+
+ return o;
+ }
+
+ private Object getValue(Object o) {
+ if (o instanceof JAXBElement) {
+ return ((JAXBElement)o).getValue();
+ }
+ return o;
}
}
Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java Thu Oct 5 13:19:52 2006
@@ -19,7 +19,6 @@
package org.apache.cxf.jaxb;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -37,8 +36,8 @@
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.wsdl11.WSDLServiceBuilder;
-
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
@@ -57,7 +56,8 @@
private BindingFactoryManager bindingFactoryManager;
private JAXBDataBinding jaxbDataBinding;
private Map<String, SchemaInfo> schemaMap;
-
+ private DestinationFactoryManager destinationFactoryManager;
+
public void setUp() throws Exception {
jaxbDataBinding = new JAXBDataBinding();
String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
@@ -67,37 +67,41 @@
wsdlReader.setFeature("javax.wsdl.verbose", false);
def = wsdlReader.readWSDL(wsdlUrl);
- WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
- for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
- if (serv != null) {
- service = serv;
- break;
- }
- }
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
- wsdlServiceBuilder = new WSDLServiceBuilder(bus);
-
+ destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
+
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
+ EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
+ .andStubReturn(destinationFactoryManager);
control.replay();
+
+ WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
+ for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
+ if (serv != null) {
+ service = serv;
+ break;
+ }
+ }
+
serviceInfo = wsdlServiceBuilder.buildService(def, service);
String schema1 = getClass().getResource(SCHEMA1).toString();
String schema2 = getClass().getResource(SCHEMA2).toString();
List<String> schemas = new ArrayList<String>();
-
+
schemas.add(schema1);
schemas.add(schema2);
serviceInfo.setProperty(JAXBDataBinding.SCHEMA_RESOURCE, schemas);
schemaMap = jaxbDataBinding.getSchemas(serviceInfo);
}
-
+
public void tearDown() throws Exception {
-
+
}
-
+
public void testGetSchemas() throws Exception {
assertEquals(schemaMap.size(), 2);
assertTrue(schemaMap.containsKey("http://schemas.xmlsoap.org/wsdl/"));
@@ -109,6 +113,5 @@
assertEquals(wsdlSchema.getNamespaceURI(), "http://schemas.xmlsoap.org/wsdl/");
assertEquals(jmsSchema.getNamespaceURI(), "http://cxf.apache.org/transports/jms");
}
-
-
+
}
Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java Thu Oct 5 13:19:52 2006
@@ -36,6 +36,7 @@
import org.apache.cxf.binding.BindingFactoryManager;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.greeter_control.types.GreetMe;
import org.apache.cxf.interceptor.WrappedInInterceptor;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.ExchangeImpl;
@@ -90,7 +91,8 @@
service.setDataBinding(new JAXBDataBinding(Greeter.class));
operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
- operation.getOperationInfo().setProperty(WrappedInInterceptor.WRAPPER_CLASS, Boolean.TRUE);
+ operation.getOperationInfo().getUnwrappedOperation()
+ .getInput().setProperty(WrappedInInterceptor.WRAPPER_CLASS, GreetMe.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Thu Oct 5 13:19:52 2006
@@ -19,14 +19,11 @@
package org.apache.cxf.jaxws;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
-import java.util.ResourceBundle;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
-import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.validation.Schema;
import javax.xml.ws.Binding;
@@ -35,17 +32,15 @@
import javax.xml.ws.handler.Handler;
import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
import org.apache.cxf.common.injection.ResourceInjector;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.endpoint.Server;
import org.apache.cxf.endpoint.ServerImpl;
import org.apache.cxf.jaxb.JAXBDataReaderFactory;
import org.apache.cxf.jaxb.JAXBDataWriterFactory;
import org.apache.cxf.jaxws.context.WebContextResourceResolver;
import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
-//import org.apache.cxf.jaxws.javaee.HandlerChainType;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
@@ -54,27 +49,22 @@
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
import org.apache.cxf.service.Service;
-import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.ChainInitiationObserver;
-import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.factory.ServerFactoryBean;
import org.apache.cxf.wsdl.EndpointReferenceUtils;
public class EndpointImpl extends javax.xml.ws.Endpoint {
-
private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
- private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
protected boolean doInit;
private Bus bus;
- // private String bindingURI;
private Object implementor;
- private ServerImpl server;
+ private Server server;
private Service service;
- private JaxWsEndpointImpl endpoint;
private JaxWsImplementorInfo implInfo;
-
+ private ReflectionServiceFactoryBean serviceFactory;
+
@SuppressWarnings("unchecked")
public EndpointImpl(Bus b, Object i, String uri) {
bus = b;
@@ -82,8 +72,7 @@
// bindingURI = uri;
// build up the Service model
implInfo = new JaxWsImplementorInfo(implementor.getClass());
-
- AbstractServiceFactoryBean serviceFactory;
+
if (implInfo.isWebServiceProvider()) {
serviceFactory = new ProviderServiceFactoryBean(implInfo);
} else {
@@ -92,46 +81,31 @@
serviceFactory.setBus(bus);
service = serviceFactory.create();
configureObject(service);
-
- // create the endpoint
- QName endpointName = implInfo.getEndpointName();
- EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
- if (ei == null) {
- throw new NullPointerException("Could not find endpoint " + endpointName + " in Service.");
- }
-
+
// revisit: should get enableSchemaValidation from configuration
if (false) {
addSchemaValidation();
}
-
+
if (implInfo.isWebServiceProvider()) {
service.setInvoker(new ProviderInvoker((Provider<?>)i));
} else {
service.setInvoker(new JAXWSMethodInvoker(i));
}
-
- // TODO: use bindigURI
- try {
- endpoint = new JaxWsEndpointImpl(bus, service, ei);
- } catch (EndpointException e) {
- throw new WebServiceException(e);
- }
- configureObject(endpoint);
-
+
doInit = true;
}
public Binding getBinding() {
- return endpoint.getJaxwsBinding();
+ return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding();
}
public void setExecutor(Executor executor) {
- server.getEndpoint().getService().setExecutor(executor);
+ service.setExecutor(executor);
}
public Executor getExecutor() {
- return server.getEndpoint().getService().getExecutor();
+ return service.getExecutor();
}
@Override
@@ -186,8 +160,9 @@
}
public ServerImpl getServer() {
- return server;
+ return (ServerImpl) server;
}
+
/**
* inject resources into servant. The resources are injected
@@ -209,47 +184,43 @@
}
protected void doPublish(String address) {
- init();
-
- if (null != address) {
- endpoint.getEndpointInfo().setAddress(address);
- }
-
- try {
- MessageObserver observer;
- if (implInfo.isWebServiceProvider()) {
- observer = new ProviderChainObserver(endpoint, bus, implInfo);
- } else {
- observer = new ChainInitiationObserver(endpoint, bus);
- }
+ ServerFactoryBean svrFactory = new ServerFactoryBean();
+ svrFactory.setBus(bus);
+ svrFactory.setAddress(address);
+ svrFactory.setServiceFactory(serviceFactory);
+ svrFactory.setTransportId("http://schemas.xmlsoap.org/wsdl/soap/");
+ svrFactory.setStart(false);
+
+ server = svrFactory.create();
- server = new ServerImpl(bus, endpoint, observer);
- server.start();
- } catch (BusException ex) {
- throw new WebServiceException(BUNDLE.getString("FAILED_TO_PUBLISH_ENDPOINT_EXC"), ex);
- } catch (IOException ex) {
- throw new WebServiceException(BUNDLE.getString("FAILED_TO_PUBLISH_ENDPOINT_EXC"), ex);
+ init();
+
+ if (implInfo.isWebServiceProvider()) {
+ getServer().setMessageObserver(new ProviderChainObserver(getEndpoint(), bus, implInfo));
}
+ configureObject(getEndpoint());
+
+ server.start();
}
-
+
org.apache.cxf.endpoint.Endpoint getEndpoint() {
- return endpoint;
+ return ((ServerImpl)getServer()).getEndpoint();
}
-
+
private void configureObject(Object instance) {
Configurer configurer = bus.getExtension(Configurer.class);
if (null != configurer) {
configurer.configureBean(instance);
}
}
-
+
private void addSchemaValidation() {
Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfo());
-
+
if (service.getDataBinding().getDataReaderFactory() instanceof JAXBDataReaderFactory) {
((JAXBDataReaderFactory)service.getDataBinding().getDataReaderFactory()).setSchema(schema);
}
-
+
if (service.getDataBinding().getDataWriterFactory() instanceof JAXBDataWriterFactory) {
((JAXBDataWriterFactory)service.getDataBinding().getDataWriterFactory()).setSchema(schema);
}
@@ -260,18 +231,16 @@
try {
injectResources(implementor);
configureHandlers();
-
} catch (Exception ex) {
- ex.printStackTrace();
- if (ex instanceof WebServiceException) {
- throw (WebServiceException)ex;
+ if (ex instanceof WebServiceException) {
+ throw (WebServiceException)ex;
}
throw new WebServiceException("Creation of Endpoint failed", ex);
}
}
doInit = false;
}
-
+
/**
* Obtain handler chain from configuration first. If none is specified,
* default to the chain configured in the code, i.e. in annotations.
@@ -291,4 +260,4 @@
}
getBinding().setHandlerChain(chain);
}
-}
+}
\ No newline at end of file
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java?view=auto&rev=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java Thu Oct 5 13:19:52 2006
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws;
+
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.FactoryBean;
+
+public class JaxWsEndpointProxyFactoryBean implements FactoryBean {
+ private Class serviceInterface;
+ private QName endpointName;
+ private String username;
+ private String password;
+ private String address;
+
+ public Object getObject() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Class getObjectType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isSingleton() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public QName getEndpointName() {
+ return endpointName;
+ }
+
+ public void setEndpointName(QName endpointName) {
+ this.endpointName = endpointName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public Class getServiceInterface() {
+ return serviceInterface;
+ }
+
+ public void setServiceInterface(Class serviceInterface) {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+}
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsEndpointProxyFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Thu Oct 5 13:19:52 2006
@@ -78,7 +78,7 @@
@Override
public String getServiceName() {
WebService ws = getConcreteWebServiceAttribute();
- if (ws != null) {
+ if (ws != null && ws.serviceName().length() > 0) {
return ws.serviceName();
}
@@ -88,7 +88,7 @@
@Override
public String getServiceNamespace() {
WebService ws = getConcreteWebServiceAttribute();
- if (ws != null) {
+ if (ws != null && ws.targetNamespace().length() > 0) {
return ws.targetNamespace();
}
@@ -96,6 +96,11 @@
}
@Override
+ public QName getEndpointName() {
+ return implInfo.getEndpointName();
+ }
+
+ @Override
public URL getWsdlURL() {
WebService ws = getPortTypeWebServiceAttribute();
if (ws != null && ws.wsdlLocation().length() > 0) {
@@ -117,17 +122,17 @@
}
@Override
- public QName getOperationName(InterfaceInfo service, Method method) {
+ public QName getOperationName(InterfaceInfo intf, Method method) {
method = getDeclaredMethod(method);
WebMethod wm = method.getAnnotation(WebMethod.class);
if (wm != null) {
String name = wm.operationName();
- if (name == null) {
+ if (name.length() == 0) {
name = method.getName();
}
- return new QName(service.getName().getNamespaceURI(), name);
+ return new QName(intf.getName().getNamespaceURI(), name);
}
return null;
@@ -165,7 +170,7 @@
}
return method;
}
-
+
@Override
public Class getResponseWrapper(Method selected) {
Method m = getDeclaredMethod(selected);
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Thu Oct 5 13:19:52 2006
@@ -19,7 +19,6 @@
package org.apache.cxf.jaxws.support;
-import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
@@ -28,20 +27,17 @@
import java.util.Arrays;
import java.util.List;
-import javax.wsdl.WSDLException;
import javax.xml.bind.JAXBException;
import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Holder;
import javax.xml.ws.WebFault;
-import org.apache.cxf.BusException;
+import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.endpoint.EndpointException;
-import org.apache.cxf.endpoint.ServerImpl;
import org.apache.cxf.interceptor.WrappedInInterceptor;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor;
import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.factory.MethodDispatcher;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.service.factory.ServiceConstructionException;
import org.apache.cxf.service.model.EndpointInfo;
@@ -49,13 +45,13 @@
import org.apache.cxf.service.model.InterfaceInfo;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.OperationInfo;
-import org.apache.cxf.transport.ChainInitiationObserver;
public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
-
- public static final String MODE_OUT = "messagepart.mode.out";
+ public static final String MODE_OUT = "messagepart.mode.out";
public static final String MODE_INOUT = "messagepart.mode.inout";
+
+ public static final String HOLDER = "messagepart.isholder";
private JAXBDataBinding dataBinding;
@@ -63,115 +59,92 @@
private JaxWsImplementorInfo jaxWsImplementorInfo;
- private JaxWsMethodDispatcher methodDispatcher = new JaxWsMethodDispatcher();
-
public JaxWsServiceFactoryBean() {
jaxWsConfiguration = new JaxWsServiceConfiguration();
getServiceConfigurations().add(0, jaxWsConfiguration);
}
-
+
public JaxWsServiceFactoryBean(JaxWsImplementorInfo implInfo) {
this();
this.jaxWsImplementorInfo = implInfo;
this.serviceClass = implInfo.getImplementorClass();
}
-
- @Override
- public Service create() {
- Service service = super.create();
-
- service.put(MethodDispatcher.class.getName(), methodDispatcher);
-
- return service;
- }
-
+
@Override
public void setServiceClass(Class<?> serviceClass) {
if (jaxWsImplementorInfo == null) {
jaxWsImplementorInfo = new JaxWsImplementorInfo(serviceClass);
}
-
+
super.setServiceClass(serviceClass);
}
@Override
protected void initializeDefaultInterceptors() {
super.initializeDefaultInterceptors();
-
+
getService().getOutFaultInterceptors().add(new WebFaultOutInterceptor());
}
- public void activateEndpoints() throws IOException, WSDLException, BusException, EndpointException {
- Service service = getService();
-
- for (EndpointInfo ei : service.getServiceInfo().getEndpoints()) {
- activateEndpoint(service, ei);
- }
- }
-
- public void activateEndpoint(Service service, EndpointInfo ei) throws BusException, WSDLException,
- IOException, EndpointException {
- JaxWsEndpointImpl ep = new JaxWsEndpointImpl(getBus(), service, ei);
- ChainInitiationObserver observer = new ChainInitiationObserver(ep, getBus());
-
- ServerImpl server = new ServerImpl(getBus(), ep, observer);
-
- server.start();
+ @Override
+ protected Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
+ return new JaxWsEndpointImpl(getBus(), getService(), ei);
}
@SuppressWarnings("unchecked")
@Override
protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
method = jaxWsConfiguration.getDeclaredMethod(method);
-
+
super.initializeWSDLOperation(intf, o, method);
- intializeWrapping(o, method);
-
+ initializeWrapping(o, method);
+
try {
// Find the Async method which returns a Response
- Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
- method.getParameterTypes());
+ Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
+ method.getParameterTypes());
+
// Find the Async method whic has a Future & AsyncResultHandler
List<Class<?>> asyncHandlerParams = new ArrayList(Arrays.asList(method.getParameterTypes()));
asyncHandlerParams.add(AsyncHandler.class);
- Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
- asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
+ Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
+ asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
- methodDispatcher.bind(o, method, responseMethod, futureMethod);
+ getMethodDispatcher().bind(o, method, responseMethod, futureMethod);
} catch (SecurityException e) {
throw new ServiceConstructionException(e);
} catch (NoSuchMethodException e) {
- methodDispatcher.bind(o, method);
+ getMethodDispatcher().bind(o, method);
}
-
+
// rpc out-message-part-info class mapping
initalizeClassInfo(o, method);
}
- void intializeWrapping(OperationInfo o, Method selected) {
+ void initializeWrapping(OperationInfo o, Method selected) {
Class responseWrapper = getResponseWrapper(selected);
if (responseWrapper != null) {
o.getUnwrappedOperation().getOutput().setProperty(WrapperClassOutInterceptor.WRAPPER_CLASS,
- responseWrapper);
+ responseWrapper);
}
Class<?> requestWrapper = getRequestWrapper(selected);
if (requestWrapper != null) {
o.getUnwrappedOperation().getInput().setProperty(WrappedInInterceptor.WRAPPER_CLASS,
- requestWrapper);
+ requestWrapper);
}
}
@Override
- protected void initializeDataBindings() {
+ protected void initializeDataBindings() {
try {
dataBinding = new JAXBDataBinding(jaxWsConfiguration.getEndpointClass());
} catch (JAXBException e) {
throw new ServiceConstructionException(e);
}
-
+
setDataBinding(dataBinding);
super.initializeDataBindings();
@@ -198,7 +171,7 @@
Object[] paraType = selected.getGenericParameterTypes();
for (MessagePartInfo mpiIn : o.getInput().getMessageParts()) {
// check for sayHi() type no input param method
- if (para.length > 0) {
+ if (para.length > 0 && !para[inIdx].equals(Holder.class)) {
mpiIn.setProperty(Class.class.getName(), para[inIdx]);
}
if (mpiOut.getName().equals(mpiIn.getName())) {
@@ -254,7 +227,7 @@
i++;
}
}
-
+
private static Class getHolderClass(ParameterizedType paramType, int idx) {
if (((Class) paramType.getRawType()).getName().equals("javax.xml.ws.Holder")) {
Object rawType = paramType.getActualTypeArguments()[0];
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java Thu Oct 5 13:19:52 2006
@@ -27,9 +27,10 @@
import org.apache.cxf.binding.xml.XMLConstants;
import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointException;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.service.Service;
-import org.apache.cxf.service.factory.MethodDispatcher;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.service.factory.ServiceConstructionException;
import org.apache.cxf.service.model.BindingInfo;
@@ -44,7 +45,6 @@
private JaxWsImplementorInfo jaxWsImplmentorInfo;
private String bindingURI;
- private JaxWsMethodDispatcher md;
public ProviderServiceFactoryBean(JaxWsImplementorInfo implInfo) {
this.jaxWsImplmentorInfo = implInfo;
@@ -62,11 +62,11 @@
try {
Method invoke = getServiceClass().getMethod("invoke", c);
- md = new JaxWsMethodDispatcher();
+
// Bind each operation to the invoke method.
for (OperationInfo o : getService().getServiceInfo().getInterface().getOperations()) {
- md.bind(o, invoke);
+ getMethodDispatcher().bind(o, invoke);
}
} catch (SecurityException e) {
@@ -75,6 +75,11 @@
throw new ServiceConstructionException(e);
}
}
+
+ @Override
+ protected Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
+ return new JaxWsEndpointImpl(getBus(), getService(), ei);
+ }
/**
* Create a mock service model with two operations - invoke and invokeOneway.
@@ -98,13 +103,22 @@
OperationInfo invokeOneWay = intf.addOperation(new QName(getServiceNamespace(), "invokeOneWay"));
invokeOneWay.setInput("input", input);
-
- md = new JaxWsMethodDispatcher();
-
+
return intf;
}
+
@Override
+ public Service create() {
+ Service s = super.create();
+
+ if (jaxWsImplmentorInfo.getWsdlLocation().length() == 0) {
+ initializeBindings();
+ }
+
+ return s;
+ }
+
protected void initializeBindings() {
ServiceInfo si = getService().getServiceInfo();
if (XMLConstants.NS_XML_FORMAT.equals(bindingURI)) {
@@ -124,15 +138,6 @@
} else if ("soapns".equals(bindingURI)) {
// TODO
}
- }
-
- @Override
- public Service create() {
- Service s = super.create();
-
- s.put(MethodDispatcher.class.getName(), md);
-
- return s;
}
@Override
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java Thu Oct 5 13:19:52 2006
@@ -23,6 +23,7 @@
import java.net.URL;
import java.util.ResourceBundle;
+import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceProvider;
@@ -60,6 +61,11 @@
return wsProvider.targetNamespace();
}
return null;
+ }
+
+ @Override
+ public QName getEndpointName() {
+ return implInfo.getEndpointName();
}
@Override
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java Thu Oct 5 13:19:52 2006
@@ -22,20 +22,20 @@
import org.apache.cxf.binding.BindingFactoryManager;
import org.apache.cxf.binding.soap.SoapBindingFactory;
import org.apache.cxf.binding.soap.SoapDestinationFactory;
-import org.apache.cxf.jaxws.EndpointImplTest.EchoObserver;
-import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.test.AbstractCXFTest;
import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.local.LocalTransportFactory;
-import org.xmlsoap.schemas.wsdl.http.AddressType;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
/**
* Abstract test which sets up the local transport and soap binding.
*/
public abstract class AbstractJaxWsTest extends AbstractCXFTest {
+ LocalTransportFactory localTransport;
+
private Bus bus;
@Override
@@ -52,21 +52,19 @@
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
- LocalTransportFactory localTransport = new LocalTransportFactory();
+ localTransport = new LocalTransportFactory();
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+ dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
+ extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/", localTransport);
- EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
- AddressType a = new AddressType();
- a.setLocation("http://localhost:9000/SoapContext/SoapPort");
- ei.addExtensor(a);
-
- Destination d = localTransport.getDestination(ei);
- d.setMessageObserver(new EchoObserver());
+ bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
}
}
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?view=auto&rev=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java Thu Oct 5 13:19:52 2006
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws;
+
+import java.util.Collection;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxws.service.Hello;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ServerFactoryBean;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+
+public class CodeFirstTest extends AbstractJaxWsTest {
+ public void testModel() throws Exception {
+ JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+
+ Bus bus = getBus();
+ bean.setBus(bus);
+ bean.setServiceClass(Hello.class);
+
+ Service service = bean.create();
+
+ InterfaceInfo i = service.getServiceInfo().getInterface();
+ assertEquals(1, i.getOperations().size());
+
+ ServerFactoryBean svrFactory = new ServerFactoryBean();
+ svrFactory.setBus(bus);
+ svrFactory.setServiceFactory(bean);
+ svrFactory.setTransportId("http://schemas.xmlsoap.org/soap/");
+ svrFactory.create();
+
+ Collection<BindingInfo> bindings = service.getServiceInfo().getBindings();
+ assertEquals(1, bindings.size());
+ }
+
+ public void testEndpoint() throws Exception {
+ Hello service = new Hello();
+
+ EndpointImpl ep = new EndpointImpl(getBus(), service, null);
+ ep.publish("http://localhost:9090/hello");
+
+ Node res = invoke("http://localhost:9090/hello",
+ LocalTransportFactory.TRANSPORT_ID,
+ "sayHi.xml");
+
+ assertNotNull(res);
+
+ addNamespace("h", "http://service.jaxws.cxf.apache.org");
+ assertValid("//s:Body/h:sayHiResponse/h:out", res);
+ }
+}
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java Thu Oct 5 13:19:52 2006
@@ -30,6 +30,9 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapDestinationFactory;
import org.apache.cxf.bus.cxf.CXFBusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.configuration.Configurer;
@@ -39,6 +42,8 @@
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.GreeterImpl;
import org.apache.hello_world_soap_http.SOAPService;
@@ -192,6 +197,7 @@
factory.setDefaultBus(null);
factory.getDefaultBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
+ initializeBus();
doTestDefaultServerEndpoint();
}
@@ -200,6 +206,7 @@
factory.setDefaultBus(null);
factory.getDefaultBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
+ initializeBus();
doTestDefaultServerEndpoint();
}
@@ -207,6 +214,7 @@
Object implementor = new GreeterImpl();
EndpointImpl ei = (EndpointImpl)(javax.xml.ws.Endpoint.create(implementor));
+ ei.publish("http://localhost/greeter");
JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl)ei.getEndpoint();
assertEquals("Unexpected bean name", PORT_NAME.toString(), endpoint.getBeanName());
@@ -241,6 +249,7 @@
properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME,
"org/apache/cxf/jaxws/configured-endpoints.xml");
cf.setDefaultBus(cf.createBus(null, properties));
+ initializeBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
doTestConfiguredServerEndpoint();
}
@@ -250,6 +259,7 @@
factory = sf;
factory.setDefaultBus(null);
sf.setDefaultBus(sf.createBus("org/apache/cxf/jaxws/configured-endpoints.xml"));
+ initializeBus();
System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, SpringBusFactory.class.getName());
doTestConfiguredServerEndpoint();
}
@@ -259,6 +269,7 @@
Object implementor = new GreeterImpl();
EndpointImpl ei = (EndpointImpl)(javax.xml.ws.Endpoint.create(implementor));
+ ei.publish("http://localhost/greeter");
JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl)ei.getEndpoint();
assertEquals("Unexpected bean name", PORT_NAME.toString(), endpoint.getBeanName());
@@ -300,6 +311,25 @@
findTestInterceptor(interceptors).getId());
}
+ private void initializeBus() {
+ Bus bus = factory.getDefaultBus();
+
+ SoapBindingFactory bindingFactory = new SoapBindingFactory();
+
+ bus.getExtension(BindingFactoryManager.class)
+ .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+
+ DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+ SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+
+ LocalTransportFactory localTransport = new LocalTransportFactory();
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+ }
+
+
private AbstractPhaseInterceptor findTestInterceptor(List<Interceptor> interceptors) {
for (Interceptor i : interceptors) {
if (i instanceof TestInterceptor) {
Copied: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java (from r450257, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java?view=diff&rev=453355&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java&r1=450257&p2=incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java&r2=453355
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/GreeterTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/GreeterTest.java Thu Oct 5 13:19:52 2006
@@ -17,26 +17,21 @@
* under the License.
*/
-package org.apache.cxf.systest.jaxws;
+package org.apache.cxf.jaxws;
import java.net.URL;
import org.w3c.dom.Node;
import org.apache.cxf.Bus;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.binding.soap.SoapBindingFactory;
-import org.apache.cxf.binding.soap.SoapDestinationFactory;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ServerFactoryBean;
import org.apache.cxf.service.invoker.BeanInvoker;
-import org.apache.cxf.test.AbstractCXFTest;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.hello_world_soap_http.GreeterImpl;
-public class GreeterTest extends AbstractCXFTest {
+public class GreeterTest extends AbstractJaxWsTest {
private Bus bus;
@@ -45,21 +40,6 @@
super.setUp();
bus = getBus();
-
- SoapBindingFactory bindingFactory = new SoapBindingFactory();
-
- bus.getExtension(BindingFactoryManager.class)
- .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
-
- DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
- SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-
- LocalTransportFactory localTransport = new LocalTransportFactory();
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
-
- ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
- extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
}
public void testEndpoint() throws Exception {
@@ -78,7 +58,11 @@
assertEquals("SOAPService", service.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
- bean.activateEndpoints();
+ ServerFactoryBean svr = new ServerFactoryBean();
+ svr.setBus(bus);
+ svr.setServiceFactory(bean);
+
+ svr.create();
Node response = invoke("http://localhost:9000/SoapContext/SoapPort",
LocalTransportFactory.TRANSPORT_ID,
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HeaderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HeaderTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HeaderTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HeaderTest.java Thu Oct 5 13:19:52 2006
@@ -22,6 +22,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.factory.ServerFactoryBean;
import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.header_test.TestHeaderImpl;
@@ -35,8 +36,12 @@
bean.create();
- bean.activateEndpoints();
-
+ ServerFactoryBean svr = new ServerFactoryBean();
+ svr.setBus(bus);
+ svr.setServiceFactory(bean);
+
+ svr.create();
+
Node response = invoke("http://localhost:9104/SoapHeaderContext/SoapHeaderPort",
LocalTransportFactory.TRANSPORT_ID,
"testHeader5.xml");
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HolderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HolderTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HolderTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/HolderTest.java Thu Oct 5 13:19:52 2006
@@ -21,6 +21,8 @@
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.mtom_xop.HelloImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ServerFactoryBean;
public class HolderTest extends AbstractJaxWsTest {
public void testInvocation() throws Exception {
@@ -30,10 +32,15 @@
bean.setBus(bus);
bean.setServiceClass(HelloImpl.class);
- bean.create();
+ Service service = bean.create();
+ service.setInvoker(new JAXWSMethodInvoker(new HelloImpl()));
- bean.activateEndpoints();
-//
+ ServerFactoryBean svr = new ServerFactoryBean();
+ svr.setBus(bus);
+ svr.setServiceFactory(bean);
+
+ svr.create();
+
// Node response = invoke("http://localhost:9036/mime-test",
// LocalTransportFactory.TRANSPORT_ID,
// "echoData.xml");
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?view=diff&rev=453355&r1=453354&r2=453355
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java Thu Oct 5 13:19:52 2006
@@ -26,10 +26,6 @@
import javax.xml.namespace.QName;
-import org.apache.cxf.Bus;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.binding.soap.SoapBindingFactory;
-import org.apache.cxf.binding.soap.SoapDestinationFactory;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
@@ -39,47 +35,19 @@
import org.apache.cxf.service.invoker.BeanInvoker;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.test.AbstractCXFTest;
import org.apache.cxf.transport.Conduit;
-import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.Destination;
-import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.hello_world_soap_http.GreeterImpl;
-import org.xmlsoap.schemas.wsdl.http.AddressType;
-public class JaxWsClientTest extends AbstractCXFTest {
-
- private Bus bus;
+public class JaxWsClientTest extends AbstractJaxWsTest {
@Override
public void setUp() throws Exception {
super.setUp();
-
- bus = getBus();
-
- SoapBindingFactory bindingFactory = new SoapBindingFactory();
- bus.getExtension(BindingFactoryManager.class)
- .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
-
- DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
- SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-
- LocalTransportFactory localTransport = new LocalTransportFactory();
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
-
- ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
- extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
- extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
- extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
-
EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
- AddressType a = new AddressType();
- a.setLocation("http://localhost:9000/SoapContext/SoapPort");
- ei.addExtensor(a);
+ ei.setAddress("http://localhost:9000/SoapContext/SoapPort");
Destination d = localTransport.getDestination(ei);
d.setMessageObserver(new EchoObserver());
@@ -105,7 +73,7 @@
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
bean.setWsdlURL(resource);
- bean.setBus(bus);
+ bean.setBus(getBus());
bean.setServiceClass(GreeterImpl.class);
GreeterImpl greeter = new GreeterImpl();
BeanInvoker invoker = new BeanInvoker(greeter);
@@ -115,9 +83,9 @@
String namespace = "http://apache.org/hello_world_soap_http";
EndpointInfo ei = service.getServiceInfo().getEndpoint(new QName(namespace, "SoapPort"));
- JaxWsEndpointImpl endpoint = new JaxWsEndpointImpl(bus, service, ei);
+ JaxWsEndpointImpl endpoint = new JaxWsEndpointImpl(getBus(), service, ei);
- ClientImpl client = new ClientImpl(bus, endpoint);
+ ClientImpl client = new ClientImpl(getBus(), endpoint);
BindingOperationInfo bop = ei.getBinding().getOperation(new QName(namespace, "sayHi"));
assertNotNull(bop);
Copied: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SoapFaultTest.java (from r450257, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SoapFaultTest.java?view=diff&rev=453355&p1=incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java&r1=450257&p2=incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SoapFaultTest.java&r2=453355
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/SoapFaultTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SoapFaultTest.java Thu Oct 5 13:19:52 2006
@@ -17,16 +17,13 @@
* under the License.
*/
-package org.apache.cxf.systest.jaxws;
+package org.apache.cxf.jaxws;
import java.net.URL;
import org.w3c.dom.Node;
import org.apache.cxf.Bus;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.binding.soap.SoapBindingFactory;
-import org.apache.cxf.binding.soap.SoapDestinationFactory;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
@@ -34,14 +31,12 @@
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ServerFactoryBean;
import org.apache.cxf.service.invoker.BeanInvoker;
-import org.apache.cxf.test.AbstractCXFTest;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.hello_world_soap_http.GreeterImpl;
-public class SoapFaultTest extends AbstractCXFTest {
+public class SoapFaultTest extends AbstractJaxWsTest {
private Bus bus;
private Service service;
@@ -52,21 +47,6 @@
bus = getBus();
- SoapBindingFactory bindingFactory = new SoapBindingFactory();
-
- bus.getExtension(BindingFactoryManager.class)
- .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
-
- DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
- SoapDestinationFactory soapDF = new SoapDestinationFactory(dfm);
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-
- LocalTransportFactory localTransport = new LocalTransportFactory();
- dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
-
- ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
- extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
-
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
@@ -80,14 +60,19 @@
service = bean.create();
- bean.activateEndpoints();
+ ServerFactoryBean svrFactory = new ServerFactoryBean();
+ svrFactory.setBus(bus);
+ svrFactory.setServiceFactory(bean);
+
+ svrFactory.create();
}
public void testInterceptorThrowingSoapFault() throws Exception {
service.getInInterceptors().add(new FaultThrowingInterceptor());
Node response = invoke("http://localhost:9000/SoapContext/SoapPort",
- LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
+ LocalTransportFactory.TRANSPORT_ID,
+ "GreeterMessage.xml");
assertNotNull(response);