The best I could come up with is generating proxies programmatically and detecting duplicates via CodeDOM, ignoring DataContract/WebServiceBinding namespaces, but it's a huge mess...[WebService(Namespace = "http://tempuri.org/FOO1")]public class Service1 : WebService{ [WebMethod] public Foo GetFoo() { return new Foo(); }}[WebService(Namespace = "http://tempuri.org/FOO2")]public class Service2 : WebService{ [WebMethod] public void SetFoo(Foo foo) { }}public class Foo{ public int Bar { get; set; }}推荐答案在添加您的两个网络引用后:after adding your two web references:双击第二个 Web 服务引用在对象浏览器中导航到 Foo 的定义右键单击 Foo 并选择转到定义删除 Foo 类的定义为 webservice one 的命名空间添加 using 语句查找并替换 .Foo 的所有实例,并仅使用 Foodouble click on the second web service referencein the object browser navigate to the definition of Fooright click on Foo and choose go to definitiondelete the definition for the class Fooadd a using statement for the namespace of webservice one find and replace all instances of <namespace-of-service-reference-2>.Foo with just Foo这应该可以解决您的问题,因为它会强制两个服务引用的自动生成代码使用相同的类声明.This should fix your problem as it forces the autogenerated code for both service references to use the same class declaration. 这篇关于在没有 XSD 的情况下共享 WSDL 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 05:40