开发者

Cannot consume WSDL in VS2010

开发者 https://www.devze.com 2023-02-19 06:48 出处:网络
I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the WSDL.

I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the 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.

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

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://schem开发者_运维技巧as.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. My situation was slightly different, but it's worth a try.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消