简体   繁体   English

无法在VS2010中使用WSDL

[英]Cannot consume WSDL in VS2010

I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the WSDL. 我试图在VS2010中使用以下WSDL,而Im遇到了似乎特定于WSDL的错误。

I am adding it as a Web Service Reference, and initially no proxy classes or anything are created - the wizard completes successfully and I get a .wsdl and a Reference.map file under ~/Web References/ in the project, however the service is unavailable in code. 我将其添加为Web服务引用,并且最初未创建任何代理类或任何内容-向导成功完成,并且在项目中的〜/ Web References /下获得了.wsdl和Reference.map文件,但是该服务是在代码中不可用。

If I do an "Update Web Reference" on it, I get the following error: 如果对它执行“更新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)

If I try and rename "element" to "type" i get a whole bunch of other issues: 如果我尝试将“ element”重命名为“ type”,则会遇到很多其他问题:

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

Can anyone shed any light on it? 任何人都可以阐明它吗? I've put the WSDL through some online tools and they consume it fine - does VS2010 have an issue with certain types of WSDL? 我已经通过一些在线工具使用了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>

I have a question on SO where I had trouble adding a service reference. 我对在添加服务引用时遇到困难的问题有疑问。 I ended up using svcutil as recommended and it solved the problem. 我最终按照建议使用svcutil,它解决了问题。 My situation was slightly different, but it's worth a try. 我的情况略有不同,但是值得一试。

.net web service: Can't add service reference, only web reference .net Web服务:无法添加服务引用,只能添加网络引用

Yes, VS2010 can't create a web service reference from some WSDLs. 是的,VS2010无法通过某些WSDL创建Web服务引用。 Have to write custom wrapper for those. 必须为这些编写自定义包装。 OR edit your WSDL in a way so VS can consume it. 或以某种方式编辑WSDL,以便VS可以使用它。 For example it may be ok for you to remove web service method references for the methods that you are not planning to use if those references create trouble for you. 例如,如果您不打算使用这些方法的Web服务方法引用给您带来麻烦,则可以删除它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM