代码之家  ›  专栏  ›  技术社区  ›  fretje

如何使WCF与此web服务对话?

  •  4
  • fretje  · 技术社区  · 16 年前

    这是一个后续行动 this question .

    按照建议 by @Benjamin here

    https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl

    问题在于Visual Studio生成了一个空代码文件:

    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:2.0.50727.3603
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    namespace test.ServiceReference1 {
    
    }
    

    C:\temp>svcutil https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
    Copyright (c) Microsoft Corporation.  All rights reserved.
    
    Attempting to download metadata from 'https://eu.link.fiatauto.com/tsi/DDUWsAut.
    php?wsdl' using WS-Metadata Exchange or DISCO.
    Error: Cannot import wsdl:portType
    Detail: An exception was thrown while running a WSDL import extension: System.Se
    rviceModel.Description.XmlSerializerMessageContractImporter
    Error: The ' ' character, hexadecimal value 0x20, cannot be included in a name.
    Parameter name: name
    XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:portT
    ype[@name='dduPortType']
    
    
    Error: Cannot import wsdl:binding
    Detail: There was an error importing a wsdl:portType that the wsdl:binding is de
    pendent on.
    XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:port
    Type[@name='dduPortType']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:bindi
    ng[@name='dduBinding']
    
    
    Error: Cannot import wsdl:port
    Detail: There was an error importing a wsdl:binding that the wsdl:port is depend
    ent on.
    XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:bindi
    ng[@name='dduBinding']
    XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:ddu']/wsdl:servi
    ce[@name='ddu']/wsdl:port[@name='dduPort']
    
    
    Generating files...
    Warning: No code was generated.
    If you were trying to generate a client, this could be because the metadata docu
    ments did not contain any valid contracts or services
    or because all contracts/services were discovered to exist in /reference assembl
    ies. Verify that you passed all the metadata documents to the tool.
    
    Warning: If you would like to generate data contracts from schemas make sure to
    use the /dataContractOnly option.
    

    也许这也与这样一个事实有关,即当试图通过添加web引用而不是服务引用来使用服务时出现问题(请参阅我的 other question )?

    由于这是一个已经被其他人使用的第三方服务,我认为他们不会愿意改变他们的服务,所以有没有什么办法让.NET与该web服务对话?

    2 回复  |  直到 9 年前
        1
  •  3
  •   John Saunders    16 年前

    WSDL中有一个bug。文章的最后一部分 dduAbortRequest

    <message name="dduAbortRequest">
        <part name="Ticket" type="xsd:string"/>
        <part name="ServiceId" type="xsd:string"/>
        <part name="LoginId" type="xsd:string"/>
        <part name="DocId " type="xsd:string"/> <!-- Should be "DocId" -->
    </message>
    
        2
  •  0
  •   Simon_Weaver    15 年前

    免责声明:这可能不是对您问题的直接回答,但我只是浪费了3个小时试图修复相同的错误消息-所以我也想在这里发布。


    Warning: No code was generated 错误消息也可能因缺少对应用程序池用户在应用程序上的权限而触发 C:\Windows\Temp 目录(是的,真的!)。

     svcutil.exe https://dev.example.com/ShoppingCartWS/WCF/ShoppingCartWCF.svc?wsdl
    

    ReadResponse() failed: The server did not return a response for this request.                                                                            
    

    然后检查 C:\Windows\Temp 只需添加您的应用程序池正在运行的任何用户即可获得权限。

    This is where I found the solution - many thanks! .