2011-03-21 37 views
0

我正在嘗試生成ServiceClient類。生成wcf ServiceClients,引用問題

我有2個項目,API和WEB。 API項目包含ClassLibrary和DataContracts/Interface類文件。我有一個擁有SVC文件的網站。 WEB引用API項目。

當我生成服務端類,它們的API項目

這裏產生是我有問題

我SvcUtil工具命令行包括/參考:[API的全位置/bin/debug/API.dll]。它與API項目的構建輸出路徑相同。

當我使用該/ Reference運行SvcUtil命令時,生成失敗,我看到下面的消息摘要摘要。

Attempting to download metadata from 
'http://id.unittest/Services/EchoService.svc?wsdl' 
using WS-Metadata Exchange or DISCO. 
Error: Cannot import wsdl:binding 
Detail: Cannot locate operation IsSubscribed in Contract IEchoService. 
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/'] 
/wsdl:binding[@name='WSHttpBinding_IEchoService'] 


Error: Cannot import wsdl:port 
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent 
on. 
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/'] 
/wsdl:binding[@name='WSHttpBinding_IEchoService'] 
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/'] 
/wsdl:service[@name='EchoService']/wsdl:port[@name='WSHttpBinding_IEchoService'] 


Generating files... 
Warning: No code was generated. 
If you were trying to generate a client, this could be because the metadata documents 
did not contain any valid contracts or services 
or because all contracts/services were discovered to exist in /reference assemblies. 
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. 

當我刪除/引用,生成成功,但生成方法params中使用的實體類的重複集合生成。當我嘗試構建我的API項目時,出現錯誤,表明存在重複的類名稱,並且我應該將它們更改爲部分。所以,不要和需要那些額外的類。

希望我已經提供了足夠的信息。謝謝。

回答

2

的解決方案是將以下開關添加到SvcUtil工具命令 /serializer:DataContractSerializer /serializable

參考網址:MSDN forum

+0

蕩,我需要的是......這個WSDL的東西是什麼是痛苦。多謝,夥計。 – Brian 2016-04-23 09:45:01