无法在 VS2010 中使用 WSDL [英] Cannot consume WSDL in VS2010

查看:35
本文介绍了无法在 VS2010 中使用 WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the WSDL.

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

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 参考",则会出现以下错误:

If I do an "Update Web Reference" on it, I get the following error:

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:

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 有问题?

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?

<?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>

推荐答案

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

Yes, VS2010 can't create a web service reference from some WSDLs. Have to write custom wrapper for those. OR edit your WSDL in a way so VS can consume it. 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.

这篇关于无法在 VS2010 中使用 WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆