在没有 XSD 的情况下共享 WSDL 类型 [英] Sharing WSDL types without XSD

查看:43
本文介绍了在没有 XSD 的情况下共享 WSDL 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到从具有共享类型但没有任何 XSD 伴随它们的 WSDL 生成代理的示例.任何人都可以将其标记为重复并指出一个示例吗?

I can't seem to find an example of generating proxies from WSDLs with shared types but without having any XSDs to go along with them. Can anyone please mark this as duplicate and point me to an example please?

这里有 2 个服务,每个都有自己的命名空间和一个公共类型.唯一可以公开访问的是他们的 WSDL,没有类型的 XSD 或其 .dll 可以传递给 wsdl.exe/sharedtypessvcutils 没有它我最终具有相同的 class Foo,我无法传递给 SetFooclass Foo1.

Here are 2 services, each has its own namespace and a common type. The only thing that is publicly accessible are their WSDLs, there is no type's XSD or its .dll to pass to wsdl.exe /sharedtypes or svcutils and without it I end up with identical class Foo that I can't pass in to SetFoo and class Foo1.

我能想到的最好的方法是以编程方式生成代理并通过 CodeDOM 检测重复项,忽略 DataContract/WebServiceBinding 命名空间,但这是一个巨大的混乱......

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:

  1. 双击第二个 Web 服务引用
  2. 在对象浏览器中导航到 Foo 的定义
  3. 右键单击 Foo 并选择转到定义
  4. 删除 Foo 类的定义
  5. 为 webservice one 的命名空间添加 using 语句
  6. 查找并替换 .Foo 的所有实例,并仅使用 Foo
  1. double click on the second web service reference
  2. in the object browser navigate to the definition of Foo
  3. right click on Foo and choose go to definition
  4. delete the definition for the class Foo
  5. add a using statement for the namespace of webservice one
  6. 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 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆