这是this question的后续行动。
根据建议by @Benjamin here,我正在尝试为我的wsdl添加服务引用(而不是Web引用)。这是有问题的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 {
}
当我尝试使用svcutil手动生成代码时,我得到以下内容:
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)?
我猜wsdl有问题,但我找不到确切的内容。
由于这是其他人已经使用过的第三方服务,我认为他们不愿意改变他们的服务,所以有没有办法让.NET与该网络服务对话?
答案 0 :(得分:3)
WSDL中存在一个错误。 dduAbortRequest
消息中的最后一部分在名称末尾有一个空格。这可能只是一个错误。告诉他们,他们会解决它,他们会感谢你告诉他们。
WSDL原样无效。
<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>
答案 1 :(得分:0)
免责声明:这可能不是您问题的直接答案,但我只是浪费了3个小时试图修复同样的错误信息 - 所以我也想在这里发布。
此Warning: No code was generated
错误消息也可能由于C:\Windows\Temp
目录上对应用程序池用户缺乏权限而触发(是的!)。
如果您收到此错误,我建议您在尝试使用“添加服务引用”对话框时切换到命令行。运行此命令,打开Fiddler作为服务URL。
svcutil.exe https://dev.example.com/ShoppingCartWS/WCF/ShoppingCartWCF.svc?wsdl
如果您看到任何请求以500(红色)和以下响应返回:
ReadResponse() failed: The server did not return a response for this request.
然后检查C:\Windows\Temp
,只需添加运行应用程序池的任何用户即可获得权限。