为什么在C#中导入WSDL文档会出现错误,但在SoapUI中可以工作?

时间:2019-02-13 22:31:32

标签: c# wsdl

我正在尝试将以下WDSL导入C#中的项目中(试图添加Web参考)

<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="urn:ServiceQualification" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:ServiceQualification" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema targetNamespace="urn:ServiceQualification">
      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
      <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
      <xsd:complexType name="ServiceQualificationRequest">
        <xsd:all>
          <xsd:element name="unit_no" type="xsd:string"/>
          <xsd:element name="house_no" type="xsd:string"/>
          <xsd:element name="lot_no" type="xsd:string"/>
          <xsd:element name="street_name" type="xsd:string"/>
          <xsd:element name="street_type" type="xsd:string"/>
          <xsd:element name="suburb" type="xsd:string"/>
          <xsd:element name="state_name" type="xsd:string"/>
          <xsd:element name="postcode" type="xsd:string"/>
        </xsd:all>
      </xsd:complexType>
      <xsd:complexType name="PortUtilisation">
        <xsd:all>
          <xsd:element name="port_no" type="xsd:integer"/>
          <xsd:element name="product_type" type="xsd:string"/>
        </xsd:all>
      </xsd:complexType>      
      <xsd:complexType name="PortUtilisation_Array">
        <xsd:complexContent>
          <xsd:restriction base="SOAP-ENC:Array">
            <xsd:element name="PortUtilisation" type="tns:PortUtilisation"/>
            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:PortUtilisation[]" xmlns:wsdl1="http://schemas.xmlsoap.org/wsdl/"/>
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>
      <xsd:complexType name="ServiceQualificationResponse">
        <xsd:all>
          <xsd:element name="status_code" type="xsd:string"/>
          <xsd:element name="property_id" type="xsd:string"/>
          <xsd:element name="unit_no" type="xsd:string"/>
          <xsd:element name="house_no" type="xsd:string"/>
          <xsd:element name="lot_no" type="xsd:string"/>
          <xsd:element name="street_name" type="xsd:string"/>
          <xsd:element name="street_type" type="xsd:string"/>
          <xsd:element name="suburb" type="xsd:string"/>
          <xsd:element name="state_name" type="xsd:string"/>
          <xsd:element name="postcode" type="xsd:string"/>
          <xsd:element name="estate_name" type="xsd:string"/>
          <xsd:element name="stage" type="xsd:string"/>
          <xsd:element name="property_class" type="xsd:string"/>
          <xsd:element name="port_utilisation" type="tns:PortUtilisation_Array"/>
        </xsd:all>
      </xsd:complexType>
      <xsd:complexType name="ServiceQualificationResponse_Array">
        <xsd:complexContent>
          <xsd:restriction base="SOAP-ENC:Array">
            <xsd:element name="ServiceQualificationResponse" type="tns:ServiceQualificationResponse"/>
            <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:ServiceQualificationResponse[]" xmlns:wsdl1="http://schemas.xmlsoap.org/wsdl/"/>
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>
    </xsd:schema>
  </types>
  <message name="AddressSearchRequest">
    <part name="property" type="tns:ServiceQualificationRequest"/>
  </message>
  <message name="AddressSearchResponse">
    <part name="return" type="tns:ServiceQualificationResponse_Array"/>
  </message>
  <portType name="ServiceQualificationPortType">
    <operation name="AddressSearch">
      <documentation>This interface provides for property search including service qualification</documentation>
      <input message="tns:AddressSearchRequest"/>
      <output message="tns:AddressSearchResponse"/>
    </operation>
  </portType>
  <binding name="ServiceQualificationBinding" type="tns:ServiceQualificationPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="AddressSearch">
      <soap:operation soapAction="urn:ServiceQualification#AddresSsearch" style="rpc"/>
      <input>
        <soap:body use="encoded" namespace="urn:ServiceQualification" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
        <soap:body use="encoded" namespace="urn:ServiceQualification" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
    </operation>
  </binding>
  <service name="ServiceQualification">
    <port name="ServiceQualificationPort" binding="tns:ServiceQualificationBinding">
      <soap:address location="http://x.x.x.x:p/components/com_soapxml/SQ.php"/>
    </port>
  </service>
</definitions>

但是,我遇到了错误

WSDL Parsing Error while reading: 'ServiceQualification_1.wsdl' verify that the XML is both well-formed and valid.

There is an error in XML document (28, 77).

The element was not expected in this context: <xsd:element xmlns:xsd='http://www.w3.org/2001/XMLSchema'>..</xsd:element>. Expected elements: http://www.w3.org/2001/XMLSchema:annotation, http://www.w3.org/2001/XMLSchema:choice, http://www.w3.org/2001/XMLSchema:group, http://www.w3.org/2001/XMLSchema:all, http://www.w3.org/2001/XMLSchema:sequence, http://www.w3.org/2001/XMLSchema:attributeGroup, http://www.w3.org/2001/XMLSchema:attribute, http://www.w3.org/2001/XMLSchema:anyAttribute.

错误消息所指向的行是:

<xsd:element name="PortUtilisation" type="tns:PortUtilisation"/>

任何人都可以建议WSDL文档出什么问题吗?

我尝试将其导入SoapUI,并且可以正常工作。

0 个答案:

没有答案