You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ke...@apache.org on 2007/02/05 09:21:19 UTC
svn commit: r503585 [6/9] - in /webservices/axis2/trunk/java: etc/
modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/ modules/adb/
modules/addressing/ modules/addressing/src/o...
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Mon Feb 5 00:21:12 2007
@@ -4,26 +4,53 @@
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.namespace.Constants;
+import org.apache.axis2.transport.http.util.RESTUtil;
+import org.apache.axis2.wsdl.HTTPHeaderMessage;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
+import org.apache.axis2.wsdl.SOAPModuleMessage;
import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.woden.*;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.WSDLSource;
import org.apache.woden.internal.DOMWSDLFactory;
+import org.apache.woden.internal.wsdl20.extensions.InterfaceOperationExtensionsImpl;
+import org.apache.woden.internal.wsdl20.extensions.http.HTTPBindingExtensionsImpl;
+import org.apache.woden.internal.wsdl20.extensions.soap.SOAPBindingExtensionsImpl;
import org.apache.woden.schema.Schema;
-import org.apache.woden.types.NCName;
-import org.apache.woden.wsdl20.*;
-import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.InterfaceFault;
+import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.TypeDefinition;
import org.apache.woden.wsdl20.enumeration.MessageLabel;
-import org.apache.woden.wsdl20.extensions.ExtensionElement;
-import org.apache.woden.wsdl20.extensions.UnknownExtensionElement;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
+import org.apache.woden.wsdl20.extensions.http.HTTPHeader;
+import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions;
import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions;
import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions;
+import org.apache.woden.wsdl20.extensions.soap.SOAPEndpointExtensions;
import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlock;
-import org.apache.woden.wsdl20.xml.*;
-import org.apache.woden.xml.XMLAttr;
+import org.apache.woden.wsdl20.extensions.soap.SOAPModule;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -31,7 +58,11 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -70,6 +101,10 @@
private boolean setupComplete = false;
private Service wsdlService;
+// As bindings are processed add it to this array so that we dont process the same binding twice
+ private Map processedBindings;
+
+
public WSDL20ToAxisServiceBuilder(InputStream in, QName serviceName,
String interfaceName) {
this.in = in;
@@ -162,22 +197,114 @@
// WSDL 2.0 spec requires that even the built-in schema should be returned
// once asked for schema definitions. But for data binding purposes we can ignore that
- if (schemaDefinition != null && !Constants.URI_2001_SCHEMA_XSD.equals(schemaDefinition.getTargetNamespace()))
- {
+ if (schemaDefinition != null && !Constants.URI_2001_SCHEMA_XSD
+ .equals(schemaDefinition.getTargetNamespace())) {
axisService.addSchema(schemaDefinition);
}
}
}
- Binding binding = findBinding(description);
- processBinding(binding);
-
+ processService();
return axisService;
} catch (Exception e) {
throw new AxisFault(e);
}
}
+ private void processEndpoints() throws AxisFault {
+ Endpoint[] endpoints = wsdlService.getEndpoints();
+
+ if (endpoints.length == 0) {
+ throw new AxisFault("No endpoints found in the WSDL");
+ }
+
+ processedBindings = new HashMap();
+ Endpoint endpoint = null;
+
+ if (this.interfaceName != null) {
+ for (int i = 0; i < endpoints.length; ++i) {
+ if (this.interfaceName.equals(endpoints[i].getName().toString())) {
+ endpoint = endpoints[i];
+ break; // found it. Stop looking
+ }
+ }
+ if (endpoint == null) {
+ throw new AxisFault("No endpoint found for the given name :"
+ + this.interfaceName);
+ }
+
+ axisService
+ .addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint));
+ } else {
+ for (int i = 0; i < endpoints.length; i++) {
+ axisService
+ .addEndpoint(endpoints[i].getName().toString(),
+ processEndpoint(endpoints[i]));
+ }
+ }
+
+ if (endpoint == null && endpoints.length > 0) {
+ endpoint = endpoints[0];
+ }
+
+ axisService.setEndpointName(endpoint.getName().toString());
+ axisService.setBindingName(endpoint.getBinding().getName().getLocalPart());
+ axisService.setEndpointURL(endpoint.getAddress().toString());
+
+ }
+
+ private void processService() throws AxisFault {
+ Service[] services = description.getServices();
+ if (services.length == 0) {
+ throw new AxisFault("No wsdlService found in the WSDL");
+ }
+
+ if (serviceName != null) {
+ for (int i = 0; i < services.length; i++) {
+ if (serviceName.equals(services[i].getName())) {
+ wsdlService = services[i];
+ break; // found it. Stop looking.
+ }
+ }
+ if (wsdlService == null) {
+ throw new AxisFault("Service with the specified name not found in the WSDL : "
+ + serviceName.getLocalPart());
+ }
+ }
+
+ wsdlService = services[0];
+ axisService.setName(wsdlService.getName().getLocalPart().toString());
+ processInterface(wsdlService.getInterface());
+
+ processEndpoints();
+
+ }
+
+ private AxisEndpoint processEndpoint(Endpoint endpoint) throws AxisFault {
+ AxisEndpoint axisEndpoint = new AxisEndpoint();
+ axisEndpoint.setName(endpoint.getName().toString());
+ if (processedBindings.containsKey(endpoint.getBinding().getName())) {
+ axisEndpoint.setBinding(
+ (AxisBinding) processedBindings.get(endpoint.getBinding().getName()));
+ } else {
+ axisEndpoint.setBinding(processBinding(endpoint.getBinding()));
+ }
+
+ SOAPEndpointExtensions soapEndpointExtensions = null;
+ try {
+ soapEndpointExtensions = (SOAPEndpointExtensions) endpoint
+ .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("HTTP Binding Extention not found");
+ }
+
+ axisEndpoint.setProperty(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE,soapEndpointExtensions.getHttpAuthenticationScheme());
+ axisEndpoint.setProperty(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_REALM,soapEndpointExtensions.getHttpAuthenticationRealm());
+
+ return axisEndpoint;
+
+ }
+
/**
* contains all code which gathers non-wsdlService specific information from the
* wsdl.
@@ -213,7 +340,7 @@
WSDLReader reader = DOMWSDLFactory.newInstance().newWSDLReader();
WSDLSource wsdlSource = reader.createWSDLSource();
wsdlSource.setSource(document.getDocumentElement());
- // wsdlSource.setBaseURI(new URI(getBaseUri()));
+ wsdlSource.setBaseURI(new URI(getBaseUri()));
description = reader.readWSDL(wsdlSource);
descriptionElement = description.toElement();
} else {
@@ -242,105 +369,393 @@
}
}
- private void processBinding(Binding binding)
- throws Exception {
- if (binding != null) {
+ private AxisBinding processBinding(Binding binding)
+ throws AxisFault {
+ AxisBinding axisBinding = new AxisBinding();
+ axisBinding.setType(binding.getType().toString());
+ axisBinding.setName(binding.getName());
+ String bindingType = binding.getType().toString();
+
+ if (bindingType.equals(WSDL2Constants.URI_WSDL2_SOAP)) {
+ processSOAPBindingExtention(binding, axisBinding);
+ } else if (bindingType.equals(WSDL2Constants.URI_WSDL2_HTTP)) {
+ processHTTPBindingExtention(binding, axisBinding);
+ }
+
+ // We should process the interface based on the service not on a binding
+
+ processedBindings.put(binding.getName(), axisBinding);
+ return axisBinding;
+ }
+
+ private void processSOAPBindingExtention(Binding binding, AxisBinding axisBinding)
+ throws AxisFault {
- Interface serviceInterface;
+ // Capture all the binding specific properties
- if (wsdlService != null) {
- serviceInterface = wsdlService.getInterface();
+ Map httpLocationTable = new TreeMap();
+ SOAPBindingExtensionsImpl soapBindingExtensions = null;
+ try {
+ soapBindingExtensions = (SOAPBindingExtensionsImpl) binding
+ .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("Soap Binding Extention not found");
+ }
+
+ String soapVersion;
+ if ((soapVersion = soapBindingExtensions.getSoapVersion()) != null)
+
+ if (soapVersion.equals(WSDL2Constants.SOAP_VERSION_1_1)) {
+ // Might have to remove this as its a binding specific property
+ axisService.setSoapNsUri(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+ WSDL2Constants.SOAP_VERSION_1_1);
} else {
- // we don't need this as wsdlService can not be null. But keeping for early stages
- serviceInterface = binding.getInterface();
+ // Might have to remove this as its a binding specific property
+ axisService.setSoapNsUri(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+ WSDL2Constants.SOAP_VERSION_1_2);
}
- determineSOAPVersion(binding);
+ URI soapUnderlyingProtocol = soapBindingExtensions.getSoapUnderlyingProtocol();
+ if (soapUnderlyingProtocol != null) {
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL,
+ soapUnderlyingProtocol.toString());
+ }
+ URI soapMepDefault = soapBindingExtensions.getSoapMepDefault();
+ if (soapMepDefault != null) {
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
+ soapMepDefault.toString());
+ }
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ soapBindingExtensions.getHttpTransferCodingDefault());
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
+ createSoapModules(soapBindingExtensions.getSoapModules()));
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
+ soapBindingExtensions.getHttpQueryParameterSeparatorDefault());
- processInterface(serviceInterface);
+ // Capture all the fault specific properties
- BindingOperation[] bindingOperations = binding.getBindingOperations();
- for (int i = 0; i < bindingOperations.length; i++) {
- BindingOperation bindingOperation = bindingOperations[i];
+ BindingFault[] bindingFaults = binding.getBindingFaults();
+ for (int i = 0; i < bindingFaults.length; i++) {
+ BindingFault bindingFault = bindingFaults[i];
+ InterfaceFault interfaceFault = bindingFault.getInterfaceFault();
- AxisOperation operation = axisService.getOperation(bindingOperation.getInterfaceOperation().getName());
+ AxisBindingMessage axisBindingFault = new AxisBindingMessage();
+ axisBindingFault.setName(interfaceFault.getName().getLocalPart());
+ axisBindingFault.setParent(axisBinding);
- BindingMessageReference[] bindingMessageReferences = bindingOperation.getBindingMessageReferences();
- for (int j = 0; j < bindingMessageReferences.length; j++) {
- BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
+ SOAPBindingFaultExtensions soapBindingFaultExtensions = null;
- NCName messageLabel = bindingMessageReference.getInterfaceMessageReference().getMessageLabel();
- AxisMessage message = operation.getMessage(messageLabel.toString());
+ try {
+ soapBindingFaultExtensions = (SOAPBindingFaultExtensions) bindingFault
+ .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("Soap Binding Extention not found");
+ }
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER,
+ createHttpHeaders(soapBindingFaultExtensions.getHttpHeaders()));
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ soapBindingFaultExtensions.getHttpTransferCoding());
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_CODE,
+ soapBindingFaultExtensions.getSoapFaultCode());
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_SUBCODES,
+ soapBindingFaultExtensions.getSoapFaultSubcodes());
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER,
+ createSoapHeaders(soapBindingFaultExtensions.getSoapHeaders()));
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
+ createSoapModules(soapBindingFaultExtensions.getSoapModules()));
- SOAPBindingMessageReferenceExtensions soapHeaderExt = (SOAPBindingMessageReferenceExtensions) bindingMessageReference.getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ axisBinding.addFault(axisBindingFault);
- if (soapHeaderExt != null) {
- SOAPHeaderBlock[] soapHeaders = soapHeaderExt.getSoapHeaders();
+ }
- for (int k = 0; k < soapHeaders.length; k++) {
- SOAPHeaderBlock soapHeader = soapHeaders[j];
+ // Capture all the binding operation specific properties
- ElementDeclaration elementDeclaration = soapHeader.getElementDeclaration();
+ BindingOperation[] bindingOperations = binding.getBindingOperations();
+ for (int i = 0; i < bindingOperations.length; i++) {
+ BindingOperation bindingOperation = bindingOperations[i];
+
+ AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+ AxisOperation axisOperation =
+ axisService.getOperation(bindingOperation.getInterfaceOperation().getName());
+
+ axisBindingOperation.setAxisOperation(axisOperation);
+ axisBindingOperation.setParent(axisBinding);
+ axisBindingOperation.setName(axisOperation.getName());
+
+ SOAPBindingOperationExtensions soapBindingOperationExtensions = null;
+ try {
+ soapBindingOperationExtensions = ((SOAPBindingOperationExtensions)
+ bindingOperation.getComponentExtensionsForNamespace(
+ new URI(WSDL2Constants.URI_WSDL2_SOAP)));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("Soap Binding Extention not found");
+ }
+
+ URI soapAction = soapBindingOperationExtensions.getSoapAction();
+ if (soapAction != null) {
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION,
+ soapAction.toString());
+ }
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
+ createSoapModules(soapBindingOperationExtensions.getSoapModules()));
+ URI soapMep = soapBindingOperationExtensions.getSoapMep();
+ if (soapMep != null) {
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
+ soapMep.toString());
+ }
+ HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
+ // If httpLocation is not null we should extract a constant part from it and add its value and the
+ // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
+ // the operation name into this map.
+ String httpLocationString = "";
+ if (httpLocation != null) {
+ String httpLocationTemplete = httpLocation.getLocationTemplate();
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
+ httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);
+
+ }
+
+ httpLocationTable.put(httpLocationString, axisOperation);
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ soapBindingOperationExtensions.getHttpTransferCodingDefault());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
+ soapBindingOperationExtensions.getHttpQueryParameterSeparator());
+
+
+ BindingMessageReference[] bindingMessageReferences =
+ bindingOperation.getBindingMessageReferences();
+ for (int j = 0; j < bindingMessageReferences.length; j++) {
+ BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
+
+ AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
+ axisBindingMessage.setParent(axisBindingOperation);
+
+ AxisMessage axisMessage = axisOperation.getMessage(bindingMessageReference
+ .getInterfaceMessageReference().getMessageLabel().toString());
+
+ axisBindingMessage.setAxisMessage(axisMessage);
+ axisBindingMessage.setName(axisMessage.getName());
+ axisBindingMessage.setDirection(axisMessage.getDirection());
- if (elementDeclaration != null) {
- QName name = elementDeclaration.getName();
- SOAPHeaderMessage soapHeaderMessage = new SOAPHeaderMessage(name);
- soapHeaderMessage.setRequired(soapHeader.isRequired().booleanValue());
- message.addSoapHeader(soapHeaderMessage);
- }
- }
- }
+ SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions = null;
+ try {
+ soapBindingMessageReferenceExtensions =
+ (SOAPBindingMessageReferenceExtensions) bindingMessageReference
+ .getComponentExtensionsForNamespace(
+ new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("Soap Binding Extention not found");
}
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER,
+ createHttpHeaders(soapBindingMessageReferenceExtensions.getHttpHeaders()));
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ soapBindingMessageReferenceExtensions.getHttpTransferCoding());
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER,
+ createSoapHeaders(soapBindingMessageReferenceExtensions.getSoapHeaders()));
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
+ createSoapModules(soapBindingMessageReferenceExtensions.getSoapModules()));
- SOAPBindingOperationExtensions soapBindingExtension = ((SOAPBindingOperationExtensions)
- bindingOperation.getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP)));
- String soapAction = soapBindingExtension.getSoapAction().toString();
+ axisBindingOperation.addChild(axisMessage.getDirection(), axisBindingMessage);
- operation.setSoapAction(soapAction == null ? "" : soapAction);
}
- }
- }
- /**
- * This method has a flaw in it which needs to be fixed.
- * IIUC, the protocol URI should match with the soap version attribute. But I need to confirm this.
- * Basically the question is wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP and
- * version wsoap:version="1.1" are valid combinations or not. (Refer page 37 and 38 of WSDL primer)
- * <p/>
- * UntiL I fixed it, just checking the version attribute.
- *
- * @param binding
- * @throws URISyntaxException
- */
- private void determineSOAPVersion(Binding binding) throws URISyntaxException {
- BindingElement bindingElement = binding.toElement();
+ BindingFaultReference [] bindingFaultReferences =
+ bindingOperation.getBindingFaultReferences();
+ for (int j = 0; j < bindingFaultReferences.length; j++) {
+ BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
- boolean soapNSFound = false;
- XMLAttr[] wsoapAttributes = bindingElement.getExtensionAttributesForNamespace(new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
+ axisBindingMessageFault.setParent(axisBindingOperation);
+ axisBindingMessageFault.setName(bindingFaultReference.getInterfaceFaultReference()
+ .getInterfaceFault().getName().getLocalPart());
- for (int i = 0; i < wsoapAttributes.length; i++) {
- XMLAttr wsoapAttribute = wsoapAttributes[i];
- if (wsoapAttribute.getAttributeType().getLocalPart().equals(WSDL2Constants.ATTR_VERSION))
- {
- String soapVersion = wsoapAttribute.toExternalForm();
- if ("1.1".equals(soapVersion)) {
- axisService.setSoapNsUri(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
- soapNSFound = true;
+ SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions = null;
+ try {
+ soapBindingFaultReferenceExtensions =
+ (SOAPBindingFaultReferenceExtensions) bindingFaultReference
+ .getComponentExtensionsForNamespace(
+ new URI(WSDL2Constants.URI_WSDL2_SOAP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("Soap Binding Extention not found");
}
+
+ axisBindingMessageFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
+ createSoapModules(soapBindingFaultReferenceExtensions.getSoapModules()));
+
+ axisBindingOperation.addFault(axisBindingMessageFault);
+
}
+ axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE,httpLocationTable);
+ axisBinding.addChild(axisBindingOperation.getName(), axisBindingOperation);
+
+
}
+ }
+
+ private void processHTTPBindingExtention(Binding binding, AxisBinding axisBinding)
+ throws AxisFault {
+
+
+ Map httpLocationTable = new TreeMap();
+ // Capture all the binding specific properties
+
+ HTTPBindingExtensionsImpl httpBindingExtensions = null;
+ try {
+ httpBindingExtensions = (HTTPBindingExtensionsImpl) binding
+ .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_HTTP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("HTTP Binding Extention not found");
+ }
+
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpBindingExtensions.getHttpMethodDefault());
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, httpBindingExtensions.getHttpQueryParameterSeparatorDefault());
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING, httpBindingExtensions.getHttpTransferCodingDefault());
+
+ // Capture all the fault specific properties
+
+ BindingFault[] bindingFaults = binding.getBindingFaults();
+ for (int i = 0; i < bindingFaults.length; i++) {
+ BindingFault bindingFault = bindingFaults[i];
+ InterfaceFault interfaceFault = bindingFault.getInterfaceFault();
+
+ AxisBindingMessage axisBindingFault = new AxisBindingMessage();
+ axisBindingFault.setName(interfaceFault.getName().getLocalPart());
+ axisBindingFault.setParent(axisBinding);
+
+ HTTPBindingFaultExtensions httpBindingFaultExtensions = null;
+
+ try {
+ httpBindingFaultExtensions = (HTTPBindingFaultExtensions) bindingFault
+ .getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_HTTP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("HTTP Binding Extention not found");
+ }
+
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_CODE,
+ httpBindingFaultExtensions.getHttpErrorStatusCode().getCode());
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER,
+ createHttpHeaders(httpBindingFaultExtensions.getHttpHeaders()));
+ axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ httpBindingFaultExtensions.getHttpTransferCoding());
+
+ axisBinding.addFault(axisBindingFault);
- if (!soapNSFound) {
- axisService.setSoapNsUri(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
}
+ // Capture all the binding operation specific properties
+
+ BindingOperation[] bindingOperations = binding.getBindingOperations();
+ for (int i = 0; i < bindingOperations.length; i++) {
+ BindingOperation bindingOperation = bindingOperations[i];
+
+ AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+ AxisOperation axisOperation =
+ axisService.getOperation(bindingOperation.getInterfaceOperation().getName());
+
+ axisBindingOperation.setAxisOperation(axisOperation);
+ axisBindingOperation.setParent(axisBinding);
+ axisBindingOperation.setName(axisOperation.getName());
+
+ HTTPBindingOperationExtensions httpBindingOperationExtensions = null;
+ try {
+ httpBindingOperationExtensions = ((HTTPBindingOperationExtensions)
+ bindingOperation.getComponentExtensionsForNamespace(
+ new URI(WSDL2Constants.URI_WSDL2_HTTP)));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("HTTP Binding Extention not found");
+ }
+
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_FAULT_SERIALIZATION,
+ httpBindingOperationExtensions.getHttpFaultSerialization());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
+ httpBindingOperationExtensions.getHttpInputSerialization());
+ HTTPLocation httpLocation = httpBindingOperationExtensions.getHttpLocation();
+
+ // If httpLocation is not null we should extract a constant part from it and add its value and the
+ // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
+ // the operation name into this map.
+ String httpLocationString = "";
+ if (httpLocation != null) {
+ String httpLocationTemplete = httpLocation.getLocationTemplate();
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
+ httpLocationString = RESTUtil.getConstantFromHTTPLocation(httpLocationTemplete);
+
+ }
+
+ httpLocationTable.put(httpLocationString, axisOperation);
+
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED, httpBindingOperationExtensions.
+ isHttpLocationIgnoreUncited());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpBindingOperationExtensions.
+ getHttpMethod());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_OUTPUT_SERIALIZATION,
+ httpBindingOperationExtensions.getHttpOutputSerialization());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
+ httpBindingOperationExtensions.getHttpQueryParameterSeparator());
+ axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ httpBindingOperationExtensions.getHttpTransferCodingDefault());
+
+ BindingMessageReference[] bindingMessageReferences =
+ bindingOperation.getBindingMessageReferences();
+ for (int j = 0; j < bindingMessageReferences.length; j++) {
+ BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
+
+ AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
+ axisBindingMessage.setParent(axisBindingOperation);
+
+ AxisMessage axisMessage = axisOperation.getMessage(bindingMessageReference
+ .getInterfaceMessageReference().getMessageLabel().toString());
+
+ axisBindingMessage.setAxisMessage(axisMessage);
+ axisBindingMessage.setName(axisMessage.getName());
+ axisBindingMessage.setDirection(axisMessage.getDirection());
+
+
+ HTTPBindingMessageReferenceExtensions httpBindingMessageReferenceExtensions = null;
+ try {
+ httpBindingMessageReferenceExtensions =
+ (HTTPBindingMessageReferenceExtensions) bindingMessageReference
+ .getComponentExtensionsForNamespace(
+ new URI(WSDL2Constants.URI_WSDL2_HTTP));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("HTTP Binding Extention not found");
+ }
+
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER,
+ createHttpHeaders(httpBindingMessageReferenceExtensions.getHttpHeaders()));
+ axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_TRANSFER_CODING,
+ httpBindingMessageReferenceExtensions.getHttpTransferCoding());
+
+ axisBindingOperation.addChild(axisMessage.getDirection(), axisBindingMessage);
+
+ }
+
+ BindingFaultReference[] bindingFaultReferences =
+ bindingOperation.getBindingFaultReferences();
+ for (int j = 0; j < bindingFaultReferences.length; j++) {
+ BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
+
+ AxisBindingMessage axisBindingMessageFault =
+ axisBinding.getFault(bindingFaultReference.getInterfaceFaultReference()
+ .getInterfaceFault().getName().getLocalPart());
+
+ axisBindingOperation.addFault(axisBindingMessageFault);
+
+ }
+
+ axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
+ axisBinding.addChild(axisBindingOperation.getName(), axisBindingOperation);
+
+ }
}
private void processInterface(Interface serviceInterface)
- throws Exception {
+ throws AxisFault {
// TODO @author Chathura copy the policy elements
// copyExtensionAttributes(wsdl4jPortType.getExtensionAttributes(),
@@ -349,8 +764,7 @@
InterfaceOperation[] interfaceOperations = serviceInterface
.getInterfaceOperations();
for (int i = 0; i < interfaceOperations.length; i++) {
- axisService.addOperation(populateOperations(interfaceOperations[i],
- description));
+ axisService.addOperation(populateOperations(interfaceOperations[i]));
}
Interface[] extendedInterfaces = serviceInterface.getExtendedInterfaces();
@@ -361,8 +775,7 @@
}
- private AxisOperation populateOperations(InterfaceOperation operation,
- Description description) throws Exception {
+ private AxisOperation populateOperations(InterfaceOperation operation) throws AxisFault {
QName opName = operation.getName();
// Copy Name Attribute
AxisOperation axisOperation = axisService.getOperation(opName);
@@ -375,8 +788,24 @@
}
// assuming the style of the operations of WSDL 2.0 is always document, for the time being :)
+ axisOperation.setMessageExchangePattern(operation.getMessageExchangePattern().toString());
axisOperation.setStyle("document");
+// The following can be used to capture the wsdlx:safe attribute
+
+ InterfaceOperationExtensionsImpl interfaceOperationExtensions;
+ try {
+ interfaceOperationExtensions = (InterfaceOperationExtensionsImpl)operation.getComponentExtensionsForNamespace(new URI(WSDL2Constants.URI_WSDL2_EXTENSIONS));
+ } catch (URISyntaxException e) {
+ throw new AxisFault("WSDL2 extensions not defined for this operation");
+ }
+
+ if (interfaceOperationExtensions != null) {
+ Parameter parameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, new Boolean(interfaceOperationExtensions.isSafety()));
+ axisOperation.addParameter(parameter);
+ }
+
+
InterfaceMessageReference[] interfaceMessageReferences = operation
.getInterfaceMessageReferences();
for (int i = 0; i < interfaceMessageReferences.length; i++) {
@@ -386,16 +815,20 @@
// Its an input message
if (isServerSide) {
- createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ createAxisMessage(axisOperation, messageReference,
+ WSDLConstants.MESSAGE_LABEL_IN_VALUE);
} else {
- createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ createAxisMessage(axisOperation, messageReference,
+ WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
} else if (messageReference.getMessageLabel().equals(
MessageLabel.OUT)) {
if (isServerSide) {
- createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ createAxisMessage(axisOperation, messageReference,
+ WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
} else {
- createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ createAxisMessage(axisOperation, messageReference,
+ WSDLConstants.MESSAGE_LABEL_IN_VALUE);
}
}
@@ -422,7 +855,9 @@
return axisOperation;
}
- private void createAxisMessage(AxisOperation axisOperation, InterfaceMessageReference messageReference, String messageLabel) throws Exception {
+ private void createAxisMessage(AxisOperation axisOperation,
+ InterfaceMessageReference messageReference, String messageLabel)
+ throws AxisFault {
AxisMessage message = axisOperation
.getMessage(messageLabel);
@@ -432,14 +867,13 @@
if (WSDLConstants.WSDL20_2006Constants.NMTOKEN_ELEMENT.equals(messageContentModelName)) {
elementQName = messageReference.getElementDeclaration().getName();
} else if (WSDLConstants.WSDL20_2006Constants.NMTOKEN_ANY.equals(messageContentModelName)) {
- // TODO : Need to improve this
-// elementQName = SchemaConstants.XSD_ANY;
+ elementQName = Constants.XSD_ANY;
} else
if (WSDLConstants.WSDL20_2006Constants.NMTOKEN_NONE.equals(messageContentModelName)) {
- // TODO : Need to improve this
-// elementQName = new QName("None");
+ // nothing to do here keep the message element as null
} else {
- throw new Exception("Sorry we do not support " + messageContentModelName + ". We do only support #any, #none and #element as message content models.");
+ throw new AxisFault("Sorry we do not support " + messageContentModelName +
+ ". We do only support #any, #none and #element as message content models.");
}
message.setElementQName(elementQName);
@@ -448,566 +882,88 @@
// populate this map so that this can be used in SOAPBody based dispatching
if (elementQName != null) {
- axisService.addmessageNameToOperationMapping(elementQName.getLocalPart(), axisOperation);
+ axisService
+ .addmessageNameToOperationMapping(elementQName.getLocalPart(), axisOperation);
}
}
- /**
- * CAUTION : Do not call this method. This is just for reference and will be deleted, ASAP.
- *
- * @param extensionElement
- * @param descriptionElement
- * @param description
- * @param originOfExtensibilityElements
- */
- private void copyExtensibleElements(ExtensionElement[] extensionElement,
- DescriptionElement descriptionElement, AxisDescription description,
- String originOfExtensibilityElements) {
- for (int i = 0; i < extensionElement.length; i++) {
- ExtensionElement element = extensionElement[i];
-
- if (element instanceof UnknownExtensionElement) {
- UnknownExtensionElement unknown = (UnknownExtensionElement) element;
-
- // look for the SOAP 1.2 stuff here. WSDL4j does not understand
- // SOAP 1.2 things
- // TODO this is wrong. Compare this with WSDL 2.0 QName
- if (WSDLConstants.WSDL11Constants.SOAP_12_OPERATION.equals(unknown
- .getExtensionType())) {
- XMLElement unknownElement = unknown.getElement();
- if (description instanceof AxisOperation) {
- AxisOperation axisOperation = (AxisOperation) description;
- String style = unknownElement.getAttributeValue("style");
- if (style != null) {
- axisOperation.setStyle(style);
- }
- axisOperation.setSoapAction(unknownElement
- .getAttributeValue("soapAction"));
- if(axisOperation.getInputAction() != null){
- axisService.mapActionToOperation(axisOperation.getInputAction(), axisOperation);
- }
- }
- } else if (WSDLConstants.WSDL11Constants.SOAP_12_HEADER.equals(unknown
- .getExtensionType())) {
- // TODO : implement thid
- } else if (WSDLConstants.WSDL11Constants.SOAP_12_BINDING.equals(unknown
- .getExtensionType())) {
- style = unknown.getElement().getAttributeValue("style");
- axisService.setSoapNsUri(element.getExtensionType()
- .getNamespaceURI());
- } else if (WSDLConstants.WSDL11Constants.SOAP_12_ADDRESS.equals(unknown
- .getExtensionType())) {
- axisService.setEndpoint(unknown.getElement().getAttributeValue(
- "location"));
-
- }
+ private Description readInTheWSDLFile(String wsdlURI)
+ throws WSDLException {
- // } else if (element instanceof SOAPAddress) {
- // SOAPAddress soapAddress = (SOAPAddress) wsdl4jElement;
- // axisService.setEndpoint(soapAddress.getLocationURI());
- // } else if (wsdl4jElement instanceof Schema) {
- // Schema schema = (Schema) wsdl4jElement;
- // //just add this schema - no need to worry about the imported
- // ones
- // axisService.addSchema(getXMLSchema(schema.getElement(),
- // wsdl4jDefinition.getDocumentBaseURI()));
- // } else if
- // (SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(wsdl4jElement
- // .getElementType())) {
- // SOAPOperation soapOperation = (SOAPOperation) wsdl4jElement;
- // if (description instanceof AxisOperation) {
- // AxisOperation axisOperation = (AxisOperation) description;
- // if (soapOperation.getStyle() != null) {
- // axisOperation.setStyle(soapOperation.getStyle());
- // }
- // axisOperation.setSoapAction(soapOperation
- // .getSoapActionURI());
- // }
- // } else if
- // (SOAPConstants.Q_ELEM_SOAP_HEADER.equals(wsdl4jElement
- // .getElementType())) {
- // SOAPHeader soapHeader = (SOAPHeader) wsdl4jElement;
- // SOAPHeaderMessage headerMessage = new SOAPHeaderMessage();
- // headerMessage.setNamespaceURI(soapHeader.getNamespaceURI());
- // headerMessage.setUse(soapHeader.getUse());
- // Boolean required = soapHeader.getRequired();
- // if (null != required) {
- // headerMessage.setRequired(required.booleanValue());
- // }
- // if (null != wsdl4jDefinition) {
- // //find the relevant schema part from the messages
- // Message msg = wsdl4jDefinition.getMessage(soapHeader
- // .getMessage());
- // Part msgPart = msg.getPart(soapHeader.getPart());
- // headerMessage.setElement(msgPart.getElementName());
- // }
- // headerMessage.setMessage(soapHeader.getMessage());
- //
- // headerMessage.setPart(soapHeader.getPart());
- // if (description instanceof AxisMessage) {
- // ((AxisMessage) description).addSoapHeader(headerMessage);
- // }
- // } else if
- // (SOAPConstants.Q_ELEM_SOAP_BINDING.equals(wsdl4jElement
- // .getElementType())) {
- // SOAPBinding soapBinding = (SOAPBinding) wsdl4jElement;
- // style = soapBinding.getStyle();
- // axisService.setSoapNsUri(soapBinding.getElementType()
- // .getNamespaceURI());
- // }
- }
- }
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ return reader.readWSDL(wsdlURI);
}
- private Binding findBinding(Description discription) throws AxisFault {
- Service[] services = discription.getServices();
- wsdlService = null;
- Endpoint endpoint = null;
- Binding binding = null;
-
- if (services.length == 0) {
- throw new AxisFault("No wsdlService found in the WSDL");
- }
-
- if (serviceName != null) {
- for (int i = 0; i < services.length; i++) {
- if (serviceName.equals(services[i].getName())) {
- wsdlService = services[i];
- break; // found it. Stop looking.
- }
- }
- if (wsdlService == null) {
- throw new AxisFault("Service not found the WSDL "
- + serviceName.getLocalPart());
- }
- } else {
- // If no particular wsdlService is mentioned select the first one.
- wsdlService = services[0];
- }
- Endpoint[] endpoints = wsdlService.getEndpoints();
- if (this.interfaceName != null) {
+ /**
+ * Convert woden dependent SOAPHeaderBlock objects to SOAPHeaderMessage objects
+ * @param soapHeaderBlocks - An array of SOAPHeaderBlock objects
+ * @return ArrayList - An ArrayList of SOAPHeaderMessage objects
+ */
+ private ArrayList createSoapHeaders(SOAPHeaderBlock soapHeaderBlocks[]) {
- if (endpoints.length == 0) {
- throw new AxisFault("No Endpoints/Ports found in the wsdlService:"
- + wsdlService.getName().getLocalPart());
- }
+ if (soapHeaderBlocks.length ==0)
+ return null;
+ ArrayList soapHeaderMessages = new ArrayList();
- for (int i = 0; i < endpoints.length; ++i) {
- if (this.interfaceName.equals(endpoints[i].getName().toString())) {
- endpoint = endpoints[i];
- break; // found it. Stop looking
- }
- }
- if (endpoint == null) {
- throw new AxisFault("No port found for the given name :"
- + this.interfaceName);
+ for (int i = 0; i < soapHeaderBlocks.length; i++) {
+ SOAPHeaderBlock soapHeaderBlock = soapHeaderBlocks[i];
+ ElementDeclaration elementDeclaration = soapHeaderBlock.getElementDeclaration();
+
+ if (elementDeclaration != null) {
+ QName name = elementDeclaration.getName();
+ SOAPHeaderMessage soapHeaderMessage = new SOAPHeaderMessage();
+ soapHeaderMessage.setElement(name);
+ soapHeaderMessage.setRequired(soapHeaderBlock.isRequired().booleanValue());
+ soapHeaderMessage.setMustUnderstand(soapHeaderBlock.mustUnderstand());
+ soapHeaderMessages.add(soapHeaderMessage);
}
- } else {
- // if no particular endpoint is specified use the first one.
- endpoint = endpoints[0];
-
- }
- axisService.setName(wsdlService.getName().getLocalPart());
- if (endpoint != null) {
- axisService.setEndpoint(endpoint.getAddress().toString());
- binding = endpoint.getBinding();
}
- return binding;
+ return soapHeaderMessages;
}
- private Element[] generateWrapperSchema(
- DescriptionElement wodenDescription, BindingElement binding) {
-
- List schemaElementList = new ArrayList();
- String targetNamespaceUri = wodenDescription.getTargetNamespace()
- .toString();
-
- // ///////////////////////////////////////////////////////////////////////////////////////////
- // if there are any bindings present then we have to process them. we
- // have to generate a schema
- // per binding (that is the safest option). if not we just resolve to
- // the good old port type
- // list, in which case we'll generate a schema per porttype
- // //////////////////////////////////////////////////////////////////////////////////////////
-
- // FIXME @author Chathura Once this method is done we could run the
- // basic codgen
- schemaElementList.add(createSchemaForInterface(binding
- .getInterfaceElement(), targetNamespaceUri,
- findWrapForceable(binding)));
- return (Element[]) schemaElementList
- .toArray(new Element[schemaElementList.size()]);
- }
-
- private Element createSchemaForInterface(InterfaceElement interfaceElement,
- String targetNamespaceUri, boolean forceWrapping) {
-
- // loop through the messages. We'll populate things map with the
- // relevant
- // messages
- // from the operations
-
- // this will have name (QName) as the key and
- // InterfaceMessageReferenceElement as the value
- Map messagesMap = new HashMap();
-
- // this will have operation name (a QName) as the key and
- // InterfaceMessageReferenceElement as the value
- Map inputOperationsMap = new HashMap();
-
- // this will have operation name (a QName) as the key and
- // InterfaceMessageReferenceElement as the value
- Map outputOperationsMap = new HashMap();
-
- Map faultyOperationsMap = new HashMap();
- // this contains the required namespace imports. the key in this
- // map would be the namaspace URI
- Map namespaceImportsMap = new HashMap();
- // generated complextypes. Keep in the list for writing later
- // the key for the complexType map is the message QName
- Map complexTypeElementsMap = new HashMap();
- // generated Elements. Kep in the list for later writing
- List elementElementsList = new ArrayList();
- // list namespace prefix map. This map will include uri -> prefix
- Map namespacePrefixMap = new HashMap();
-
- // //////////////////////////////////////////////////////////////////////////////////////////////////
- // First thing is to populate the message map with the messages to
- // process.
- // //////////////////////////////////////////////////////////////////////////////////////////////////
-
- // we really need to do this for a single porttype!
- InterfaceOperationElement[] operationElements = interfaceElement
- .getInterfaceOperationElements();
- InterfaceOperationElement opElement;
- for (int k = 0; k < operationElements.length; k++) {
- opElement = operationElements[k];
- InterfaceMessageReferenceElement[] interfaceMessageReferenceElements = opElement
- .getInterfaceMessageReferenceElements();
-
- for (int i = 0; i < interfaceMessageReferenceElements.length; i++) {
- InterfaceMessageReferenceElement interfaceMessageReferenceElement = interfaceMessageReferenceElements[i];
- String direction = interfaceMessageReferenceElement
- .getDirection().toString();
- messagesMap.put(interfaceMessageReferenceElement
- .getElementName(), interfaceMessageReferenceElement);
- if (Direction.IN.toString().equalsIgnoreCase(direction)) {
- inputOperationsMap.put(opElement.getName(),
- interfaceMessageReferenceElement);
- } else if (Direction.OUT.toString().equalsIgnoreCase(direction)) {
- outputOperationsMap.put(opElement.getName(),
- interfaceMessageReferenceElement);
- }
- }
-
- InterfaceFaultReferenceElement[] interfaceFaultReferenceElements = opElement
- .getInterfaceFaultReferenceElements();
-
- for (int i = 0; i < interfaceFaultReferenceElements.length; i++) {
- InterfaceFaultReferenceElement interfaceFaultReferenceElement = interfaceFaultReferenceElements[i];
- String direction = interfaceFaultReferenceElement
- .getDirection().toString();
- messagesMap.put(interfaceFaultReferenceElement.getRef(),
- interfaceFaultReferenceElement);
- faultyOperationsMap.put(interfaceFaultReferenceElement
- .getInterfaceFaultElement(),
- interfaceFaultReferenceElement);
- }
-
- }
+ /**
+ * Convert woden dependent SOAPHeaderBlock objects to SOAPHeaderMessage objects
+ * @param soapModules - An array of SOAPModule objects
+ * @return ArrayList - An ArrayList of SOAPHeaderMessage objects
+ */
+ private ArrayList createSoapModules(SOAPModule soapModules[]) {
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // check whether there are messages that are wrappable. If there are no
- // messages that are wrappable we'll
- // just return null and endup this process. However we need to take the
- // force flag into account here
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- QName[] keys;
- if (forceWrapping) {
- // just take all the messages and wrap them, we've been told to
- // force wrapping!
- keys = (QName[]) messagesMap.keySet().toArray(
- new QName[messagesMap.size()]);
- } else {
- //
- QName[] allKeys = (QName[]) messagesMap.keySet().toArray(
- new QName[messagesMap.size()]);
- List wrappableMessageNames = new ArrayList();
- boolean noMessagesTobeProcessed = true;
-
- // TODO Fix this
- // for (int i = 0; i < allKeys.length; i++) {
- // if (findWrapppable((Message) messagesMap.get(allKeys[i]))) {
- // noMessagesTobeProcessed = false;
- // //add that message to the list
- // wrappableMessageNames.add(allKeys[i]);
- // }
- // }
- if (noMessagesTobeProcessed) {
- return null;
- }
+ if (soapModules.length ==0)
+ return null;
+ ArrayList soapModuleMessages = new ArrayList();
- keys = (QName[]) wrappableMessageNames
- .toArray(new QName[wrappableMessageNames.size()]);
+ for (int i = 0; i < soapModules.length; i++) {
+ SOAPModule soapModule = soapModules[i];
+ SOAPModuleMessage soapModuleMessage = new SOAPModuleMessage();
+ soapModuleMessage.setUri(soapModule.getRef().toString());
+ soapModuleMessages.add(soapModuleMessage);
}
+ return soapModuleMessages;
+ }
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Now we have the message list to process - Process the whole list of
- // messages at once
- // since we need to generate one single schema
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- // List resolvedMessageQNames = new ArrayList();
- // //find the xsd prefix
- // String xsdPrefix = findSchemaPrefix();
- // Message wsdl4jMessage;
- // //DOM document that will be the ultimate creator
- // Document document = getDOMDocumentBuilder().newDocument();
- // for (int i = 0; i < keys.length; i++) {
- // wsdl4jMessage = (Message) messagesMap.get(keys[i]);
- // //No need to check the wrappable,
- //
- // //This message is wrappabel. However we need to see whether the
- // // message is already
- // //resolved!
- // if (!resolvedMessageQNames.contains(wsdl4jMessage.getQName())) {
- // //This message has not been touched before!. So we can go ahead
- // // now
- // Map parts = wsdl4jMessage.getParts();
- // //add the complex type
- // String name = wsdl4jMessage.getQName().getLocalPart();
- // Element newComplexType = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_COMPLEX_TYPE_LOCAL_NAME);
- // newComplexType.setAttribute(XSD_NAME, name);
- //
- // Element cmplxContentSequence = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_SEQUENCE_LOCAL_NAME);
- // Element child;
- // Iterator iterator = parts.keySet().iterator();
- // while (iterator.hasNext()) {
- // Part part = (Part) parts.get(iterator.next());
- // //the part name
- // String elementName = part.getName();
- // boolean isTyped = true;
- // //the type name
- // QName schemaTypeName;
- // if (part.getTypeName() != null) {
- // schemaTypeName = part.getTypeName();
- // } else if (part.getElementName() != null) {
- // schemaTypeName = part.getElementName();
- // isTyped = false;
- // } else {
- // throw new RuntimeException(" Unqualified Message part!");
- // }
- //
- // child = document.createElementNS(XMLSCHEMA_NAMESPACE_URI,
- // xsdPrefix + ":" + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- //
- // String prefix;
- // if (XMLSCHEMA_NAMESPACE_URI.equals(schemaTypeName
- // .getNamespaceURI())) {
- // prefix = xsdPrefix;
- // } else {
- // //this schema is a third party one. So we need to have
- // // an import statement in our generated schema
- // String uri = schemaTypeName.getNamespaceURI();
- // if (!namespaceImportsMap.containsKey(uri)) {
- // //create Element for namespace import
- // Element namespaceImport = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_IMPORT_LOCAL_NAME);
- // namespaceImport.setAttribute("namespace", uri);
- // //add this to the map
- // namespaceImportsMap.put(uri, namespaceImport);
- // //we also need to associate this uri with a prefix
- // // and include that prefix
- // //in the schema's namspace declarations. So add
- // // theis particular namespace to the
- // //prefix map as well
- // prefix = getTemporaryNamespacePrefix();
- // namespacePrefixMap.put(uri, prefix);
- // } else {
- // //this URI should be already in the namspace prefix
- // // map
- // prefix = (String) namespacePrefixMap.get(uri);
- // }
- //
- // }
- // // If it's from a type the element we need to add a name and
- // // the type
- // //if not it's the element reference
- // if (isTyped) {
- // child.setAttribute(XSD_NAME, elementName);
- // child.setAttribute(XSD_TYPE, prefix + ":"
- // + schemaTypeName.getLocalPart());
- // } else {
- // child.setAttribute(XSD_REF, prefix + ":"
- // + schemaTypeName.getLocalPart());
- // }
- // cmplxContentSequence.appendChild(child);
- // }
- // newComplexType.appendChild(cmplxContentSequence);
- // //add this newly created complextype to the list
- // complexTypeElementsMap.put(wsdl4jMessage.getQName(),
- // newComplexType);
- // resolvedMessageQNames.add(wsdl4jMessage.getQName());
- // }
- //
- // }
- //
- // Element elementDeclaration;
- //
- // //loop through the input op map and generate the elements
- // String[] inputOperationtNames = (String[])
- // inputOperationsMap.keySet()
- // .toArray(new String[inputOperationsMap.size()]);
- // for (int j = 0; j < inputOperationtNames.length; j++) {
- // String inputOpName = inputOperationtNames[j];
- // elementDeclaration = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- // elementDeclaration.setAttribute(XSD_NAME, inputOpName);
- //
- // String typeValue = ((Message) inputOperationsMap.get(inputOpName))
- // .getQName().getLocalPart();
- // elementDeclaration.setAttribute(XSD_TYPE, AXIS2WRAPPED + ":"
- // + typeValue);
- // elementElementsList.add(elementDeclaration);
- // resolvedRpcWrappedElementMap.put(inputOpName, new QName(
- // targetNamespaceUri, inputOpName, AXIS2WRAPPED));
- // }
- //
- // //loop through the output op map and generate the elements
- // String[] outputOperationtNames = (String[]) outputOperationsMap
- // .keySet().toArray(new String[outputOperationsMap.size()]);
- // for (int j = 0; j < outputOperationtNames.length; j++) {
- //
- // String baseoutputOpName = outputOperationtNames[j];
- // String outputOpName = baseoutputOpName + "Response";
- // elementDeclaration = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- // elementDeclaration.setAttribute(XSD_NAME, outputOpName);
- // String typeValue = ((Message) outputOperationsMap
- // .get(baseoutputOpName)).getQName().getLocalPart();
- // elementDeclaration.setAttribute(XSD_TYPE, AXIS2WRAPPED + ":"
- // + typeValue);
- // elementElementsList.add(elementDeclaration);
- // resolvedRpcWrappedElementMap.put(outputOpName, new QName(
- // targetNamespaceUri, outputOpName, AXIS2WRAPPED));
- //
- // }
- //
- // //loop through the faultoutput op map and generate the elements
- // String[] faultyOperationtNames = (String[]) faultyOperationsMap
- // .keySet().toArray(new String[faultyOperationsMap.size()]);
- // for (int j = 0; j < faultyOperationtNames.length; j++) {
- //
- // String baseFaultOpName = faultyOperationtNames[j];
- // elementDeclaration = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_ELEMENT_LOCAL_NAME);
- // elementDeclaration.setAttribute(XSD_NAME, baseFaultOpName);
- // String typeValue = ((Message) faultyOperationsMap
- // .get(baseFaultOpName)).getQName().getLocalPart();
- // elementDeclaration.setAttribute(XSD_TYPE, AXIS2WRAPPED + ":"
- // + typeValue);
- // elementElementsList.add(elementDeclaration);
- // resolvedRpcWrappedElementMap.put(baseFaultOpName, new QName(
- // targetNamespaceUri, baseFaultOpName, AXIS2WRAPPED));
- //
- // }
- //
- // //////////////////////////////////////////////////////////////////////////////////////////////
- // // Now we are done with processing the messages and generating the
- // right
- // // schema object model
- // // time to write out the schema
- // //////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Element schemaElement = document.createElementNS(
- // XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
- // + XML_SCHEMA_LOCAL_NAME);
- //
- // //loop through the namespace declarations first
- // String[] nameSpaceDeclarationArray = (String[]) namespacePrefixMap
- // .keySet().toArray(new String[namespacePrefixMap.size()]);
- // for (int i = 0; i < nameSpaceDeclarationArray.length; i++) {
- // String s = nameSpaceDeclarationArray[i];
- // schemaElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
- // "xmlns:" + namespacePrefixMap.get(s).toString(), s);
- //
- // }
- //
- // //add the targetNamespace
- //
- // schemaElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
- // XMLNS_AXIS2WRAPPED, targetNamespaceUri);
- // schemaElement.setAttribute(XSD_TARGETNAMESPACE, targetNamespaceUri);
- // schemaElement.setAttribute(XSD_ELEMENT_FORM_DEFAULT,
- // XSD_UNQUALIFIED);
- //
- // Element[] namespaceImports = (Element[]) namespaceImportsMap.values()
- // .toArray(new Element[namespaceImportsMap.size()]);
- // for (int i = 0; i < namespaceImports.length; i++) {
- // schemaElement.appendChild(namespaceImports[i]);
- //
- // }
- //
- // Element[] complexTypeElements = (Element[]) complexTypeElementsMap
- // .values().toArray(new Element[complexTypeElementsMap.size()]);
- // for (int i = 0; i < complexTypeElements.length; i++) {
- // schemaElement.appendChild(complexTypeElements[i]);
- //
- // }
- //
- // Element[] elementDeclarations = (Element[]) elementElementsList
- // .toArray(new Element[elementElementsList.size()]);
- // for (int i = 0; i < elementDeclarations.length; i++) {
- // schemaElement.appendChild(elementDeclarations[i]);
- //
- // }
-
- // return schemaElement;
+ /**
+ * Convert woden dependent HTTPHeader objects to Header objects
+ * @param httpHeaders - An array of HTTPHeader objects
+ * @return ArrayList - An ArrayList of Header objects
+ */
+ private ArrayList createHttpHeaders(HTTPHeader httpHeaders[]) {
+ if (httpHeaders.length ==0)
return null;
- }
+ ArrayList httpHeaderMessages = new ArrayList();
- private boolean findWrapForceable(BindingElement binding) {
- boolean retVal = false;
- if (RPC.equalsIgnoreCase(binding.getInterfaceElement()
- .getStyleDefault().toString())) {
- return true;
- }
- if (!retVal) {
- InterfaceOperationElement[] operations = binding
- .getInterfaceElement().getInterfaceOperationElements();
- for (int i = 0; i < operations.length; i++) {
- URI[] styles = operations[i].getStyle();
- for (int j = 0; j < styles.length; j++) {
- if (RPC.equalsIgnoreCase(styles[j].toString())) {
- return true;
- }
+ for (int i = 0; i < httpHeaders.length; i++) {
+ HTTPHeader httpHeader = httpHeaders[i];
+ TypeDefinition typeDefinition = httpHeader.getTypeDefinition();
- }
+ if (typeDefinition != null) {
+ HTTPHeaderMessage httpHeaderMessage = new HTTPHeaderMessage();
+ httpHeaderMessage.setqName(typeDefinition.getName());
+ httpHeaderMessage.setName(httpHeader.getName());
+ httpHeaderMessage.setRequired(httpHeader.isRequired().booleanValue());
+ httpHeaderMessages.add(httpHeaderMessage);
}
}
- return false;
- }
-
- private Description readInTheWSDLFile(String wsdlURI)
- throws WSDLException {
-
- WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
-
- // TODO : I can not find a constant for this feature in WSDLReader
- // reader.setFeature("javax.wsdl.importDocuments", false);
-
-// reader.setFeature(WSDLReader.FEATURE_VERBOSE, false);
- return reader.readWSDL(wsdlURI);
+ return httpHeaderMessages;
}
-
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL2Constants.java Mon Feb 5 00:21:12 2007
@@ -19,10 +19,13 @@
*/
public interface WSDL2Constants {
+
String WSDL_NAMESPACE = "http://www.w3.org/2006/01/wsdl";
String DEFAULT_WSDL_NAMESPACE_PREFIX = "wsdl2";
String DESCRIPTION = "description";
String URI_WSDL2_SOAP = "http://www.w3.org/2006/01/wsdl/soap";
+ String URI_WSDL2_HTTP = "http://www.w3.org/2006/01/wsdl/http";
+ String URI_WSDL2_EXTENSIONS = "http://www.w3.org/2006/01/wsdl-extensions";
String SOAP_PREFIX = "wsoap";
String URI_WSDL2_SOAP_ENV = "http://www.w3.org/2003/05/soap-envelope";
String SOAP_ENV_PREFIX = "soap";
@@ -42,16 +45,45 @@
String MESSAGE_LABEL = "messageLabel";
String ATTRIBUTE_ELEMENT = "element";
- String BINDING_LOCAL_NAME = "binding ";
+ String BINDING_LOCAL_NAME = "binding";
+ String ENDPOINT_LOCAL_NAME = "endpoint";
String SOAP_BINDING_PREFIX = "SOAPBinding";
String HTTP_PROTOCAL = "http://www.w3.org/2003/05/soap/bindings/HTTP";
String SERVICE_LOCAL_NAME = "service";
-
+
String URI_HTTP_SOAP12 = "http://www.w3.org/2003/05/soap/bindings/HTTP";
String URI_HTTP_SOAP11 = "http://www.w3.org/2006/01/soap11/bindings/HTTP";
- String ATTR_PROTOCOL = "protocol";
- String ATTR_VERSION = "version";
+ String URI_WSOAP_MEP = "http://www.w3.org/2003/05/soap/mep/soap-response/";
+
+ String ATTR_WSOAP_PROTOCOL = "wsoap:protocol";
+ String ATTR_WSOAP_VERSION = "wsoap:version";
+ String ATTR_WSOAP_CODE = "wsoap:code";
+ String ATTR_WSOAP_MEP = "wsoap:mep";
+ String ATTR_WSOAP_MODULE = "wsoap:module";
+ String ATTR_WSOAP_SUBCODES = "wsoap:subcodes";
+ String ATTR_WSOAP_HEADER = "wsoap:header";
+ String ATTR_WSOAP_ACTION = "wsoap:action";
+
+ String ATTR_WHTTP_TRANSFER_CODING = "whttp:transferCoding";
+ String ATTR_WHTTP_LOCATION = "whttp:location";
+ String ATTR_WHTTP_HEADER = "whttp:header";
+ String ATTR_WHTTP_METHOD = "whttp:method";
+ String ATTR_WHTTP_CODE = "whttp:code";
+ String ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR = "whttp:queryParameterSeparator";
+ String ATTR_WHTTP_IGNORE_UNCITED = "whttp:ignoreUncited";
+ String ATTR_WHTTP_INPUT_SERIALIZATION = "whttp:inputSerialization";
+ String ATTR_WHTTP_OUTPUT_SERIALIZATION = "whttp:outputSerialization";
+ String ATTR_WHTTP_FAULT_SERIALIZATION = "whttp:faultSerialization";
+ String ATTR_WHTTP_AUTHENTICATION_TYPE = "whttp:authenticationType";
+ String ATTR_WHTTP_AUTHENTICATION_REALM = "whttp:authenticationRealm";
+
+ String ATTR_WSDLX_SAFE = "wsdlx:safe";
+
+ String SOAP_VERSION_1_1 = "1.1";
+ String SOAP_VERSION_1_2 = "1.2";
String MESSAGE_LABEL_IN = "In";
String MESSAGE_LABEL_OUT = "Out";
+
+ String HTTP_LOCATION_TABLE = "HTTPLocationTable";
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/SOAPMessageBodyBasedOperationDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/SOAPMessageBodyBasedOperationDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/SOAPMessageBodyBasedOperationDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/dispatchers/SOAPMessageBodyBasedOperationDispatcher.java Mon Feb 5 00:21:12 2007
@@ -18,10 +18,9 @@
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AbstractDispatcher.java Mon Feb 5 00:21:12 2007
@@ -18,10 +18,14 @@
package org.apache.axis2.engine;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.AxisBindingOperation;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.wsdl.WSDLConstants;
@@ -89,19 +93,29 @@
}
}
- if ((msgctx.getAxisService() != null) && (msgctx.getAxisOperation() == null)) {
+ if ((axisService != null) && (msgctx.getAxisOperation() == null)) {
AxisOperation axisOperation = findOperation(axisService, msgctx);
if (axisOperation != null) {
if (isDebugEnabled) {
- log.debug(msgctx.getLogIDString()+" "+Messages.getMessage("operationfound",
- axisOperation.getName().getLocalPart()));
+ log.debug(msgctx.getLogIDString() + " " + Messages.getMessage("operationfound",
+ axisOperation
+ .getName().getLocalPart()));
}
msgctx.setAxisOperation(axisOperation);
//setting axisMessage into messageContext
msgctx.setAxisMessage(axisOperation.getMessage(
WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+ AxisEndpoint axisEndpoint =
+ (AxisEndpoint) msgctx.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
+ if (axisEndpoint != null) {
+ AxisBindingOperation axisBindingOperation =
+ (AxisBindingOperation) axisEndpoint.getBinding()
+ .getChild(axisOperation.getName());
+ msgctx.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
+ }
+
}
}
return InvocationResponse.CONTINUE;
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java?view=diff&rev=503585&r1=503584&r2=503585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AddressingBasedDispatcher.java Mon Feb 5 00:21:12 2007
@@ -18,18 +18,23 @@
package org.apache.axis2.engine;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.*;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisBindingOperation;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
+import java.util.Map;
/**
* Dispatcher based on the WS-Addressing properties.
@@ -53,21 +58,22 @@
String action = messageContext.getWSAAction();
if (action != null) {
- return service.getOperationByAction(action);
+ AxisOperation axisOperation = service.getOperationByAction(action);
+ return axisOperation;
}
return null;
}
public AxisService findService(MessageContext messageContext) throws AxisFault {
- EndpointReference toEPR = messageContext.getTo();
+EndpointReference toEPR = messageContext.getTo();
AxisService service = null;
if (toEPR != null) {
if (toEPR.hasAnonymousAddress()) {
return null;
}
-
+
String address = toEPR.getAddress();
if(isDebugEnabled){
log.debug(messageContext.getLogIDString()+" "+Messages.getMessage("checkingserviceforepr", address));
@@ -89,7 +95,25 @@
AxisConfiguration registry =
configurationContext.getAxisConfiguration();
- return registry.getService(serviceName.getLocalPart());
+ AxisService axisService = registry.getService(serviceName.getLocalPart());
+
+ // If the axisService is not null we get the binding that the request came to add
+ // add it as a property to the messageContext
+ if (axisService != null) {
+ Map endpoints = axisService.getEndpoints();
+ if (endpoints != null) {
+ if (endpoints.size() == 1) {
+ messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+ endpoints.get(
+ axisService.getEndpointName()));
+ } else {
+ String endpointName = values[0].substring(values[0].indexOf(".") + 1);
+ messageContext.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
+ endpoints.get(endpointName));
+ }
+ }
+ }
+ return axisService;
}
}
@@ -116,7 +140,8 @@
}
if ((relatesTo != null) || "".equals(relatesTo)) {
OperationContext operationContext =
- msgctx.getConfigurationContext().getOperationContext(msgctx.getRelatesTo().getValue());
+ msgctx.getConfigurationContext()
+ .getOperationContext(msgctx.getRelatesTo().getValue());
if (operationContext != null) {
operationContext.addMessageContext(msgctx);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org