You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2016/02/14 14:36:14 UTC
svn commit: r1730335 - in /axis/axis2/java/core/trunk/modules/kernel:
src/org/apache/axis2/description/ test-resources/wsdl/imports/
test-resources/wsdl/imports/binding/
test-resources/wsdl/imports/binding_recursive/
test-resources/wsdl/imports/portTyp...
Author: veithen
Date: Sun Feb 14 13:36:13 2016
New Revision: 1730335
URL: http://svn.apache.org/viewvc?rev=1730335&view=rev
Log:
AXIS2-5732: Fix issue in WSDL11ToAxisServiceBuilder triggered by WSDLs with bindings defined in imported documents. Patch provided by Detelin Yordanov.
Added:
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoBindings.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoService.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoTypes.xsd
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoBindings.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoService.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoTypes.xsd
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoBindings.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoPortType.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoService.wsdl
axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoTypes.xsd
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=1730335&r1=1730334&r2=1730335&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Sun Feb 14 13:36:13 2016
@@ -332,10 +332,16 @@ public class WSDL11ToAxisServiceBuilder
Binding binding = findBinding(wsdl4jDefinition, wsdl4jService);
Definition bindingWSDL = getParentDefinition(wsdl4jDefinition,
binding.getQName(), COMPONENT_BINDING, new HashSet());
- Definition portTypeWSDL = getParentDefinition(bindingWSDL,
- binding.getPortType().getQName(), COMPONENT_PORT_TYPE, new HashSet());
- PortType portType = portTypeWSDL.getPortType(binding.getPortType().getQName());
-
+
+ //do not search for wsdl where port type is defined, this search is depth-first
+ //and might lead to a wsdl where the port is only referenced but undefined
+ //instead look up the port type in the wsdl and only if not found fall back to binding's port type
+ PortType portType = wsdl4jDefinition.getPortType(binding.getPortType().getQName());
+ if (portType == null) {
+ //TODO in case of recursive imports, binding's port type will contain operations with null input message
+ //requires fix for http://sourceforge.net/p/wsdl4j/bugs/39
+ portType = binding.getPortType();
+ }
if (portType == null) {
throw new AxisFault("There is no port type associated with the binding");
@@ -361,7 +367,7 @@ public class WSDL11ToAxisServiceBuilder
addDocumentation(axisService, documentationElement);
axisService.setName(wsdl4jService.getQName().getLocalPart());
- populateEndpoints(binding, bindingWSDL,wsdl4jService, portType, portTypeWSDL);
+ populateEndpoints(binding, bindingWSDL,wsdl4jService, portType);
processPoliciesInDefintion(wsdl4jDefinition);
axisService.getPolicyInclude().setPolicyRegistry(registry);
@@ -457,8 +463,7 @@ public class WSDL11ToAxisServiceBuilder
private void populateEndpoints(Binding binding,
Definition bindingWSDL,
Service wsdl4jService,
- PortType portType,
- Definition portTypeWSDL) throws AxisFault {
+ PortType portType) throws AxisFault {
Map wsdl4jPorts = wsdl4jService.getPorts();
QName bindingName = binding.getQName();
@@ -471,7 +476,7 @@ public class WSDL11ToAxisServiceBuilder
// process the port type for this binding
// although we support multiports they must be belongs to same port type and should have the
// same soap style
- populatePortType(portType, portTypeWSDL);
+ populatePortType(portType);
Binding currentBinding;
Definition currentBindingWSDL = null;
@@ -492,12 +497,12 @@ public class WSDL11ToAxisServiceBuilder
if (axisService.getEndpointName() == null &&
bindingName.equals(port.getBinding().getQName())) {
populateEndpoint(axisEndpoint, port, currentBinding,
- bindingWSDL, portType, portTypeWSDL, true);
+ bindingWSDL, portType, true);
axisService.setEndpointName(axisEndpoint.getName());
axisService.setBindingName(axisEndpoint.getBinding().getName().getLocalPart());
} else {
populateEndpoint(axisEndpoint, port, currentBinding,
- bindingWSDL, portType, portTypeWSDL, false);
+ bindingWSDL, portType, false);
}
axisEndpoint.setParent(axisService);
@@ -523,7 +528,6 @@ public class WSDL11ToAxisServiceBuilder
Binding wsdl4jBinding,
Definition bindingWSDL,
PortType portType,
- Definition portTypeWSDL,
boolean isSetMessageQNames)
throws AxisFault {
@@ -544,7 +548,6 @@ public class WSDL11ToAxisServiceBuilder
wsdl4jBinding,
bindingWSDL,
portType,
- portTypeWSDL,
isSetMessageQNames);
processedBindings.put(wsdl4jBinding.getQName(), axisBinding);
}
@@ -578,8 +581,7 @@ public class WSDL11ToAxisServiceBuilder
}
}
- private void populatePortType(PortType wsdl4jPortType,
- Definition portTypeWSDL) throws AxisFault {
+ private void populatePortType(PortType wsdl4jPortType) throws AxisFault {
copyExtensionAttributes(wsdl4jPortType.getExtensionAttributes(),
axisService, PORT_TYPE);
List wsdl4jOperations = wsdl4jPortType.getOperations();
@@ -600,7 +602,7 @@ public class WSDL11ToAxisServiceBuilder
for (Iterator iterator = wsdl4jOperations.iterator(); iterator.hasNext();) {
wsdl4jOperation = (Operation) iterator.next();
- axisOperation = populateOperations(wsdl4jOperation, wsdl4jPortType, portTypeWSDL);
+ axisOperation = populateOperations(wsdl4jOperation, wsdl4jPortType);
addDocumentation(axisOperation, wsdl4jOperation.getDocumentationElement());
if (wsdl4jOperation.getInput() != null) {
addMessageDocumentation(axisOperation, wsdl4jOperation.getInput().getDocumentationElement(), WSDLConstants.MESSAGE_LABEL_IN_VALUE);
@@ -645,7 +647,6 @@ public class WSDL11ToAxisServiceBuilder
Binding wsdl4jBinding,
Definition bindingWSDL,
PortType portType,
- Definition portTypeWSDL,
boolean isSetMessageQNames)
throws AxisFault {
@@ -678,7 +679,7 @@ public class WSDL11ToAxisServiceBuilder
axisBindingOperation.setName(new QName(bindingWSDL.getTargetNamespace(), wsdl4jBindingOperation.getName()));
addDocumentation(axisBindingOperation, wsdl4jBindingOperation.getDocumentationElement());
- axisOperation = axisService.getOperation(new QName(portTypeWSDL.getTargetNamespace(), wsdl4jOperation.getName()));
+ axisOperation = axisService.getOperation(new QName(portType.getQName().getNamespaceURI(), wsdl4jOperation.getName()));
axisBindingOperation.setAxisOperation(axisOperation);
// process ExtensibilityElements of the wsdl4jBinding
@@ -1406,9 +1407,9 @@ public class WSDL11ToAxisServiceBuilder
* @throws AxisFault
*/
private AxisOperation populateOperations(Operation wsdl4jOperation,
- PortType wsdl4jPortType, Definition dif)
+ PortType wsdl4jPortType)
throws AxisFault {
- QName opName = new QName(dif.getTargetNamespace(), wsdl4jOperation.getName());
+ QName opName = new QName(wsdl4jPortType.getQName().getNamespaceURI(), wsdl4jOperation.getName());
// Copy Name Attribute
AxisOperation axisOperation = axisService.getOperation(opName);
if (axisOperation == null) {
@@ -1444,7 +1445,7 @@ public class WSDL11ToAxisServiceBuilder
String action = null;
if (inputActions == null || inputActions.size() == 0) {
action = WSDL11ActionHelper
- .getActionFromInputElement(dif, wsdl4jPortType,
+ .getActionFromInputElement(wsdl4jDefinition, wsdl4jPortType,
wsdl4jOperation, wsdl4jInputMessage);
}
if (action != null) {
@@ -1475,7 +1476,7 @@ public class WSDL11ToAxisServiceBuilder
// with the Default Action Pattern
String action = axisOperation.getOutputAction();
if (action == null) {
- action = WSDL11ActionHelper.getActionFromOutputElement(dif,
+ action = WSDL11ActionHelper.getActionFromOutputElement(wsdl4jDefinition,
wsdl4jPortType,
wsdl4jOperation,
wsdl4jOutputMessage);
@@ -1507,7 +1508,7 @@ public class WSDL11ToAxisServiceBuilder
String action = axisOperation.getOutputAction();
if (action == null) {
action = WSDL11ActionHelper
- .getActionFromInputElement(dif, wsdl4jPortType,
+ .getActionFromInputElement(wsdl4jDefinition, wsdl4jPortType,
wsdl4jOperation, wsdl4jInputMessage);
}
if (action != null) {
@@ -1534,7 +1535,7 @@ public class WSDL11ToAxisServiceBuilder
ArrayList inputActions = axisOperation.getWSAMappingList();
String action = null;
if (inputActions == null || inputActions.size() == 0) {
- action = WSDL11ActionHelper.getActionFromOutputElement(dif,
+ action = WSDL11ActionHelper.getActionFromOutputElement(wsdl4jDefinition,
wsdl4jPortType,
wsdl4jOperation,
wsdl4jOutputMessage);
@@ -1563,7 +1564,7 @@ public class WSDL11ToAxisServiceBuilder
.setName(faultMessage.getQName().getLocalPart());
copyExtensibleElements(faultMessage.getExtensibilityElements(),
- dif, axisFaultMessage, PORT_TYPE_OPERATION_FAULT);
+ wsdl4jDefinition, axisFaultMessage, PORT_TYPE_OPERATION_FAULT);
}
@@ -1572,7 +1573,7 @@ public class WSDL11ToAxisServiceBuilder
// with the Default Action Pattern
String action = axisOperation.getFaultAction(fault.getName());
if (action == null) {
- action = WSDL11ActionHelper.getActionFromFaultElement(dif,
+ action = WSDL11ActionHelper.getActionFromFaultElement(wsdl4jDefinition,
wsdl4jPortType,
wsdl4jOperation, fault);
}
@@ -1593,7 +1594,7 @@ public class WSDL11ToAxisServiceBuilder
String faultAction = axisOperation.getFaultAction(exceptionClassName);
if (faultAction == null) {
- faultAction = WSDL11ActionHelper.getActionFromFaultElement(dif,
+ faultAction = WSDL11ActionHelper.getActionFromFaultElement(wsdl4jDefinition,
wsdl4jPortType,
wsdl4jOperation, fault);
if (log.isDebugEnabled()) {
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoBindings.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoBindings.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoBindings.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoBindings.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org/bindings">
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="basicAuthPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:binding name="EchoServiceSoap12Binding" type="ns:EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#basicAuthPolicy"/>
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="echo">
+ <soap12:operation soapAction="urn:echo" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="EchoServiceHttpBinding" type="ns:EchoServicePortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="echo">
+ <http:operation location="echo"/>
+ <wsdl:input>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoService.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoService.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoService.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoService.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org"
+ xmlns:bindings="http://tempuri.org/bindings"
+ xmlns:types="http://tempuri.org/types"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org">
+
+ <wsdl:documentation>EchoService</wsdl:documentation>
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="usingAddressingPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <wsaws:UsingAddressing xmlns:wsaws="http://schemas.xmlsoap.org/ws/2004/08/addressing" />
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:import namespace="http://tempuri.org/bindings" location="EchoBindings.wsdl" />
+
+ <wsdl:types>
+ <xs:schema targetNamespace="http://tempuri.org/imports">
+ <xs:import schemaLocation="EchoTypes.xsd" namespace="http://tempuri.org/types" />
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="echoRequest">
+ <wsdl:part name="parameters" element="types:echo"/>
+ </wsdl:message>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="parameters" element="types:echoResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#usingAddressingPolicy"/>
+ <wsdl:operation name="echo">
+ <wsdl:input message="ns:echoRequest" wsaw:Action="urn:custom:echo"/>
+ <wsdl:output message="ns:echoResponse" wsaw:Action="urn:custom:echoResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:service name="EchoService">
+ <wsdl:port name="EchoServiceHttpSoap12Endpoint" binding="bindings:EchoServiceSoap12Binding">
+ <soap12:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpSoap12Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="EchoServiceHttpEndpoint" binding="bindings:EchoServiceHttpBinding">
+ <http:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpEndpoint/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoTypes.xsd
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoTypes.xsd?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoTypes.xsd (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding/EchoTypes.xsd Sun Feb 14 13:36:13 2016
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema elementFormDefault="qualified"
+ targetNamespace="http://tempuri.org/types"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="echo">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="echoResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoBindings.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoBindings.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoBindings.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoBindings.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org/bindings">
+
+ <wsdl:import namespace="http://tempuri.org" location="EchoService.wsdl" />
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="basicAuthPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:binding name="EchoServiceSoap12Binding" type="ns:EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#basicAuthPolicy"/>
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="echo">
+ <soap12:operation soapAction="urn:echo" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="EchoServiceHttpBinding" type="ns:EchoServicePortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="echo">
+ <http:operation location="echo"/>
+ <wsdl:input>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoService.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoService.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoService.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoService.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org"
+ xmlns:bindings="http://tempuri.org/bindings"
+ xmlns:types="http://tempuri.org/types"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org">
+
+ <wsdl:documentation>EchoService</wsdl:documentation>
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="usingAddressingPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <wsaws:UsingAddressing xmlns:wsaws="http://schemas.xmlsoap.org/ws/2004/08/addressing" />
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:import namespace="http://tempuri.org/bindings" location="EchoBindings.wsdl" />
+
+ <wsdl:types>
+ <xs:schema targetNamespace="http://tempuri.org/imports">
+ <xs:import schemaLocation="EchoTypes.xsd" namespace="http://tempuri.org/types" />
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="echoRequest">
+ <wsdl:part name="parameters" element="types:echo"/>
+ </wsdl:message>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="parameters" element="types:echoResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#usingAddressingPolicy"/>
+ <wsdl:operation name="echo">
+ <wsdl:input message="ns:echoRequest" wsaw:Action="urn:custom:echo"/>
+ <wsdl:output message="ns:echoResponse" wsaw:Action="urn:custom:echoResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:service name="EchoService">
+ <wsdl:port name="EchoServiceHttpSoap12Endpoint" binding="bindings:EchoServiceSoap12Binding">
+ <soap12:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpSoap12Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="EchoServiceHttpEndpoint" binding="bindings:EchoServiceHttpBinding">
+ <http:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpEndpoint/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoTypes.xsd
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoTypes.xsd?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoTypes.xsd (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/binding_recursive/EchoTypes.xsd Sun Feb 14 13:36:13 2016
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema elementFormDefault="qualified"
+ targetNamespace="http://tempuri.org/types"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="echo">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="echoResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoBindings.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoBindings.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoBindings.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoBindings.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org/porttype"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org/bindings">
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="basicAuthPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:import namespace="http://tempuri.org/porttype" location="EchoPortType.wsdl" />
+
+ <wsdl:binding name="EchoServiceSoap12Binding" type="ns:EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#basicAuthPolicy"/>
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="echo">
+ <soap12:operation soapAction="urn:echo" style="document"/>
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:binding name="EchoServiceHttpBinding" type="ns:EchoServicePortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="echo">
+ <http:operation location="echo"/>
+ <wsdl:input>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="application/xml" part="parameters"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoPortType.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoPortType.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoPortType.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoPortType.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:types="http://tempuri.org/types"
+ xmlns:ns="http://tempuri.org/porttype"
+ targetNamespace="http://tempuri.org/porttype">
+
+ <wsdl:types>
+ <xs:schema targetNamespace="http://tempuri.org/imports">
+ <xs:import schemaLocation="EchoTypes.xsd" namespace="http://tempuri.org/types" />
+ </xs:schema>
+ </wsdl:types>
+
+ <wsdl:message name="echoRequest">
+ <wsdl:part name="parameters" element="types:echo"/>
+ </wsdl:message>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="parameters" element="types:echoResponse"/>
+ </wsdl:message>
+
+ <wsdl:portType name="EchoServicePortType">
+ <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#usingAddressingPolicy"/>
+ <wsdl:operation name="echo">
+ <wsdl:input message="ns:echoRequest" wsaw:Action="urn:custom:echo"/>
+ <wsdl:output message="ns:echoResponse" wsaw:Action="urn:custom:echoResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoService.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoService.wsdl?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoService.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoService.wsdl Sun Feb 14 13:36:13 2016
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns="http://tempuri.org"
+ xmlns:bindings="http://tempuri.org/bindings"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://tempuri.org">
+
+ <wsdl:documentation>EchoService</wsdl:documentation>
+
+ <wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ wsu:Id="usingAddressingPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <wsaws:UsingAddressing xmlns:wsaws="http://schemas.xmlsoap.org/ws/2004/08/addressing" />
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsdl:import namespace="http://tempuri.org/bindings" location="EchoBindings.wsdl" />
+
+ <wsdl:service name="EchoService">
+ <wsdl:port name="EchoServiceHttpSoap12Endpoint" binding="bindings:EchoServiceSoap12Binding">
+ <soap12:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpSoap12Endpoint/"/>
+ </wsdl:port>
+ <wsdl:port name="EchoServiceHttpEndpoint" binding="bindings:EchoServiceHttpBinding">
+ <http:address location="http://localhost:9083/wsstack/services/EchoService.EchoServiceHttpEndpoint/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoTypes.xsd
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoTypes.xsd?rev=1730335&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoTypes.xsd (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/imports/portType/EchoTypes.xsd Sun Feb 14 13:36:13 2016
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xs:schema elementFormDefault="qualified"
+ targetNamespace="http://tempuri.org/types"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="echo">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="echoResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
Modified: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java?rev=1730335&r1=1730334&r2=1730335&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java Sun Feb 14 13:36:13 2016
@@ -23,11 +23,16 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import javax.wsdl.xml.WSDLLocator;
import javax.xml.namespace.QName;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.xml.sax.InputSource;
import junit.framework.TestCase;
@@ -113,4 +118,170 @@ public class WSDL11ToAxisServiceBuilderT
checkOperationActions(service, operation, expectedInputAction,expectedOutputAction,expectedFaultAction);
}
}
+
+ /**
+ * Tests parsing of <code>EchoService.wsdl</code> into an AxisService instance. The <code>EchoService.wsdl</code>
+ * imports <code>EchoBindings.wsdl</code>, which contains the binding definitions (note that it does not reverse-import the EchoService.wsdl).
+ * Parsing the wsdl should cause neither a "There is no port type associated with the binding" exception, nor a "Cannot determine the MEP" exception,
+ * provided that Axis2 does not recursively search the port type in all imported wsdls, but looks it up via {@link javax.wsdl.Definition#getPortType(QName)},
+ * falling back to {@link javax.wsdl.Binding#getPortType()} if not available (will be the case when port type is imported through another document but not directly)
+ *
+ * The test verifies that no exceptions are thrown and additionally checks that the endpoint, binding, operation and its in/out messages are correctly populated from the WSDL definition.
+ * @throws IOException
+ */
+ public void testImportedBindings() throws IOException {
+ AxisConfiguration axisConf = new AxisConfiguration();
+ WSDLLocator wsdlLocator = new CustomWSDLLocator("test-resources/wsdl/imports/binding/", "EchoService.wsdl");
+ AxisService service = populateAxisService(axisConf, new File(wsdlLocator.getBaseURI()), wsdlLocator);
+ assertValidEchoService(service, wsdlLocator);
+ }
+
+ /**
+ * Tests parsing of <code>EchoService.wsdl</code> into an AxisService instance. The <code>EchoService.wsdl</code>
+ * imports <code>EchoBindings.wsdl</code>, which reverse-imports the EchoService.wsdl (i.e. we have a circular import).
+ * Parsing the wsdl should cause neither a "There is no port type associated with the binding" exception, nor a "Cannot determine the MEP" exception,
+ * provided that Axis2 does not recursively search the port type in all imported wsdls, but looks it up via {@link javax.wsdl.Definition#getPortType(QName)},
+ * falling back to {@link javax.wsdl.Binding#getPortType()} if not available (will be the case when port type is imported through another document but not directly)
+ *
+ * The test verifies that no exceptions are thrown and additionally checks that the endpoint, binding, operation and its in/out messages are correctly populated from the WSDL definition.
+ * @throws IOException
+ */
+ public void testCircularImportedBindings() throws IOException {
+ AxisConfiguration axisConf = new AxisConfiguration();
+ WSDLLocator wsdlLocator = new CustomWSDLLocator("test-resources/wsdl/imports/binding_recursive/", "EchoService.wsdl");
+ AxisService service = populateAxisService(axisConf, new File(wsdlLocator.getBaseURI()), wsdlLocator);
+ assertValidEchoService(service, wsdlLocator);
+ }
+
+ /**
+ * Tests parsing of <code>EchoService.wsdl</code> into an AxisService instance. The <code>EchoService.wsdl</code>
+ * imports <code>EchoBindings.wsdl</code>, which in turn imports the <code>EchoPortType.wsdl</code>.
+ * Parsing the wsdl should cause neither a "There is no port type associated with the binding" exception, nor a "Cannot determine the MEP" exception,
+ * provided that Axis2 does not recursively search the port type in all imported wsdls, but looks it up via {@link javax.wsdl.Definition#getPortType(QName)},
+ * falling back to {@link javax.wsdl.Binding#getPortType()} if not available (will be the case when port type is imported through another document but not directly)
+ *
+ * The test verifies that no exceptions are thrown and additionally checks that the endpoint, binding, operation and its in/out messages are correctly populated from the WSDL definition.
+ * @throws IOException
+ */
+ public void testImportedPortType() throws IOException {
+ AxisConfiguration axisConf = new AxisConfiguration();
+ WSDLLocator wsdlLocator = new CustomWSDLLocator("test-resources/wsdl/imports/portType/", "EchoService.wsdl");
+ AxisService service = populateAxisService(axisConf, new File(wsdlLocator.getBaseURI()), wsdlLocator);
+ assertValidEchoService(service, wsdlLocator);
+ }
+
+ private void assertValidEchoService(AxisService echoService, WSDLLocator wsdlLocator) {
+ //check soap12 endpoint and binding are available
+ String endpointName = "EchoServiceHttpSoap12Endpoint";
+ AxisEndpoint soap12Endpoint = echoService.getEndpoint(endpointName);
+ assertNotNull(String.format("Cannot find %s endpoint in wsdl definition: %s", endpointName, wsdlLocator.getBaseURI()), soap12Endpoint);
+
+ AxisBinding soap12Binding = soap12Endpoint.getBinding();
+ assertNotNull(String.format("Binding not set on %s endpoint in wsdl definition: %s", endpointName, wsdlLocator.getBaseURI()), soap12Binding);
+
+ //check that policy reference is present on the binding subject
+ String bindingPolicyRefId = "#basicAuthPolicy";
+ assertNotNull(String.format("Cannot find policy reference %s on binding %s", bindingPolicyRefId, soap12Binding.getName()),
+ soap12Binding.getPolicySubject().getAttachedPolicyComponent(bindingPolicyRefId));
+
+ //check that binding operation and respective operation are available
+ QName echoBindingOpName = new QName("http://tempuri.org/bindings", "echo");
+ AxisBindingOperation echoBindingOp = (AxisBindingOperation) soap12Binding.getChild(echoBindingOpName);
+ assertNotNull(String.format("Cannot find %s binding operation on binding %s", echoBindingOpName, soap12Binding), echoBindingOp);
+
+ AxisOperation echoOp = echoBindingOp.getAxisOperation();
+ assertNotNull(String.format("Operation not set on binding operation %s", echoBindingOp.getName()), echoOp);
+
+ //check that operation style is correctly identified and an operation with respective mep is created
+ assertTrue(String.format("Operation %s is not an instance of %s", echoOp.getName(), InOutAxisOperation.class.getName()), echoOp instanceof InOutAxisOperation);
+ assertEquals(String.format("Operation %s specifies an unexpected MEP uri: %s", echoOp.getName(), echoOp.getMessageExchangePattern()),
+ WSDL2Constants.MEP_URI_IN_OUT, echoOp.getMessageExchangePattern());
+
+ //check in/out messages
+ AxisMessage inMessage = echoOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ assertNotNull(String.format("No input message set on operation %s", echoOp.getName()), inMessage);
+ QName echoInMessageName = new QName("http://tempuri.org/types", "echo");
+ assertEquals(String.format("Unexpected input message QName set on operation %s", echoOp.getName()), echoInMessageName, inMessage.getElementQName());
+ //message name is 'echoRequest' whereas the QName's local name is simply 'echo'
+ assertEquals(String.format("Unexpected input message name set on operation %s", echoOp.getName()), "echoRequest", inMessage.getName());
+
+ AxisMessage outMessage = echoOp.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ assertNotNull(String.format("No output message set on operation %s", echoOp.getName()), outMessage);
+ QName echoOutMessageName = new QName("http://tempuri.org/types", "echoResponse");
+ assertEquals(String.format("Unexpected output message QName set on operation %s", echoOp.getName()), echoOutMessageName, outMessage.getElementQName());
+ assertEquals(String.format("Unexpected output message name set on operation %s", echoOp.getName()), echoOutMessageName.getLocalPart(), outMessage.getName());
+ }
+
+ private AxisService populateAxisService(AxisConfiguration axisConf, File wsdlFile, WSDLLocator wsdlLocator) throws IOException {
+ InputStream in = null;
+ try {
+ in = new FileInputStream(wsdlFile);
+ WSDL11ToAxisServiceBuilder wsdl11Builder = new WSDL11ToAxisServiceBuilder(in);
+ if (wsdlLocator != null) {
+ wsdl11Builder.setCustomWSDLResolver(wsdlLocator);
+ }
+ wsdl11Builder.setDocumentBaseUri(wsdlFile.getParentFile().toURI().toString());
+ if (axisConf != null) {
+ wsdl11Builder.useAxisConfiguration(axisConf);
+ }
+ AxisService service = wsdl11Builder.populateService();
+ assertNotNull("Could not load AxisService from wsdl: " + wsdlFile.getAbsolutePath(), service);
+
+ return service;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
+ //custom locator that can located imported wsdls relative to the base wsdl uri (code borrowed from wsdl4j)
+ class CustomWSDLLocator implements WSDLLocator {
+ private String wsdlURI;
+
+ private InputSource baseInputSource;
+ private Map<String, InputSource> importInputSources = new HashMap<String, InputSource>();
+ private boolean closed = false;
+ private String baseURI;
+ private String lastImportURI;
+
+ public CustomWSDLLocator(String baseURI, String wsdlURI) {
+ this.baseURI = baseURI;
+ this.wsdlURI = wsdlURI;
+ }
+
+ public InputSource getBaseInputSource() {
+ if (baseInputSource == null) {
+ lastImportURI = baseURI + wsdlURI;
+ baseInputSource = new InputSource(lastImportURI);
+ }
+ return baseInputSource;
+ }
+
+ public InputSource getImportInputSource(String parentLocation, String importLocation) {
+ InputSource inSource = (InputSource) importInputSources.get(importLocation);
+ if (inSource == null) {
+ lastImportURI = baseURI + importLocation;
+ inSource = new InputSource(lastImportURI);
+ importInputSources.put(importLocation, inSource);
+ }
+ return inSource;
+ }
+
+ public String getBaseURI() {
+ return baseURI + wsdlURI;
+ }
+
+ public String getLatestImportURI() {
+ return lastImportURI;
+ }
+
+ public void close() {
+ closed = true;
+ }
+
+ public boolean isClosed() {
+ return closed;
+ }
+ }
}