You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2008/06/16 02:06:35 UTC
svn commit: r668025 - in /incubator/tuscany/java/sca:
modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/
modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/
modules/binding-ws-axis2/src/te...
Author: nash
Date: Sun Jun 15 17:06:34 2008
New Revision: 668025
URL: http://svn.apache.org/viewvc?rev=668025&view=rev
Log:
Fix TUSCANY-2298
Added:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2WSDLHelper.java
Modified:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
incubator/tuscany/java/sca/vtest/wsbinding/nowsdl/soapversion/src/main/resources/nowsdlsoapversion.composite
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java Sun Jun 15 17:06:34 2008
@@ -30,6 +30,7 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -78,7 +79,6 @@
import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
@@ -116,6 +116,16 @@
this.contract = contract;
this.wsBinding = wsBinding;
this.policyHandlerClassnames = policyHandlerClassnames;
+ Definition definition = wsBinding.getWSDLDocument();
+ if (definition != null) {
+ // Can happen if a self-reference. Reuse the service's WSDL configuration.
+ // In theory this is just a useful optimization but in practice I found
+ // it was needed to make the JUnit test for the helloworld-ws-service-jms
+ // sample run.
+ } else {
+ definition = Axis2WSDLHelper.configureWSDLDefinition(wsBinding, component, contract, servletHost);
+ wsBinding.setWSDLDocument(definition);
+ }
}
protected void start() {
@@ -172,14 +182,31 @@
createPolicyHandlers();
setupPolicyHandlers(policyHandlerList, configContext);
- configureWSDLDefinition(wsBinding, component, contract);
- // The service, port and WSDL definition can be set by the above call
- Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
- QName serviceQName =
- wsBinding.getService() != null ? wsBinding.getService().getQName() : wsBinding.getServiceName();
- String portName = wsBinding.getPort() != null ? wsBinding.getPort().getName() : wsBinding.getPortName();
+ Definition definition = wsBinding.getWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
+ Port port = wsBinding.getPort();
+ if (port == null) {
+ // service has multiple ports, select one port to use
+ Collection<Port> ports = wsBinding.getService().getPorts().values();
+ for (Port p : ports) {
+ // look for a SOAP 1.1 port first
+ if (p.getExtensibilityElements().get(0) instanceof SOAPAddress) {
+ port = p;
+ break;
+ }
+ }
+ if (port == null) {
+ // no SOAP 1.1 port available, so look for a SOAP 1.2 port
+ for (Port p : ports) {
+ if (p.getExtensibilityElements().get(0) instanceof SOAP12Address) {
+ port = p;
+ break;
+ }
+ }
+ }
+ }
AxisService axisService =
- createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
+ createClientSideAxisService(definition, serviceQName, port.getName(), new Options());
HttpClient httpClient = (HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
if (httpClient == null) {
@@ -277,12 +304,12 @@
* @throws AxisFault
*/
@Deprecated
- public static AxisService createClientSideAxisService(Definition wsdlDefinition,
- QName wsdlServiceName,
+ public static AxisService createClientSideAxisService(Definition definition,
+ QName serviceName,
String portName,
Options options) throws AxisFault {
- Definition def = getDefinition(wsdlDefinition, wsdlServiceName);
- final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, wsdlServiceName, portName);
+ Definition def = getDefinition(definition, serviceName);
+ final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, serviceName, portName);
serviceBuilder.setServerSide(false);
// [rfeng] Add a custom resolver to work around WSCOMMONS-228
serviceBuilder.setCustomResolver(new URIResolverImpl(def));
@@ -308,6 +335,7 @@
return axisService;
}
+ /*
private static <T extends ExtensibilityElement> T getExtensibilityElement(List elements, Class<T> type) {
for (Object e : elements) {
if (type.isInstance(e)) {
@@ -316,186 +344,7 @@
}
return null;
}
-
- /**
- * Generate a suitably configured WSDL definition
- */
- protected static void configureWSDLDefinition(WebServiceBinding wsBinding,
- RuntimeComponent component,
- AbstractContract contract) {
- WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition();
- Definition def = wsdlDefinition.getDefinition();
- if (wsBinding.getWSDLDefinition().getURI() != null) {
- // The WSDL document was provided by the user. Generate a new
- // WSDL document with imports from the user-provided document.
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- throw new RuntimeException(e);
- }
- Definition definition = factory.newDefinition();
-
- // Construct a target namespace from the base URI of the user's
- // WSDL document (is this what we should be using?) and a path
- // computed according to the SCA Web Service binding spec.
- String nsName = component.getName() + "/" + contract.getName();
- String namespaceURI = null;
- try {
- URI userTNS = new URI(def.getTargetNamespace());
- namespaceURI = userTNS.resolve("/" + nsName).toString();
- } catch (URISyntaxException e1) {
- } catch (IllegalArgumentException e2) {
- }
-
- // set name and targetNamespace attributes on the definition
- String defsName = component.getName() + "." + contract.getName();
- definition.setQName(new QName(namespaceURI, defsName));
- definition.setTargetNamespace(namespaceURI);
- definition.addNamespace("tns", namespaceURI);
-
- // add soap11 or soap12 prefix as required
- boolean requiresSOAP11 = false;
- boolean requiresSOAP12 = false;
- for (Object binding : def.getAllBindings().values()) {
- List bindingExtensions = ((Binding)binding).getExtensibilityElements();
- for (final Object extension : bindingExtensions) {
- if (extension instanceof SOAPBinding) {
- requiresSOAP11 = true;
- }
- if (extension instanceof SOAP12Binding) {
- requiresSOAP12 = true;
- }
- }
- }
- if (requiresSOAP11 || wsBinding.getBinding() == null) {
- definition.addNamespace("soap11", "http://schemas.xmlsoap.org/wsdl/soap/");
- }
- if (requiresSOAP12) {
- definition.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
- }
-
- // set wsdl namespace prefix on the definition
- definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
-
- // import the existing portType
- int index = 0;
- List<WSDLDefinition> imports = new ArrayList<WSDLDefinition>();
- InterfaceContract ic = wsBinding.getBindingInterfaceContract();
- WSDLInterface wi = (WSDLInterface)ic.getInterface();
- PortType portType = wi.getPortType();
- WSDLDefinition ptDef = getPortTypeDefinition(wsdlDefinition, portType.getQName());
- if (ptDef != null) {
- Import imp = definition.createImport();
- String ptNamespace = portType.getQName().getNamespaceURI();
- imp.setNamespaceURI(ptNamespace);
- imp.setLocationURI(ptDef.getURI().toString());
- imp.setDefinition(ptDef.getDefinition());
- imports.add(ptDef);
- definition.addNamespace("ns" + index++, ptNamespace);
- definition.addImport(imp);
- } else {
- throw new RuntimeException("Unable to find portType " + portType.getQName());
- }
-
- // import an existing binding if specified
- Binding binding = wsBinding.getBinding();
- if (binding != null) {
- String biNamespace = binding.getQName().getNamespaceURI();
- if (definition.getImports(biNamespace) == null) {
- WSDLDefinition biDef = getBindingDefinition(wsdlDefinition, binding.getQName());
- if (biDef != null) {
- Import imp = definition.createImport();
- imp.setNamespaceURI(biNamespace);
- imp.setLocationURI(biDef.getURI().toString());
- imp.setDefinition(biDef.getDefinition());
- imports.add(biDef);
- definition.addNamespace("ns" + index++, biNamespace);
- definition.addImport(imp);
- } else {
- throw new RuntimeException("Unable to find binding " + binding.getQName());
- }
- }
- }
-
- // replace original WSDL definition by the generated definition
- def = definition;
- wsdlDefinition.setDefinition(definition);
- wsdlDefinition.setLocation(null);
- wsdlDefinition.setURI(null);
- wsdlDefinition.getImportedDefinitions().clear();
- wsdlDefinition.getImportedDefinitions().addAll(imports);
- }
-
- QName serviceQName = wsBinding.getServiceName();
- String portName = wsBinding.getPortName();
-
- if (portName != null || serviceQName != null) {
- return;
- }
-
- // If no WSDL service or port is specified in the binding element, add a
- // suitably configured service and port to the WSDL definition.
- WSDLDefinitionGenerator helper =
- new WSDLDefinitionGenerator(Axis2ServiceBindingProvider.requiresSOAP12(wsBinding));
- if (wsBinding.getBinding() == null) {
- InterfaceContract ic = wsBinding.getBindingInterfaceContract();
- WSDLInterface wi = (WSDLInterface)ic.getInterface();
- PortType portType = wi.getPortType();
- Service service = helper.createService(def, portType);
- Binding binding = helper.createBinding(def, portType);
- helper.createBindingOperations(def, binding, portType);
- binding.setUndefined(false);
- def.addBinding(binding);
-
- Port port = helper.createPort(def, binding, service, wsBinding.getURI());
- wsBinding.setService(service);
- wsBinding.setPort(port);
- wsBinding.setBinding(port.getBinding());
- } else {
- Service service = helper.createService(def, wsBinding.getBinding());
- Port port = helper.createPort(def, wsBinding.getBinding(), service, wsBinding.getURI());
- wsBinding.setService(service);
- wsBinding.setPort(port);
- }
-
- }
-
- private static WSDLDefinition getPortTypeDefinition(WSDLDefinition def, QName portTypeName) {
-
- if (def == null || portTypeName == null) {
- return def;
- }
- Object portType = def.getDefinition().getPortTypes().get(portTypeName);
- if (portType != null) {
- return def;
- }
- for (WSDLDefinition impDef : def.getImportedDefinitions()) {
- WSDLDefinition d = getPortTypeDefinition(impDef, portTypeName);
- if (d != null) {
- return d;
- }
- }
- return null;
- }
-
- private static WSDLDefinition getBindingDefinition(WSDLDefinition def, QName bindingName) {
-
- if (def == null || bindingName == null) {
- return def;
- }
- Object binding = def.getDefinition().getBindings().get(bindingName);
- if (binding != null) {
- return def;
- }
- for (WSDLDefinition impDef : def.getImportedDefinitions()) {
- WSDLDefinition d = getBindingDefinition(impDef, bindingName);
- if (d != null) {
- return d;
- }
- }
- return null;
- }
+ */
protected void stop() {
if (serviceClient != null) {
@@ -658,4 +507,5 @@
aHandler.setUp(configContext);
}
}
+
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java Sun Jun 15 17:06:34 2008
@@ -27,6 +27,7 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -69,6 +70,7 @@
import org.apache.axis2.description.WSDLToAxisServiceBuilder;
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.transport.jms.JMSConstants;
import org.apache.axis2.transport.jms.JMSListener;
import org.apache.axis2.transport.jms.JMSSender;
@@ -115,6 +117,8 @@
private JMSListener jmsListener;
private Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassnames = null;
private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>();
+ private Map<String, Port> urlMap = new HashMap<String, Port>();
+ private Map<String, String> addressMap = new HashMap<String, String>();
public static final QName QNAME_WSA_ADDRESS =
new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
@@ -124,10 +128,6 @@
new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory";
-
- private static final QName TRANSPORT_JMS_QUALIFIED_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","transport.jms");
- private PolicySet transportJmsPolicySet = null;
-
public Axis2ServiceProvider(RuntimeComponent component,
AbstractContract contract,
@@ -165,114 +165,99 @@
configContext.setContextRoot(servletHost.getContextPath());
- // pull out the binding intents to see what sort of transport is required
- transportJmsPolicySet = AxisPolicyHelper.getPolicySet(wsBinding, TRANSPORT_JMS_QUALIFIED_INTENT);
-
- String uri;
-
- if (transportJmsPolicySet != null){
- uri = computeActualURI(component, contract);
-
- if (!uri.startsWith("jms:/")) {
- uri = "jms:" + uri;
- }
-
- // construct the rest of the URI based on the policy. All the details are put
- // into the URI here rather than being place directly into the Axis configuration
- // as the Axis JMS sender relies on parsing the target URI
- Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
- for ( Object policy : transportJmsPolicySet.getPolicies() ) {
- if ( policy instanceof Axis2ConfigParamPolicy ) {
- axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
- Iterator paramIterator = axis2ConfigParamPolicy.getParamElements().get(DEFAULT_QUEUE_CONNECTION_FACTORY).getChildElements();
-
- if (paramIterator.hasNext()){
- StringBuffer uriParams = new StringBuffer("?");
-
- while (paramIterator.hasNext()){
- OMElement parameter = (OMElement)paramIterator.next();
- uriParams.append(parameter.getAttributeValue(new QName("","name")));
- uriParams.append("=");
- uriParams.append(parameter.getText());
-
- if (paramIterator.hasNext()){
- uriParams.append("&");
- }
- }
-
- uri = uri + uriParams;
- }
+ /*
+ // Look at all the Web Service bindings of the SCA service to see if any
+ // of them have an existing generated WSDL definitions document. If found,
+ // use it for this binding as well. If not found, generate a new document.
+ Definition definition = null;
+ for (Binding binding : contract.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ definition = ((WebServiceBinding)binding).getWSDLDocument();
+ if (definition != null) {
+ wsBinding.setWSDLDocument(definition);
+ break;
}
- }
- } else {
- uri = computeActualURI(component, contract);
- if (!uri.startsWith("jms:")) {
- uri = servletHost.getURLMapping(uri).toString();
}
}
-
- wsBinding.setURI(uri);
+ */
+ // The above code is disabled temporarily. Instead, we only look
+ // for a WSDL definitions document in this binding and don't
+ // attempt to share the same document across multiple bindings.
+ Definition definition = wsBinding.getWSDLDocument();
+
+ // generate a WSDL definitions document if needed
+ if (definition == null) {
+ definition = Axis2WSDLHelper.configureWSDLDefinition(wsBinding, component, contract, servletHost);
+ wsBinding.setWSDLDocument(definition);
+ }
+
+ // The generated WSDL document maps ports to endpoint URLs. Create a
+ // reverse map that eliminates duplicate ports for the same endpoint.
+ for (Object port : wsBinding.getService().getPorts().values()) {
+ urlMap.put(getPortAddress((Port)port), (Port)port);
+ }
}
public void start() {
- // TODO: if <binding.ws> specifies the WSDL service then should create a
- // service for every port
-
try {
createPolicyHandlers();
- AxisService axisService = createAxisService();
- configContext.getAxisConfiguration().addService( axisService );
-
+ for (Map.Entry<String, Port> entry : urlMap.entrySet()) {
+ AxisService axisService = createAxisService(entry.getKey(), entry.getValue());
+ configContext.getAxisConfiguration().addService(axisService);
+ }
setupPolicyHandlers(policyHandlerList, configContext);
- String endpointURL = axisService.getEndpointURL();
- if ( endpointURL.startsWith( "http://") || endpointURL.startsWith("/")) {
- Axis2ServiceServlet servlet = new Axis2ServiceServlet();
- servlet.init(configContext);
- String servletURI = wsBinding.getURI();
- configContext.setContextRoot(servletURI);
- servletHost.addServletMapping(servletURI, servlet);
- } else if ( axisService.getEndpointURL().startsWith( "jms" ) ) {
- logger.log(Level.INFO,"Axis2 JMS URL=" + axisService.getEndpointURL() );
-
- jmsListener = new JMSListener();
- jmsSender = new JMSSender();
- ListenerManager listenerManager = configContext.getListenerManager();
- TransportInDescription trsIn = configContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS);
-
- // get JMS transport parameters from the binding URI
- Map<String, String> jmsProps = JMSUtils.getProperties( wsBinding.getURI() );
-
- // collect the parameters used to configure the JMS transport
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMElement parms = fac.createOMElement(DEFAULT_QUEUE_CONNECTION_FACTORY, null);
-
- for ( String key : jmsProps.keySet() ) {
- OMElement param = fac.createOMElement("parameter", null);
- param.addAttribute( "name", key, null );
- param.addChild(fac.createOMText(param, jmsProps.get(key)));
- parms.addChild(param);
- }
-
- Parameter queueConnectionFactory = new Parameter(DEFAULT_QUEUE_CONNECTION_FACTORY, parms);
- trsIn.addParameter( queueConnectionFactory );
-
- trsIn.setReceiver(jmsListener);
-
- configContext.getAxisConfiguration().addTransportIn( trsIn );
- TransportOutDescription trsOut = configContext.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS);
- //configContext.getAxisConfiguration().addTransportOut( trsOut );
- trsOut.setSender(jmsSender);
-
- if (listenerManager == null) {
- listenerManager = new ListenerManager();
- listenerManager.init(configContext);
- }
- listenerManager.addListener(trsIn, true);
- jmsSender.init(configContext, trsOut);
- jmsListener.init(configContext, trsIn);
- jmsListener.start();
+ Axis2ServiceServlet servlet = null;
+ for (String endpointURL : urlMap.keySet()) {
+ if (endpointURL.startsWith("http://") || endpointURL.startsWith("/")) {
+ if (servlet == null) {
+ servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+ }
+ //[nash] configContext.setContextRoot(endpointURL);
+ servletHost.addServletMapping(endpointURL, servlet);
+ } else if (endpointURL.startsWith("jms")) {
+ logger.log(Level.INFO,"Axis2 JMS URL=" + endpointURL);
+
+ jmsListener = new JMSListener();
+ jmsSender = new JMSSender();
+ ListenerManager listenerManager = configContext.getListenerManager();
+ TransportInDescription trsIn = configContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS);
+
+ // get JMS transport parameters from the computed URL
+ Map<String, String> jmsProps = JMSUtils.getProperties(endpointURL);
+
+ // collect the parameters used to configure the JMS transport
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement parms = fac.createOMElement(DEFAULT_QUEUE_CONNECTION_FACTORY, null);
+
+ for ( String key : jmsProps.keySet() ) {
+ OMElement param = fac.createOMElement("parameter", null);
+ param.addAttribute( "name", key, null );
+ param.addChild(fac.createOMText(param, jmsProps.get(key)));
+ parms.addChild(param);
+ }
+
+ Parameter queueConnectionFactory = new Parameter(DEFAULT_QUEUE_CONNECTION_FACTORY, parms);
+ trsIn.addParameter( queueConnectionFactory );
+
+ trsIn.setReceiver(jmsListener);
+
+ configContext.getAxisConfiguration().addTransportIn( trsIn );
+ TransportOutDescription trsOut = configContext.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS);
+ //configContext.getAxisConfiguration().addTransportOut( trsOut );
+ trsOut.setSender(jmsSender);
+
+ if (listenerManager == null) {
+ listenerManager = new ListenerManager();
+ listenerManager.init(configContext);
+ }
+ listenerManager.addListener(trsIn, true);
+ jmsSender.init(configContext, trsOut);
+ jmsListener.init(configContext, trsIn);
+ jmsListener.start();
+ }
}
} catch (AxisFault e) {
throw new RuntimeException(e);
@@ -291,24 +276,37 @@
jmsListener.destroy();
}
else {
- servletHost.removeServletMapping(wsBinding.getURI());
+ for (String endpointURL : urlMap.keySet()) {
+ servletHost.removeServletMapping(endpointURL);
+ }
}
if ( jmsSender != null )
jmsSender.stop();
try {
- // get the path to the service
- URI uriPath = new URI(wsBinding.getURI());
- String stringURIPath = uriPath.getPath();
+ for (String endpointURL : urlMap.keySet()) {
+ // get the path to the service
+ URI uriPath = new URI(endpointURL);
+ String stringURIPath = uriPath.getPath();
- // remove any "/" from the start of the path
- if (stringURIPath.startsWith("/")) {
- stringURIPath = stringURIPath.substring(1, stringURIPath.length());
- }
+ //[nash] Need a leading slash for WSDL imports to work with ?wsdl
+ /*
+ // remove any "/" from the start of the path
+ if (stringURIPath.startsWith("/")) {
+ stringURIPath = stringURIPath.substring(1, stringURIPath.length());
+ }
+ */
- // remove it from the Axis context
- configContext.getAxisConfiguration().removeService(stringURIPath);
+ // remove it from the Axis context
+ String modifiedURI = addressMap.remove(endpointURL);
+ for (Object port : wsBinding.getService().getPorts().values()) {
+ if (modifiedURI.equals(getPortAddress((Port)port))) {
+ setPortAddress((Port)port, endpointURL);
+ }
+ }
+ configContext.getAxisConfiguration().removeService(stringURIPath);
+ }
} catch (URISyntaxException e) {
throw new RuntimeException(e);
} catch (AxisFault e) {
@@ -316,106 +314,12 @@
}
}
- /**
- * Compute the endpoint URI based on section 2.1.1 of the WS binding Specification 1.
- * The URIs in the endpoint(s) of the referenced WSDL, which may be relative
- * 2. The URI specified by the wsa:Address element of the
- * wsa:EndpointReference, which may be relative 3. The explicitly stated URI
- * in the "uri" attribute of the binding.ws element, which may be relative,
- * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly Specification
- * If the <binding.ws> has no wsdlElement but does have a uri attribute then
- * the uri takes precedence over any implicitly used WSDL.
- *
- */
- protected String computeActualURI(RuntimeComponent component, AbstractContract contract) {
-
- org.apache.axis2.addressing.EndpointReference epr = null;
- URI eprURI = null;
- if (wsBinding.getEndPointReference() != null) {
- epr = getEPR();
- if (epr.getAddress() != null) {
- eprURI = URI.create(epr.getAddress());
- }
- }
-
- URI wsdlURI = null;
- if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
- // <binding.ws> explicitly points at a WSDL port, may be a relative URI
- wsdlURI = getEndpoint(wsBinding.getPort());
- }
-
- // if the WSDL port/endpoint has an absolute URI use that
- if (wsdlURI != null && wsdlURI.isAbsolute()) {
- return wsdlURI.toString();
- }
-
- // if the wsa:EndpointReference has an address element with an absolute URI use that
- if (eprURI != null && eprURI.isAbsolute()) {
- return eprURI.toString();
- }
-
- // either there is no WSDL port endpoint URI or that URI is relative
- String actualURI = wsBinding.getURI();
- if (eprURI != null && eprURI.toString().length() != 0) {
- // there is a relative URI in the binding EPR
- actualURI = actualURI + "/" + eprURI;
- }
-
- if (wsdlURI != null && wsdlURI.toString().length() != 0) {
- // there is a relative URI in the WSDL port
- actualURI = actualURI + "/" + wsdlURI;
- }
-
- actualURI = URI.create(actualURI).normalize().toString();
-
- return actualURI;
- }
-
- private org.apache.axis2.addressing.EndpointReference getEPR() {
- try {
-
- XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(wsBinding.getEndPointReference()));
- StAXOMBuilder builder = new StAXOMBuilder(parser);
- OMElement omElement = builder.getDocumentElement();
- org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement);
- return epr;
-
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- } catch (FactoryConfigurationError e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Returns the endpoint of a given port.
- */
- protected URI getEndpoint(Port wsdlPort) {
- if (wsdlPort != null) {
- List<?> wsdlPortExtensions = wsdlPort.getExtensibilityElements();
- for (Object extension : wsdlPortExtensions) {
- if (extension instanceof SOAPAddress) {
- String uri = ((SOAPAddress)extension).getLocationURI();
- return (uri == null || "".equals(uri)) ? null : URI.create(uri);
- }
- if (extension instanceof SOAP12Address) {
- SOAP12Address address = (SOAP12Address)extension;
- String uri = address.getLocationURI();
- return (uri == null || "".equals(uri)) ? null : URI.create(uri);
- }
- }
- }
- return null;
- }
-
- private AxisService createAxisService() throws AxisFault {
+ private AxisService createAxisService(String endpointURL, Port port) throws AxisFault {
AxisService axisService;
- if (wsBinding.getWSDLDefinition() != null) {
- axisService = createWSDLAxisService();
+ if (wsBinding.getWSDLDocument() != null) {
+ axisService = createWSDLAxisService(endpointURL, port);
} else {
- axisService = createJavaAxisService();
+ axisService = createJavaAxisService(endpointURL);
}
initAxisOperations(axisService);
return axisService;
@@ -424,11 +328,11 @@
/**
* Create an AxisService from the interface class from the SCA service interface
*/
- protected AxisService createJavaAxisService() throws AxisFault {
+ protected AxisService createJavaAxisService(String endpointURL) throws AxisFault {
AxisService axisService = new AxisService();
- String path = URI.create(wsBinding.getURI()).getPath();
+ String path = URI.create(endpointURL).getPath();
axisService.setName(path);
- axisService.setServiceDescription("Tuscany configured AxisService for service: " + wsBinding.getURI());
+ axisService.setServiceDescription("Tuscany configured AxisService for service: " + endpointURL);
axisService.setClientSide(false);
Parameter classParam =
new Parameter(Constants.SERVICE_CLASS, ((JavaInterface)contract.getInterfaceContract().getInterface())
@@ -477,18 +381,13 @@
/**
* Create an AxisService from the WSDL doc used by ws binding
*/
- protected AxisService createWSDLAxisService() throws AxisFault {
+ protected AxisService createWSDLAxisService(String endpointURL, Port port) throws AxisFault {
- Axis2ServiceClient.configureWSDLDefinition(wsBinding, component, contract);
- // The service, port and WSDL definition can be set by the above call
- Definition definition = wsBinding.getWSDLDefinition().getDefinition();
- QName serviceQName =
- wsBinding.getService() != null ? wsBinding.getService().getQName() : wsBinding.getServiceName();
- String portName = wsBinding.getPort() != null ? wsBinding.getPort().getName() : wsBinding.getPortName();
-
+ Definition definition = wsBinding.getWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
Definition def = getDefinition(definition, serviceQName);
- final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, portName);
+ final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, port.getName());
builder.setServerSide(true);
// [rfeng] Add a custom resolver to work around WSCOMMONS-228
builder.setCustomResolver(new URIResolverImpl(def));
@@ -507,12 +406,15 @@
} catch (PrivilegedActionException e) {
throw (AxisFault)e.getException();
}
- String path = URI.create(wsBinding.getURI()).getPath();
- String name = ( path.startsWith( "/") ? path.substring(1) : path );
+
+ String name = URI.create(endpointURL).getPath();
+ //[nash] HTTP endpoints need a leading slash for WSDL imports to work with ?wsdl
+ if (endpointURL.startsWith("jms")) {
+ name = name.startsWith("/") ? name.substring(1) : name;
+ }
axisService.setName(name);
- String endpointURL = wsBinding.getURI();
- axisService.setEndpointURL(endpointURL );
- axisService.setDocumentation("Tuscany configured AxisService for service: " + wsBinding.getURI());
+ axisService.setEndpointURL(endpointURL);
+ axisService.setDocumentation("Tuscany configured AxisService for service: " + endpointURL);
for ( Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext(); ) {
AxisEndpoint ae = (AxisEndpoint)i.next();
if (endpointURL.startsWith("jms") ) {
@@ -522,16 +424,62 @@
break;
}
}
+
// Use the existing WSDL
Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null);
- wsdlParam.setValue(def);
+ wsdlParam.setValue(definition);
axisService.addParameter(wsdlParam);
Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
axisService.addParameter(userWSDL);
+ // Axis2 1.3 has a bug with returning incorrect values for the port
+ // addresses. To work around this, compute the values here.
+ Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false");
+ axisService.addParameter(modifyAddr);
+ String modifiedURL = setIPAddress(endpointURL);
+ addressMap.put(endpointURL, modifiedURL);
+ for (Object p : wsBinding.getService().getPorts().values()) {
+ if (endpointURL.equals(getPortAddress((Port)p))) {
+ setPortAddress((Port)p, modifiedURL);
+ }
+ }
+
return axisService;
}
+ private String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ private void setPortAddress(Port port, String locationURI) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ ((SOAPAddress)ext).setLocationURI(locationURI);
+ }
+ if (ext instanceof SOAP12Address) {
+ ((SOAP12Address)ext).setLocationURI(locationURI);
+ }
+ }
+
+ private static String setIPAddress(String uriString) {
+ try {
+ URI uriObj = new URI(uriString);
+ String ipAddr = HttpUtils.getIpAddress();
+ String host = uriObj.getHost();
+ return uriString.replace(host, ipAddr);
+ } catch (Exception e) {
+ // URI string not in expected format, so return it unmodified
+ return uriString;
+ }
+ }
+
protected void initAxisOperations(AxisService axisService) {
for (Iterator<?> i = axisService.getOperations(); i.hasNext();) {
AxisOperation axisOp = (AxisOperation)i.next();
Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2WSDLHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2WSDLHelper.java?rev=668025&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2WSDLHelper.java (added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2WSDLHelper.java Sun Jun 15 17:06:34 2008
@@ -0,0 +1,524 @@
+/*
+ * 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.tuscany.sca.binding.ws.axis2;
+
+//FIXME: trim the import list down to what's really needed
+
+import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.SOAP12_INTENT;
+import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.isIntentRequired;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.util.threadpool.ThreadPool;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.interface2wsdl.WSDLDefinitionGenerator;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.xsd.xml.XMLDocumentHelper;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Axis2WSDLHelper provides WSDL generation support for Axis2ServiceProvider and Axis2SericeClient.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2WSDLHelper {
+ // the following switch is temporary for debugging
+ public static boolean printWSDL; // external code sets this to print generated WSDL
+
+ private static final QName TRANSPORT_JMS_QUALIFIED_INTENT =
+ new QName("http://www.osoa.org/xmlns/sca/1.0", "transport.jms");
+ private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory";
+
+ private Axis2WSDLHelper() {
+ // this class has static methods only and cannot be instantiated
+ }
+
+ /**
+ * Generate a suitably configured WSDL definition
+ */
+ protected static Definition configureWSDLDefinition(WebServiceBinding wsBinding,
+ RuntimeComponent component,
+ AbstractContract contract,
+ ServletHost servletHost) {
+ List<Port> ports = new ArrayList<Port>();
+ WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition();
+ Definition def = wsdlDefinition.getDefinition();
+ if (wsdlDefinition.getBinding() == null) {
+ // The WSDL document was provided by the user. Generate a new
+ // WSDL document with imports from the user-provided document.
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ throw new RuntimeException(e);
+ }
+ Definition newDef = factory.newDefinition();
+
+ // Construct a target namespace from the base URI of the user's
+ // WSDL document (is this what we should be using?) and a path
+ // computed according to the SCA Web Service binding spec.
+ String nsName = component.getName() + "/" + contract.getName();
+ String namespaceURI = null;
+ try {
+ URI userTNS = new URI(def.getTargetNamespace());
+ namespaceURI = userTNS.resolve("/" + nsName).toString();
+ } catch (URISyntaxException e1) {
+ } catch (IllegalArgumentException e2) {
+ }
+
+ // set name and targetNamespace attributes on the definition
+ String defsName = component.getName() + "." + contract.getName();
+ newDef.setQName(new QName(namespaceURI, defsName));
+ newDef.setTargetNamespace(namespaceURI);
+ newDef.addNamespace("tns", namespaceURI);
+
+ // set wsdl namespace prefix on the definition
+ newDef.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+
+ // import the service or reference interface portType
+ List<WSDLDefinition> imports = new ArrayList<WSDLDefinition>();
+ Interface interfaze = wsBinding.getBindingInterfaceContract().getInterface();
+ if (interfaze instanceof WSDLInterface) {
+ PortType portType = ((WSDLInterface)interfaze).getPortType();
+ importPortType(portType, wsdlDefinition, newDef, imports);
+ }
+
+ // import an existing binding if specified
+ Binding binding = wsBinding.getBinding();
+ if (binding != null) {
+ importBinding(binding, wsdlDefinition, newDef, imports);
+ }
+
+ // import bindings and portTypes needed by services and ports
+ QName serviceQName = wsBinding.getServiceName();
+ String portName = wsBinding.getPortName();
+ if (serviceQName != null) {
+ Service service = def.getService(serviceQName);
+ if (portName != null) {
+ Port port = service.getPort(portName);
+ Port newPort = copyPort(newDef, port, wsBinding, servletHost);
+ if (newPort != null) {
+ importBinding(port.getBinding(), wsdlDefinition, newDef, imports);
+ ports.add(newPort);
+ } else {
+ //FIXME: use the monitor to report a problem
+ }
+ } else {
+ for (Object port : service.getPorts().values()) {
+ Port newPort = copyPort(newDef, (Port)port, wsBinding, servletHost);
+ if (newPort != null) {
+ importBinding(((Port)port).getBinding(), wsdlDefinition, newDef, imports);
+ ports.add(newPort);
+ } else {
+ // not an error, just ignore the port
+ }
+ }
+ if (ports.size() == 0) {
+ //FIXME: use the monitor to report a problem
+ }
+ }
+ }
+
+ // replace original WSDL definition by the generated definition
+ def = newDef;
+
+ } else {
+ // The WSDL definition was generated by Interface2WSDLGenerator.
+ // Reuse it instead of creating a new definition here.
+ }
+
+ // add a service and ports to the generated definition
+ WSDLDefinitionGenerator helper =
+ new WSDLDefinitionGenerator(Axis2ServiceBindingProvider.requiresSOAP12(wsBinding));
+ WSDLInterface wi = (WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface();
+ PortType portType = wi.getPortType();
+ Service service = helper.createService(def, portType);
+ if (wsBinding.getBinding() == null && ports.size() == 0) {
+ Binding binding = helper.createBinding(def, portType);
+ if (Axis2ServiceBindingProvider.requiresSOAP12(wsBinding)) {
+ def.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ } else {
+ def.addNamespace("soap11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ helper.createBindingOperations(def, binding, portType);
+ binding.setUndefined(false);
+ def.addBinding(binding);
+
+ String endpointURI = computeEndpointURI(wsBinding, servletHost, null);
+ Port port = helper.createPort(def, binding, service, endpointURI);
+ wsBinding.setService(service);
+ wsBinding.setPort(port);
+ } else {
+ if (ports.size() > 0) {
+ // there are one or more user-specified valid ports
+ for (Port port : ports) {
+ service.addPort(port);
+ }
+ if (ports.size() == 1) {
+ // only one port, so use it
+ wsBinding.setPort(ports.get(0));
+ } else {
+ // multiple ports, make them all available
+ wsBinding.setPort(null);
+ }
+ } else {
+ // no valid user-specified ports, so create a suitably configured port
+ String endpointURI = computeEndpointURI(wsBinding, servletHost, null);
+ Port port = helper.createPort(def, wsBinding.getBinding(), service, endpointURI);
+ if (Axis2ServiceBindingProvider.requiresSOAP12(wsBinding)) {
+ def.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ } else {
+ def.addNamespace("soap11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ wsBinding.setPort(port);
+ }
+ wsBinding.setService(service);
+ }
+
+ // for debugging
+ if (printWSDL) {
+ try {
+ System.out.println("Generated WSDL for " + component.getName() + "/" + contract.getName());
+ WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(def, System.out);
+ } catch (WSDLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return def;
+ }
+
+ private static void importPortType(PortType portType,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ addImport(portType.getQName(), PortType.class, wsdlDef, newDef, imports);
+ }
+
+ private static void importBinding(Binding binding,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ addImport(binding.getQName(), Binding.class, wsdlDef, newDef, imports);
+ importPortType(binding.getPortType(), wsdlDef, newDef, imports);
+ List bindingExtensions = binding.getExtensibilityElements();
+ for (final Object extension : bindingExtensions) {
+ if (extension instanceof SOAPBinding) {
+ newDef.addNamespace("soap11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+ if (extension instanceof SOAP12Binding) {
+ newDef.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ }
+ }
+ }
+
+ private static void addImport(QName name,
+ Class type,
+ WSDLDefinition wsdlDef,
+ Definition newDef,
+ List<WSDLDefinition> imports) {
+ String namespace = name.getNamespaceURI();
+ if (newDef.getImports(namespace) == null) {
+ WSDLDefinition impDef = findDefinition(wsdlDef, name, type);
+ if (impDef != null) {
+ Import imp = newDef.createImport();
+ imp.setNamespaceURI(namespace);
+ imp.setLocationURI(impDef.getURI().toString());
+ imp.setDefinition(impDef.getDefinition());
+ newDef.addNamespace("ns" + imports.size(), namespace);
+ newDef.addImport(imp);
+ imports.add(impDef);
+ } else {
+ throw new RuntimeException("Unable to find " + type.getName() + " " + name);
+ }
+ }
+ }
+
+ private static WSDLDefinition findDefinition(WSDLDefinition wsdlDef, QName name, Class type) {
+ if (wsdlDef == null || name == null) {
+ return wsdlDef;
+ }
+ if (wsdlDef.getURI() != null) { // not a facade
+ Definition def = wsdlDef.getDefinition();
+ Map types = type == PortType.class ? def.getPortTypes() : def.getBindings();
+ if (types.get(name) != null) {
+ return wsdlDef;
+ }
+ }
+ for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) {
+ WSDLDefinition d = findDefinition(impDef, name, type);
+ if (d != null) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ private static Port copyPort(Definition def, Port port, WebServiceBinding wsBinding, ServletHost servletHost) {
+ Port newPort = def.createPort();
+ newPort.setName(port.getName());
+ newPort.setBinding(port.getBinding());
+ List portExtensions = port.getExtensibilityElements();
+ for (final Object extension : portExtensions) {
+ ExtensibilityElement newExt = null;
+ if (extension instanceof SOAPAddress) {
+ def.addNamespace("soap11", "http://schemas.xmlsoap.org/wsdl/soap/");
+ try {
+ newExt = def.getExtensionRegistry().createExtension(
+ Port.class, WSDLDefinitionGenerator.SOAP_ADDRESS);
+ } catch (WSDLException e) {
+ }
+ String uri = computeEndpointURI(wsBinding, servletHost, port);
+ ((SOAPAddress)newExt).setLocationURI(uri);
+ newPort.addExtensibilityElement(newExt);
+ } else if (extension instanceof SOAP12Address) {
+ def.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+ try {
+ newExt = def.getExtensionRegistry().createExtension(
+ Port.class, WSDLDefinitionGenerator.SOAP12_ADDRESS);
+ } catch (WSDLException e) {
+ }
+ String uri = computeEndpointURI(wsBinding, servletHost, port);
+ ((SOAP12Address)newExt).setLocationURI(uri);
+ newPort.addExtensibilityElement(newExt);
+ } else {
+ // we don't support ports with other extensibility elements such as HTTPAddress
+ return null;
+ }
+ }
+ return newPort;
+ }
+
+ private static String computeEndpointURI(WebServiceBinding wsBinding, ServletHost servletHost, Port port) {
+
+ // pull out the binding intents to see what sort of transport is required
+ PolicySet transportJmsPolicySet = AxisPolicyHelper.getPolicySet(wsBinding, TRANSPORT_JMS_QUALIFIED_INTENT);
+ String uri = computeActualURI(wsBinding, port);
+ if (uri == null) {
+ return null;
+ }
+
+ if (transportJmsPolicySet != null){
+ if (!uri.startsWith("jms:/")) {
+ uri = "jms:" + uri;
+ }
+
+ // construct the rest of the URI based on the policy. All the details are put
+ // into the URI here rather than being place directly into the Axis configuration
+ // as the Axis JMS sender relies on parsing the target URI
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ for ( Object policy : transportJmsPolicySet.getPolicies() ) {
+ if ( policy instanceof Axis2ConfigParamPolicy ) {
+ axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
+ Iterator paramIterator = axis2ConfigParamPolicy.getParamElements().get(DEFAULT_QUEUE_CONNECTION_FACTORY).getChildElements();
+
+ if (paramIterator.hasNext()){
+ StringBuffer uriParams = new StringBuffer("?");
+
+ while (paramIterator.hasNext()){
+ OMElement parameter = (OMElement)paramIterator.next();
+ uriParams.append(parameter.getAttributeValue(new QName("","name")));
+ uriParams.append("=");
+ uriParams.append(parameter.getText());
+
+ if (paramIterator.hasNext()){
+ uriParams.append("&");
+ }
+ }
+
+ uri = uri + uriParams;
+ }
+ }
+ }
+ } else {
+ if (!uri.startsWith("jms:")) {
+ uri = servletHost.getURLMapping(uri).toString();
+ }
+ }
+
+ return uri;
+ }
+
+ /**
+ * Compute the endpoint URI based on section 2.1.1 of the WS binding Specification 1.
+ * The URIs in the endpoint(s) of the referenced WSDL, which may be relative
+ * 2. The URI specified by the wsa:Address element of the
+ * wsa:EndpointReference, which may be relative 3. The explicitly stated URI
+ * in the "uri" attribute of the binding.ws element, which may be relative,
+ * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly Specification
+ * If the <binding.ws> has no wsdlElement but does have a uri attribute then
+ * the uri takes precedence over any implicitly used WSDL.
+ *
+ */
+ private static String computeActualURI(WebServiceBinding wsBinding, Port port) {
+
+ org.apache.axis2.addressing.EndpointReference epr = null;
+ URI eprURI = null;
+ if (wsBinding.getEndPointReference() != null) {
+ epr = getEPR(wsBinding);
+ if (epr.getAddress() != null) {
+ eprURI = URI.create(epr.getAddress());
+ }
+ }
+
+ URI wsdlURI = null;
+ if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
+ // <binding.ws> explicitly points at a WSDL port, may be a relative URI
+ wsdlURI = getEndpoint(port);
+ }
+
+ // if the WSDL port/endpoint has an absolute URI use that
+ if (wsdlURI != null && wsdlURI.isAbsolute()) {
+ return wsdlURI.toString();
+ }
+
+ // if the wsa:EndpointReference has an address element with an absolute URI use that
+ if (eprURI != null && eprURI.isAbsolute()) {
+ return eprURI.toString();
+ }
+
+ // either there is no WSDL port endpoint URI or that URI is relative
+ String actualURI = wsBinding.getURI();
+ if (eprURI != null && eprURI.toString().length() != 0) {
+ // there is a relative URI in the binding EPR
+ actualURI = actualURI + "/" + eprURI;
+ }
+
+ if (wsdlURI != null && wsdlURI.toString().length() != 0) {
+ // there is a relative URI in the WSDL port
+ actualURI = actualURI + "/" + wsdlURI;
+ }
+
+ if (actualURI != null) {
+ actualURI = URI.create(actualURI).normalize().toString();
+ }
+
+ return actualURI;
+ }
+
+ private static org.apache.axis2.addressing.EndpointReference getEPR(WebServiceBinding wsBinding) {
+ try {
+
+ XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(
+ new DOMSource(wsBinding.getEndPointReference()));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement omElement = builder.getDocumentElement();
+ org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement);
+ return epr;
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Returns the endpoint of a given port.
+ */
+ private static URI getEndpoint(Port wsdlPort) {
+ if (wsdlPort != null) {
+ List<?> wsdlPortExtensions = wsdlPort.getExtensibilityElements();
+ for (Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ String uri = ((SOAPAddress)extension).getLocationURI();
+ return (uri == null || "".equals(uri)) ? null : URI.create(uri);
+ }
+ if (extension instanceof SOAP12Address) {
+ SOAP12Address address = (SOAP12Address)extension;
+ String uri = address.getLocationURI();
+ return (uri == null || "".equals(uri)) ? null : URI.create(uri);
+ }
+ }
+ }
+ return null;
+ }
+
+}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java Sun Jun 15 17:06:34 2008
@@ -19,6 +19,10 @@
package org.apache.tuscany.sca.binding.ws.axis2.itests;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
import java.util.List;
import javax.wsdl.Definition;
@@ -48,13 +52,21 @@
* Tests ?wsdl works and returns the correct port endpoint from the WSDL
*/
public void testWSDLPortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/services/HelloWorldWebService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose",false);
wsdlReader.setFeature("javax.wsdl.importDocuments",true);
Definition definition = wsdlReader.readWSDL("http://localhost:8085/services/HelloWorldWebService?wsdl");
assertNotNull(definition);
- Service service = definition.getService(new QName("http://helloworld", "HelloWorldService"));
+ Service service = definition.getService(new QName("http://helloworld/HelloWorldService/$promoted$.ep1",
+ "HelloWorldService"));
Port port = service.getPort("HelloWorldSoapPort");
String endpoint = getEndpoint(port);
@@ -66,6 +78,13 @@
* Tests ?wsdl works and returns the correct port endpoint from binding.ws with a custom URI
*/
public void testCustomEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/foo/bar?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose",false);
wsdlReader.setFeature("javax.wsdl.importDocuments",true);
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl Sun Jun 15 17:06:34 2008
@@ -75,6 +75,12 @@
<wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
<wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService"/>
</wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort2">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService2"/>
+ </wsdl:port>
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort3">
+ <wsdlsoap:address location="http://localhost:8085/services/HelloWorldWebService3"/>
+ </wsdl:port>
</wsdl:service>
</wsdl:definitions>
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite Sun Jun 15 17:06:34 2008
@@ -1,36 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
- name="QuestionMarkWSDLTests">
-
- <service name="ep1" promote="HelloWorldService">
- <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
- </service>
-
- <service name="ep2" promote="HelloWorldService">
- <binding.ws uri="http://localhost:8085/foo/bar" />
- </service>
-
- <component name="HelloWorldService">
- <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
- </component>
-
-</composite>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ name="QuestionMarkWSDLTests">
+
+ <service name="ep1" promote="HelloWorldService">
+ <binding.ws wsdlElement="http://helloworld#wsdl.service(HelloWorldService)"/>
+ <!--
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ -->
+ </service>
+
+ <service name="ep2" promote="HelloWorldService">
+ <binding.ws uri="http://localhost:8085/foo/bar" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+</composite>
Modified: incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java Sun Jun 15 17:06:34 2008
@@ -317,6 +317,7 @@
wsdlDefinition.setDefinition(resolved.getDefinition());
wsdlDefinition.setLocation(resolved.getLocation());
wsdlDefinition.setURI(resolved.getURI());
+ wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions());
wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas());
wsdlDefinition.setUnresolved(false);
model.setDefinition(wsdlDefinition);
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java Sun Jun 15 17:06:34 2008
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.binding.ws;
+import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
@@ -196,4 +197,17 @@
Element getEndPointReference();
void setEndPointReference(Element element);
+
+ /**
+ * Returns the generated WSDL definitions document.
+ * @return the generated WSDL definitions document
+ */
+ Definition getWSDLDocument();
+
+ /**
+ * Sets the generated WSDL definitions document.
+ * @param definition the generated WSDL definitions document
+ */
+ void setWSDLDocument(Definition definition);
+
}
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java Sun Jun 15 17:06:34 2008
@@ -23,6 +23,7 @@
import java.util.List;
import javax.wsdl.Binding;
+import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
@@ -56,7 +57,6 @@
private IntentAttachPointType intentAttachPointType;
private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
-
private String location;
private Binding binding;
private Service service;
@@ -70,6 +70,7 @@
private String wsdlNamespace;
private InterfaceContract bindingInterfaceContract;
private Element endPointReference;
+ private Definition generatedWSDLDocument;
protected WebServiceBindingImpl() {
}
@@ -273,7 +274,15 @@
public void setEndPointReference(Element epr) {
this.endPointReference = epr;
}
-
+
+ public Definition getWSDLDocument() {
+ return generatedWSDLDocument;
+ }
+
+ public void setWSDLDocument(Definition definition) {
+ this.generatedWSDLDocument = definition;
+ }
+
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java Sun Jun 15 17:06:34 2008
@@ -499,9 +499,13 @@
part.setName(partName);
if (arg != null && arg.getLogical() instanceof XMLType) {
XMLType xmlType = (XMLType)arg.getLogical();
- part.setElementName(xmlType.getElementName());
+ QName elementName = xmlType.getElementName();
+ part.setElementName(elementName);
+ addNamespace(definition, elementName);
if (xmlType.getElementName() == null) {
- part.setTypeName(xmlType.getTypeName());
+ QName typeName = xmlType.getTypeName();
+ part.setTypeName(typeName);
+ addNamespace(definition, typeName);
}
}
return part;
@@ -523,6 +527,7 @@
input ? opWrapper.getInputChildElements() : opWrapper.getOutputChildElements();
QName wrapperName = elementInfo.getQName();
part.setElementName(wrapperName);
+ addNamespace(definition, wrapperName);
wrappers.put(wrapperName, elements);
// FIXME: [rfeng] Ideally, we should try to register the wrappers only. But we are
@@ -597,6 +602,13 @@
return element;
}
+ private static void addNamespace(Definition definition, QName name) {
+ String namespace = name.getNamespaceURI();
+ if (definition.getPrefix(namespace) == null) {
+ definition.addNamespace("ns" + definition.getNamespaces().size(), namespace);
+ }
+ }
+
/*
// currently not using the next three methods
public XmlSchemaType getXmlSchemaType(DataType type) {
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java Sun Jun 15 17:06:34 2008
@@ -59,13 +59,13 @@
*/
public class WSDLDefinitionGenerator {
private static final String SOAP_NS = "http://schemas.xmlsoap.org/wsdl/soap/";
- private static final QName SOAP_ADDRESS = new QName(SOAP_NS, "address");
+ public static final QName SOAP_ADDRESS = new QName(SOAP_NS, "address");
private static final QName SOAP_BINDING = new QName(SOAP_NS, "binding");
private static final QName SOAP_BODY = new QName(SOAP_NS, "body");
private static final QName SOAP_FAULT = new QName(SOAP_NS, "fault");
private static final QName SOAP_OPERATION = new QName(SOAP_NS, "operation");
private static final String SOAP12_NS = "http://schemas.xmlsoap.org/wsdl/soap12/";
- private static final QName SOAP12_ADDRESS = new QName(SOAP12_NS, "address");
+ public static final QName SOAP12_ADDRESS = new QName(SOAP12_NS, "address");
private static final QName SOAP12_BINDING = new QName(SOAP12_NS, "binding");
private static final QName SOAP12_BODY = new QName(SOAP12_NS, "body");
private static final QName SOAP12_FAULT = new QName(SOAP12_NS, "fault");
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java Sun Jun 15 17:06:34 2008
@@ -205,6 +205,7 @@
wsdlDefinition.setDefinition(resolved.getDefinition());
wsdlDefinition.setLocation(resolved.getLocation());
wsdlDefinition.setURI(resolved.getURI());
+ wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions());
wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas());
wsdlDefinition.setUnresolved(false);
WSDLObject<PortType> portType = wsdlDefinition.getWSDLObject(PortType.class, wsdlInterface.getName());
Modified: incubator/tuscany/java/sca/vtest/wsbinding/nowsdl/soapversion/src/main/resources/nowsdlsoapversion.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/wsbinding/nowsdl/soapversion/src/main/resources/nowsdlsoapversion.composite?rev=668025&r1=668024&r2=668025&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/wsbinding/nowsdl/soapversion/src/main/resources/nowsdlsoapversion.composite (original)
+++ incubator/tuscany/java/sca/vtest/wsbinding/nowsdl/soapversion/src/main/resources/nowsdlsoapversion.composite Sun Jun 15 17:06:34 2008
@@ -26,7 +26,7 @@
<implementation.java class="org.apache.tuscany.sca.vtest.wsbinding.nowsdl.soapversion.impl.BServiceImpl"/>
<service name="BService">
<interface.java interface="org.apache.tuscany.sca.vtest.wsbinding.nowsdl.soapversion.BService"/>
- <binding.ws/>
+ <binding.ws uri="http://localhost:8080/BComponent"/>
</service>
</component>
@@ -58,7 +58,7 @@
<implementation.java class="org.apache.tuscany.sca.vtest.wsbinding.nowsdl.soapversion.impl.CServiceImpl"/>
<service name="CService">
<interface.java interface="org.apache.tuscany.sca.vtest.wsbinding.nowsdl.soapversion.CService"/>
- <binding.ws requires="soap.1_2"/>
+ <binding.ws requires="soap.1_2" uri="http://localhost:8080/CComponent"/>
</service>
</component>