You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/02/11 19:24:08 UTC
svn commit: r620568 -
/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
Author: mriou
Date: Mon Feb 11 10:24:08 2008
New Revision: 620568
URL: http://svn.apache.org/viewvc?rev=620568&view=rev
Log:
ODE-241 An xsd including another xsd throws a NPE on deployment
Modified:
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java?rev=620568&r1=620567&r2=620568&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java Mon Feb 11 10:24:08 2008
@@ -49,6 +49,9 @@
import org.apache.ode.axis2.util.Axis2UriResolver;
import org.apache.ode.axis2.util.Axis2WSDLLocator;
import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.w3c.dom.Element;
/**
* Implementation of Axis Service used by ODE iapi to enlist itself its service. Allows us to build the service using a
@@ -59,27 +62,24 @@
private static final Log LOG = LogFactory.getLog(ODEAxisService.class);
public static AxisService createService(AxisConfiguration axisConfig, ProcessConf pconf, QName wsdlServiceName,
- String portName) throws AxisFault {
+ String portName) throws AxisFault {
Definition wsdlDefinition = pconf.getDefinitionForService(wsdlServiceName);
String serviceName = extractServiceName(wsdlDefinition, wsdlServiceName, portName);
if (LOG.isDebugEnabled()) {
- LOG.debug("Create AxisService:"
- +" service="+wsdlServiceName
- +" port="+portName
- +" WSDL="+wsdlDefinition.getDocumentBaseURI()
- +" BPEL="+pconf.getBpelDocument());
+ LOG.debug("Create AxisService:"+" service="+wsdlServiceName+" port="+portName
+ +" WSDL="+wsdlDefinition.getDocumentBaseURI()+" BPEL="+pconf.getBpelDocument());
}
try {
- URI baseUri = pconf.getBaseURI().resolve(wsdlDefinition.getDocumentBaseURI());
+ URI baseUri = pconf.getBaseURI().resolve(wsdlDefinition.getDocumentBaseURI());
InputStream is = baseUri.toURL().openStream();
- WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(is, wsdlServiceName, portName);
+ WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisPatchedBuilder(is, wsdlServiceName, portName);
serviceBuilder.setBaseUri(baseUri.toString());
serviceBuilder.setCustomResolver(new Axis2UriResolver());
serviceBuilder.setCustomWSLD4JResolver(new Axis2WSDLLocator(baseUri));
serviceBuilder.setServerSide(true);
-
+
AxisService axisService = serviceBuilder.populateService();
axisService.setName(serviceName);
axisService.setWsdlFound(true);
@@ -87,7 +87,7 @@
axisService.setClassLoader(axisConfig.getServiceClassLoader());
// axis2 service configuration
- URI axis2config = pconf.getBaseURI().resolve(wsdlServiceName.getLocalPart()+".axis2");
+ URI axis2config = pconf.getBaseURI().resolve(wsdlServiceName.getLocalPart()+".axis2");
LOG.debug("Looking for Axis2 service configuration file: "+axis2config.toURL());
try {
InputStream ais = axis2config.toURL().openStream();
@@ -102,11 +102,11 @@
} catch (IOException except) {
LOG.warn("Exception while configuring service: " + axis2config, except);
}
-
+
// In doc/lit we need to declare a mapping between operations and message element names
// to be able to route properly.
declarePartsElements(wsdlDefinition, wsdlServiceName, serviceName, portName);
-
+
Iterator operations = axisService.getOperations();
ODEMessageReceiver msgReceiver = new ODEMessageReceiver();
while (operations.hasNext()) {
@@ -143,25 +143,25 @@
String url = null;
Service service = wsdlDefinition.getService(wsdlServiceName);
if (service == null) {
- throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition "
- + wsdlDefinition.getDocumentBaseURI());
+ throw new OdeFault("Unable to find service " + wsdlServiceName + " from service WSDL definition "
+ + wsdlDefinition.getDocumentBaseURI());
}
Port port = service.getPort(portName);
if (port == null) {
throw new OdeFault("Couldn't find port " + portName + " in definition " + wsdlServiceName);
}
for (Object oext : port.getExtensibilityElements()) {
- if (oext instanceof SOAPAddress)
- url = ((SOAPAddress) oext).getLocationURI();
+ if (oext instanceof SOAPAddress)
+ url = ((SOAPAddress) oext).getLocationURI();
}
if (url == null) {
- throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName
- + " (necessary to establish the process target address)!");
+ throw new OdeFault("Could not extract any soap:address from service WSDL definition " + wsdlServiceName
+ + " (necessary to establish the process target address)!");
}
String serviceName = parseURLForService(url);
if (serviceName == null) {
- throw new OdeFault("The soap:address used for service WSDL definition " + wsdlServiceName + " and port "
- + portName + " should be of the form http://hostname:port/ode/processes/myProcessEndpointName");
+ throw new OdeFault("The soap:address used for service WSDL definition " + wsdlServiceName + " and port "
+ + portName + " should be of the form http://hostname:port/ode/processes/myProcessEndpointName");
}
return serviceName;
}
@@ -174,7 +174,7 @@
int index = path.indexOf("/processes/");
if (-1 != index) {
String service;
-
+
int serviceStart = index + "/processes/".length();
if (path.length() > serviceStart + 1) {
service = path.substring(serviceStart);
@@ -190,22 +190,49 @@
}
private static void declarePartsElements(Definition wsdlDefinition, QName wsdlServiceName, String axisServiceName,
- String portName) {
+ String portName) {
List wsldOps = wsdlDefinition.getService(wsdlServiceName).getPort(portName).getBinding().getPortType()
.getOperations();
- for (Object wsldOp : wsldOps) {
- Operation wsdlOp = (Operation) wsldOp;
- Collection parts = wsdlOp.getInput().getMessage().getParts().values();
- // More than one part, it's rpc/enc, no mapping needs to be declared
- if (parts.size() == 1) {
- Part part = (Part) parts.iterator().next();
- // Parts are types, it's rpc/enc, no mapping needs to be declared
- if (part.getElementName() != null)
+ for (Object wsldOp : wsldOps) {
+ Operation wsdlOp = (Operation) wsldOp;
+ Collection parts = wsdlOp.getInput().getMessage().getParts().values();
+ // More than one part, it's rpc/enc, no mapping needs to be declared
+ if (parts.size() == 1) {
+ Part part = (Part) parts.iterator().next();
+ // Parts are types, it's rpc/enc, no mapping needs to be declared
+ if (part.getElementName() != null)
ODEAxisDispatcher.addElmtToOpMapping(axisServiceName, wsdlOp.getName(), part.getElementName()
.getLocalPart());
- }
+ }
+ }
}
- }
+ // Axis2 monkey patching to force the usage of the read(element,baseUri) method
+ // of XmlSchema as the normal read is broken.
+ public static class WSDL11ToAxisPatchedBuilder extends WSDL11ToAxisServiceBuilder {
+ public WSDL11ToAxisPatchedBuilder(InputStream in, QName serviceName, String portName) {
+ super(in, serviceName, portName);
+ }
+ public WSDL11ToAxisPatchedBuilder(Definition def, QName serviceName, String portName) {
+ super(def, serviceName, portName);
+ }
+ public WSDL11ToAxisPatchedBuilder(Definition def, QName serviceName, String portName, boolean isAllPorts) {
+ super(def, serviceName, portName, isAllPorts);
+ }
+ public WSDL11ToAxisPatchedBuilder(InputStream in, AxisService service) {
+ super(in, service);
+ }
+ public WSDL11ToAxisPatchedBuilder(InputStream in) {
+ super(in);
+ }
+
+ protected XmlSchema getXMLSchema(Element element, String baseUri) {
+ XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
+ if (baseUri != null) {
+ schemaCollection.setBaseUri(baseUri);
+ }
+ return schemaCollection.read(element, baseUri);
+ }
+ }
}