2010-10-12 91 views
2

我們已經得到了一個.wsdl文件(下面列出),我們將使用它來生成用於我們的應用程序的c#代碼。當我將文件加載到XMLSpy的我收到以下錯誤WSDL定義問題

attribute 'type' in message part 'organisation' (message 'getOrganisationResponse') refers to type 'organisation' which is not defined within the WSDL file! 

它說,它無法找到的類型,但是,這是在該文件的頂部的部分定義的,所以我不知道爲什麼它沒有找到它。

任何幫助,將不勝感激

乾杯

理查德

<?xml version="1.0" encoding="UTF-8"?> 
<definitions 
    xmlns:tns="http://www.xxxx.com/epp/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:ns1="http://xml.apache.org/xml-soap/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    name="Heiq" 
    targetNamespace="http://www.xxxx.com/epp/"> 


    <types> 
    <!-- Organisation object --> 
    <xsd:element name="organisation"> 
    <xsd:complexType> 
    <xsd:sequence> 
    <xsd:element name="id" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="componentID" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="name" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="suburb" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="address1" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="address2" type="xsd:string" minOccurs="0"/> 
    <xsd:element name="postcode" type="xsd:string"/> 
    <xsd:element name="phone" type="xsd:string"/> 
    <xsd:element name="fax" type="xsd:string"/> 
    <xsd:element name="emailAddress" type="xsd:string"/> 
    <xsd:element name="website" type="xsd:string"/> 
    <xsd:element name="contactPersonName" type="xsd:string"/> 
    </xsd:sequence> 
    </xsd:complexType> 
    </xsd:element> 
</types> 


<message name="getOrganisationRequest"> 
    <part name="token" type="xsd:string"/> 
    <part name="organisationID" type="xsd:string"/> 
</message> 

<message name="getOrganisationResponse"> 
    <part name="organisation" type="organisation"/> 
</message> 


    <portType name="xxxxPortType"> 
    <!-- Get organisation function --> 
    <operation name="getOrganisation"> 
    <input message="tns:getOrganisationRequest"/> 
    <output message="tns:getOrganisationResponse"/> 
    </operation> 
</portType> 


<binding name="xxxxBinding" type="tns:xxxxPortType"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <!-- Get organisation function --> 
    <operation name="getOrganisation"> 
    <input> 
    <soap:body use="encoded"  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </input> 
    <output> 
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
    </output> 
    </operation> 
</binding> 


<service name="xxxxService"> 
    <port name="xxxxPort" binding="tns:xxxxBinding"> 
    <soap:address location="http://www.xxxx.com/xxxx/application/soap.php"/> 
    </port> 
</service> 

</definitions> 

回答

2

你的類型聲明下方<types>需要給予自己的命名空間。我猜測你的wsdl的供應商在測試他們編寫的WSDL時使用了非常鬆散的解析器,或者依賴於某些代碼優先的WSDL生成工具來創建此WSDL。在任何一種情況下,都有責任爲你提供一個合適的WSDL和xsd。

這裏是一個WSDL的相關部分應該是什麼樣子的例子 - 在這裏改變名稱空間,如你所願:

<?xml version="1.0" encoding="UTF-8"?> 
<definitions 
    xmlns:tns="http://www.xxxx.com/epp/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:ns1="http://xml.apache.org/xml-soap/" 
    xmlns:types="http://www.xxxx.com/types/"  
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    name="Heiq" 
    targetNamespace="http://www.xxxx.com/epp/"> 


    <types> 
     <xsd:schema targetNamespace="http://www.xxxx.com/types/" 
      xmlns="http://www.w3.org/2001/XMLSchema"> 
     <xsd:complexType name="organisation"> 
      <xsd:sequence> 
       <xsd:element name="id" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="componentID" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="name" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="suburb" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="address1" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="address2" type="xsd:string" minOccurs="0"/> 
       <xsd:element name="postcode" type="xsd:string"/> 
       <xsd:element name="phone" type="xsd:string"/> 
       <xsd:element name="fax" type="xsd:string"/> 
       <xsd:element name="emailAddress" type="xsd:string"/> 
       <xsd:element name="website" type="xsd:string"/> 
       <xsd:element name="contactPersonName" type="xsd:string"/> 
      </xsd:sequence> 
     </xsd:complexType> 
     </xsd:schema> 
    </types> 


    <message name="getOrganisationRequest"> 
     <part name="token" type="xsd:string"/> 
     <part name="organisationID" type="xsd:string"/> 
    </message> 

    <message name="getOrganisationResponse"> 
     <part name="organisation" type="types:organisation"/> 
    </message> 

    ... 
+0

感謝您的幫助。 – PerryW 2010-10-14 11:49:41

+0

我會回到他們希望得到一個更強大的wsdl – PerryW 2010-10-14 11:50:16