2009-12-23 115 views
4

这是this question的后续行动。如何让WCF与此Web服务交谈?

如建议by @Benjamin here,我想为我的wsdl现在添加一个服务引用(而不是web引用)。这里是URL到WSDL问题:

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

的问题是,Visual Studio生成一个空的CodeFile:

//------------------------------------------------------------------------------ 
// <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. 

May这是否也与尝试通过添加Web引用而不是服务引用来使用服务时出现问题有关(请参阅我的other question)?

我想那个wsdl有问题,但我找不到究竟是什么。

由于这是已被其他人使用的第三方服务,我不认为他们会愿意更改他们的服务,那么是否有任何解决方法让.NET与该Web服务通信?

+0

奇特。 http://soapclient.com/soaptest.html在该WSDL上表现完美。我的猜测是某处某处反对标记? – 2009-12-23 20:12:30

+0

如果你仔细观察(查看源代码),带有额外空间的消息显示空间。 – smaclell 2009-12-23 20:25:08

回答

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> 
+0

该死的,我真的一直在找这样的文件,但找不到它,谢谢! – fretje 2009-12-23 20:17:29

+0

对于'dduRollbackRequest'消息也是一个问题。如果您直接用IE打开端点,则不会看到此问题。 – smaclell 2009-12-23 20:21:55

+0

是的,我保存了文件并删除了空格,现在svcutil生成的代码很好。我将不得不在明天工作,如果这将解决其他问题(dduLogin方法==> http://stackoverflow.com/questions/1953132/whats-the-problem-with-this-web-service-method )。我会让你张贴;-) – fretje 2009-12-23 20:31:38

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,只是增加你的应用程序池在有运行任何用户权限。

This is where I found the solution - many thanks!

相关问题