I'm experiencing some wsdl schema namespace hell.
I have a WSDL that came from an Axis web service and I'm tyring to generate a stub service with WCF for testing purposes.
Problem is, the SVCUTIL tool generates code fine but, when hosted, no methods are exposed.
I checked the WSDL and there is a line that fails validation. I'm trying to check if that is the culprit but the namespaces are such a mess that i cannot make heads or tails of it.
So, The WSDL is roughly this. I have ommited the WSDL Bindings, Services and Ports, as I just want to focus on understanding the namespaces problem.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://p1-services.customer.com/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://returnobject.foo.bar.com/xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://ws.receiver.foo.bar.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://p1-services.customer.com/">
<wsdl:documentation>WSP1IA01Service</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://returnobject.foo.bar.com/xsd">
<xs:complexType name="ReturnEnvelope">
<xs:sequence>
<!-- Simplified -->
<xs:element minOccurs="0" name="errorCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ns="http://ws.receiver.foo.bar.com" attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://ws.receiver.foo.bar.com">
<xs:element name="setMessage">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="xmlMessage" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="setMessageResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:ReturnEnvelope"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
The bit that fails validation is the reference to ns0:ReturnEnvelope in the SetMessageResponse element. It says that the type cannot be found.
I cannot understand why, as the type is declared above with targetNamespace pointing to the NS0 prefix.
Any ideas? Should those type declarations be so complicated?
Aditionally, what's the purpose of this construct:
<xs:schema xmlns:ax22="http://returnobject.foo.bar.com/xsd"
I've read that that declares the prefix "ax22" for further use in child elements. But it isn't being used and it collides with the NS0 namespace.
Thanks for any help
I'm not familiar with your toolset, but I can see one issue that could be causing the problem. First, some baseline:
There are two schemas defined in wsdl:types
. The first one is for the namespace http://returnobject.foo.bar.com/xsd
which contains the type ReturnEnvelope
.
The second schema is for the namespace http://ws.receiver.foo.bar.com
and defines an element setMessageResponse
with type ReturnEnvelope
from the http://returnobject.foo.bar.com/xsd
namespace.
ax22
is not used and unnecessary, but its presence doesn't interfere with ns0
representing the same namespace.
The second schema definition can "see" ns0 because the second schema definition is nested inside wsdl:definitions
where the prefix is defined. However, the second schema can't use the contents of the schema for that namespace (the first schema); they are unconnected siblings. To allow use of another namespace's types, you need to add an xs:import
element to the second schema:
<xs:import namespace="http://returnobject.foo.bar.com/xsd"/>
Depending on the tools you may also have to tell it where that schema lives using schemaLocation
, but hopefully it can figure it out since they're right next to each other.