Hi,
When put below wsdl into my VS2010 project I got a "Type 'urn:listing3:Phone' is not declared." error. Looks like the xsd:import doesn't work, why?
<?xml version="1.0" ?>
<wsdl:definitions targetNamespace="urn:listing2"
xmlns:tns="urn:listing2"
xmlns:listing3="urn:listing3"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="urn:listing3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>
<xsd:complexType name="Phone">
<xsd:sequence>
<xsd:element name="areaCode" type="xsd:int"/>
<xsd:element name="exchange" type="xsd:int"/>
<xsd:element name="number" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema targetNamespace="urn:listing2"
xmlns:listing3="urn:listing3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="urn:listing3"/>
<xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element name="streetNum" type="xsd:int"/>
<xsd:element name="streetName" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="phone" type="listing3:Phone"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetAddressRequest">
<wsdl:part name="name" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="GetAddressResponse">
<wsdl:part name="address" type="tns:Address"/>
</wsdl:message>
<wsdl:message name="GetPhoneRequest">
<wsdl:part name="name" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="GetPhoneResponse">
<wsdl:part name="phone" type="listing3:Phone"/>
</wsdl:message>
<wsdl:portType name="AddressBook">
<wsdl:operation name="getAddress">
<wsdl:input message="tns:GetAddressRequest"/>
<wsdl:output message="tns:GetAddressResponse"/>
</wsdl:operation>
<wsdl:operation name="getPhone">
<wsdl:input message="tns:GetPhoneRequest"/>
<wsdl:output message="tns:GetPhoneResponse"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
The error is, type Phone is declared in namespace listing3, the namespace is also imported in namespace listing2 using <xsd:import>
, but type Phone cannot be referenced in listing2. The error message is "Type 'urn:listing3:Phone' is not declared".
Update:
The wsdl was generated automatically by VS2010 when adding the Java web service as a web reference. The wsdl I posted here actually is not the real wsdl but a fake one for security reason. But the structure of both wsdl and the error messages are almost same.