C# 为什么这个WSDL文件在VS2008中会生成一个空的服务代理?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/757990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does this WSDL file generate an empty service proxy in VS2008?
提问by TheSoftwareJedi
Why does this WSDL filegenerate an empty service proxy in VS2008?
为什么这个WSDL文件在VS2008中会生成一个空的服务代理?
If you look at the Reference.cs file generated, it's empty. Any ideas?
如果您查看生成的 Reference.cs 文件,它是空的。有任何想法吗?
采纳答案by Randolpho
Have you read your error list? I got the following:
你读过你的错误列表吗?我得到以下信息:
Custom tool warning: There was a validation error on a schema generated during export:
Source:
Line: 144 Column: 12
Validation Error: Wildcard '##any' allows element 'http://search.yahoo.com/mrss:text', and causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.
Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Cannot import invalid schemas. Compilation on the XmlSchemaSet failed.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://fliqz.com/services/search/20071001']/wsdl:portType[@name='IVideoSearchService']
Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://fliqz.com/services/search/20071001']/wsdl:portType[@name='IVideoSearchService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='basicHttpBinding_IVideoSearchService_20071001']
Custom tool warning: 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='basicHttpBinding_IVideoSearchService_20071001']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='VideoSearchService']/wsdl:port[@name='basicHttpBinding_IVideoSearchService_20071001']
Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details.
Edit:I did some digging, and I came across the following links:
编辑:我做了一些挖掘,我发现了以下链接:
I tried following the instructions by ScottAnderson in the first link, but was unable to generate a client proxy with them. Perhaps you can have better luck.
我尝试按照 ScottAnderson 在第一个链接中的说明进行操作,但无法使用它们生成客户端代理。也许你可以有更好的运气。
It appears the reasonthis doesn't work is because Fliqz is using XmlSerializer rather than DataContract/MessageContract for its contract definitions, and WCF doesn't want to play nicely with them and generates inappropriate WSDL. If you could control the original contract, you could probably fix the issue and be on your way; unfortunately, you may be entirely out of luck.
看起来这不起作用的原因是因为 Fliqz 使用 XmlSerializer 而不是 DataContract/MessageContract 作为其合同定义,并且 WCF 不想很好地使用它们并生成不合适的 WSDL。如果您可以控制原始合同,那么您可能可以解决问题并继续前进;不幸的是,您可能完全不走运。
If you can get the ServiceContract interface and the types it exposes, you might be able to generate your own client by hand. Judging by some of the class names I see in there, it appears that Fliqz is exposing internal objects in their contract, so I doubt you could, you know, call them up and ask them for a .dll you can reference.
如果您可以获得 ServiceContract 接口及其公开的类型,您或许可以手动生成您自己的客户端。从我在那里看到的一些类名来看,Fliqz 似乎在他们的合同中公开了内部对象,所以我怀疑你是否可以打电话给他们并要求他们提供可以引用的 .dll。
You could try to write out the interface and data / message contract types yourself by analyzing the WSDL and XSDs. Looks like it'd be a lot of work, though.
您可以尝试通过分析 WSDL 和 XSD 自己写出接口和数据/消息合同类型。不过,看起来这将是很多工作。
Sorry I can't help more. This seems to be a combination of poor WCF legacy support and poor architecture/design on the part of Fliqz.
对不起,我帮不上忙了。这似乎是 Fliqz 方面糟糕的 WCF 遗留支持和糟糕的架构/设计的结合。
回答by Alan
Try adding it as .NET 2.0 Web Reference.
尝试将其添加为 .NET 2.0 Web 参考。
Go to Add Service Reference, then click the "Advanced" button. Then you're given to option to add it as a .NET 2.0 Web Reference. I did this, and got it to work. I couldn't via the standard "Add Service Reference"
转到添加服务引用,然后单击“高级”按钮。然后您可以选择将其添加为 .NET 2.0 Web 参考。我做到了这一点,并让它发挥作用。我无法通过标准的“添加服务引用”
回答by marc_s
I don't see any <wsdl:portType> elements in your WSDL - that might be the problem.
我在您的 WSDL 中没有看到任何 <wsdl:portType> 元素 - 这可能是问题所在。
Also, are you creating your service from a live URL, or some files on disk? If you're using "on disk" files: did you also get the "wsdl0" file as referenced in this line here:
另外,您是从实时 URL 还是磁盘上的某些文件创建服务?如果您使用的是“磁盘上”文件:您是否还获得了此行中引用的“wsdl0”文件:
<wsdl:import namespace="http://fliqz.com/services/search/20071001" location="http://services.fliqz.com/LegacyServices/Services/search/R20071001/service.svc?wsdl=wsdl0"/>
<wsdl:import namespace="http://fliqz.com/services/search/20071001" location="http://services.fliqz.com/LegacyServices/Services/search/R20071001/service.svc?wsdl=wsdl0"/>
Marc
马克
回答by walaa waref
right click on service reference , cofigure , un-check “Reuse types in referenced assembles” and click OK. Try to Update Service Reference. This worked for me!
右键单击服务引用,配置,取消选中“Reuse types in referenced assembles”,然后单击“确定”。尝试更新服务参考。这对我有用!