【问题标题】:Cannot consume WSDL in VS2010VS2010不能消费WSDL
【发布时间】:2011-03-24 15:56:03
【问题描述】:

我正在尝试在 VS2010 中使用以下 WSDL,但遇到了似乎特定于 WSDL 的错误。

我将它添加为 Web 服务参考,最初没有创建任何代理类或任何东西 - 向导成功完成,但是我在项目的 ~/Web References/ 下获得了一个 .wsdl 和一个 Reference.map 文件该服务在代码中不可用。

如果我对其执行“更新 Web 引用”,我会收到以下错误:

Custom tool error: Unable to import WebService/Schema. The element attribute is not allowed on encoded message parts. The erroneous part is named 'textReturnObject' in message 'singleTextResponse'. (File: Reference.map line 1 column 1)

如果我尝试将“元素”重命名为“类型”,我会遇到一大堆其他问题:

The custom tool 'MSDiscoCodeGenerator' failed.  Cannot find definition for http://schemas.xmlsoap.org/wsdl/:exampleServiceNameBinding.  Service Description with namespace http://schemas.xmlsoap.org/wsdl/ is missing.
Parameter name: name

任何人都可以对此有所了解吗?我已经通过一些在线工具将 WSDL 放入其中,他们可以很好地使用它 - VS2010 对某些类型的 WSDL 有问题吗?

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/exampleServiceName" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="exampleServiceName" targetNamespace="http://www.example.com/exampleServiceName" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <xsd:complexType name="exampleType">
    <sequence>
      <element minOccurs="1" maxOccurs="1" name="title" type="string" />
      <element minOccurs="1" maxOccurs="1" name="url" type="string" />
      <element minOccurs="1" maxOccurs="1" name="description" type="string" />
    </sequence>
  </xsd:complexType>
  <wsdl:types />
  <wsdl:message name="singleTextRequest">
    <wsdl:part name="intIdentity" type="xsd:integer" />
  </wsdl:message>
  <wsdl:message name="singleTextResponse">
    <wsdl:part name="textReturnObject" element="wsdl:exampleType" />
  </wsdl:message>
  <wsdl:portType name="exampleServiceNamePortType">
    <wsdl:operation name="singleTextAdvert">
      <wsdl:input message="tns:singleTextRequest" />
      <wsdl:output message="tns:singleTextResponse" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="exampleServiceNameBinding" type="tns:exampleServiceNamePortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
    <wsdl:operation name="singleText">
      <soap:operation soapAction="urn:xmethods-delayed-quotes#singleText" />
      <wsdl:input>
        <soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="exampleServiceNameService">
    <wsdl:port name="exampleServiceNamePort" binding="wsdl:exampleServiceNameBinding">
      <soap:address location="http://www.example.com/exampleServiceName/Server.php" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

【问题讨论】:

    标签: c# soap wsdl


    【解决方案1】:

    我有一个关于添加服务参考的问题。我最终按照建议使用了 svcutil,它解决了问题。我的情况略有不同,但值得一试。

    .net web service: Can't add service reference, only web reference

    【讨论】:

    • 酷,我去看看!
    【解决方案2】:

    是的,VS2010 不能从某些 WSDL 中创建 Web 服务引用。必须为那些编写自定义包装器。或者以某种方式编辑您的 WSDL,以便 VS 可以使用它。例如,如果这些引用给您带来麻烦,您可以删除您不打算使用的方法的 Web 服务方法引用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-03
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 2018-01-20
      • 2018-06-04
      相关资源
      最近更新 更多