2009-12-23 71 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!