开发者

Generating wcf ServiceClients, reference problem

I am trying to generate ServiceClient classes.

I have 2 Projects, API and WEB. The API project contains both ClassLibrary and DataContracts/Interface class files. I have a website which has the SVC files. WEB references the API project.

When I to generate the the Service Client classes, they generate in the API project

Here is the problem I am having

My SvcUtil command line includes /Reference: [full location of API /bin/debug/API.dll ]. It is the same path as the build output from the API project.

When I run the SvcUtil command with that /Reference, the generation fails and I see the following cutdown summary of messages.

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 clie开发者_JAVA技巧nt, 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.

When I remove the /reference, the generation succeeds, but a duplicate set of entity classes that were used in the methods params are generated. When I try to build my API project, I get an error that there are duplicate classes names and that I should change them to partial. So, dont want and need those extra classes.

Hopefully I have provided enough information. Thanks.


The solution was to add the following switches to the svcutil command /serializer:DataContractSerializer /serializable

Reference url: MSDN forum

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜