【问题标题】:Error creating a proxy class from a WSDL. Element missing?从 WSDL 创建代理类时出错。缺少元素?
【发布时间】:2012-02-06 15:49:44
【问题描述】:

我承认我对 WSDL 很无知。我为我正在处理的项目提供了以下 WSDL,但它不起作用。这是我正在使用的 WSDL 的帖子。我被要求从 wsdl 中删除服务的实际 URL,以便它不会被爬虫索引和命中。实际 URL 已替换为“www.testsite.org”。这是 XML:

<wsdl:definitions xmlns:tns="https://www.testsite.org/uiws-test" 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="http://schemas.xmlsoap.org/wsdl/" name="uiicon" targetNamespace="https://www.testsite.org/uiws-test">
<!-- TYPES -->
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="https://www.testsite.org/uiws-test">
<xsd:complexType name="ResponseType">
<xsd:sequence>
<xsd:element name="request_id" type="xsd:string"/>
<xsd:element name="messages" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="responseType" type="tns:ResponseType"/>
<xsd:element name="ICON_MessageTrain" type="xsd:string"/>
<xsd:element name="fault" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<!-- MESSAGES -->
<wsdl:message name="RequestMessage">
<wsdl:part name="ICON_MessageTrain" element="tns:ICON_MessageTrain"/>
</wsdl:message>
<wsdl:message name="ResponseMessage">
<wsdl:part name="response" element="tns:responseType"/>
</wsdl:message>
<wsdl:message name="FaultMessage">
<wsdl:part name="fault" element="tns:fault"/>
</wsdl:message>
<wsdl:message name="SourceHeader">
<wsdl:part name="source" element="xsd:string"/>
</wsdl:message>
<wsdl:message name="ApplicationHeader">
<wsdl:part name="application" element="xsd:string"/>
</wsdl:message>
<!-- PORT TYPES -->
<wsdl:portType name="uiicon_portType">
<wsdl:operation name="uiicon">
<wsdl:input message="tns:RequestMessage"/>
<wsdl:output message="tns:ResponseMessage"/>
<wsdl:fault message="tns:FaultMessage" name="FaultMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- BINDINGS -->
<wsdl:binding name="uiicon_binding" type="tns:uiicon_portType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="uiicon">
<soap:operation soapAction="https://www.testsite.org/uiws-test/services/uiicon-test" style="document"/>
<wsdl:input>
<soap:header part="source" message="tns:SourceHeader" use="literal"/>
<soap:header part="application" message="tns:ApplicationHeader" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="FaultMessage">
<soap:fault name="FaultMessage" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<!-- SERVICES -->
<wsdl:service name="uiicon_service">
<wsdl:documentation>
This is the web service for UI-ICON data exchange modernization project
</wsdl:documentation>
<wsdl:port name="uiicon_port" binding="tns:uiicon_binding">
<soap:address location="https://www.testsite.org/uiws-test/services/uiicon-test"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

当我在 wsdl.exe 中运行它时,我收到以下错误:

  • 无法导入操作“uiicon”。
  • 缺少“http://www.w3.org/2001/XMLSchema:string”元素

我看到 wsdl 在哪里引用 w3.org 2001 架构,并且我看到了字符串架构引用。只是不确定它应该是什么样子以及为什么它是错误的。谢谢!

【问题讨论】:

    标签: xml web-services wsdl


    【解决方案1】:

    如果您在 SourceHeaderApplicationHeader 引用中将 element 更改为 type,则 WSDL 有效,即:

    <wsdl:message name="ApplicationHeader">
        <wsdl:part name="application" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="SourceHeader">
        <wsdl:part name="source" type="xsd:string"/>
    </wsdl:message>
    

    使用element,您可以引用预定义的简单或复杂类型。然而,在这里您定义了一个类型为xsd:string 的新元素(称为应用程序/源)。因此,您需要使用type

    据我所知,您只需要一个名为 application 的消息部分,其中包含一个字符串。修复应该使这项工作和 WSDL 是有效的。我不能保证实际的 Web 服务会接受/发送什么,因为它的描述是无效的,但是......

    【讨论】:

    • 谢谢!我将此信息发回给服务提供商,并且已经进行了更新,似乎可以正常工作。
    • 很高兴听到,我很高兴能帮上忙!
    【解决方案2】:

    我认为这并不像公认的答案所说的那样简单。

    根据我对WSDL 1.1 spec, section 2.3.1 Message Parts 的阅读,此 WSDL 应该是有效的。

    据我了解,确定是否应该使用元素或类型的关键项目之一是基于绑定样式 - rpc 与文档,文字与编码。 An answer to a similar question 更详细,article that the answer references 也是如此。

    由于此 WSDL 确实使用了文档/文字绑定,因此在我看来使用元素而非类型是正确的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 1970-01-01
      • 2010-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      相关资源
      最近更新 更多