生成wcf ServiceClients,参考问题
我正在尝试生成 ServiceClient 类。
我有 2 个项目,API 和 WEB。 API 项目包含 ClassLibrary 和 DataContracts/Interface 类文件。我有一个包含 SVC 文件的网站。 WEB引用API项目。
当我生成服务客户端类时,它们在 API 项目中生成
这是我遇到的问题
我的 SvcUtil 命令行包括 /Reference: [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.
当我删除 /reference 时,生成成功,但生成了方法参数中使用的一组重复的实体类。当我尝试构建 API 项目时,收到一条错误,指出存在重复的类名称,我应该将它们更改为部分名称。所以,不想要也不需要那些额外的课程。
希望我提供了足够的信息。谢谢。
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 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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是将以下开关添加到 svcutil 命令中
/serializer:DataContractSerializer /serializes
参考网址:MSDN 论坛
The solution was to add the following switches to the svcutil command
/serializer:DataContractSerializer /serializable
Reference url: MSDN forum