在不同的子类的命名空间均出现在WSDL顶级子类、出现在、不同、空间

2023-09-06 09:30:02 作者:喜风

我创建与各种类,其中许多可以包含对其他类的web服务。有时,这些子类具有相同的名称(例如,客户和客户),但实际上却是不同的,所以我在不同的命名空间中放置这些(如MyRoot.Sub1,MyRoot.Sub2,等等。)

I'm creating a web service with a variety of classes, many of which can contain references to other classes. Sometimes these "sub classes" have the same name (e.g. Customer and Customer), but are actually different, so I've placed these in different namespaces (e.g. MyRoot.Sub1, MyRoot.Sub2, etc.)

当我生成服务,生成的WSDL将所有这些类的顶层,没有按子命名空间指定任何描述。因此,它定义了两个版本的客户。奇怪的是,它不会在编译过程中抱怨。

When I build the service, the generated WSDL places all of these classes at the top level, without specifying any delineation by sub-namespace. Therefore, it will define two versions of "Customer". Curiously, it doesn't complain during the build process.

在我的主机服务,并尝试引用它的浏览器,我得到以下错误:

When I host the service and try to reference it with a browser, I get the following error:

从上面的XML元素客户的   命名空间RE:HTTP:// ......引用的   不同类型的MyRoot.Sub1.Customer 的   和MyRoot.Sub2.Customer。使用XML 的   属性来指定另一个XML名称的   或命名空间的元素或类型。的

The top XML element 'Customer' from namespace 'RE: http://...' references distinct types MyRoot.Sub1.Customer and MyRoot.Sub2.Customer. Use XML attributes to specify another XML name or namespace for the element or types.

我的样子,我可以用XmlTypeAttribute类型名,以提供一个独特的类名,但是这使得文档相当麻烦,因为一切都将有两个名字。考虑到差异化已经指定的命名空间,有没有什么办法来利用这些信息?使用类型名=Sub1.Customer,等等。我还没有尝试过,但没有,我已经看到使用这种表示法的例子,所以我持怀疑态度。

I looks like I could use XmlTypeAttribute TypeName to provide an unique class name, but this makes documentation quite a hassle, as everything's going to have two names. Considering the differentiation is already specified by the namespaces, is there any way to utilize that information? I haven't tried using TypeName="Sub1.Customer", etc., but none of the examples that I've seen use this notation, so I'm skeptical.

有没有别的明显,我失踪?

Is there something else obvious that I'm missing?

推荐答案

SOAP不支持分层命名空间,所以我决定了,只有两种解决方法:

SOAP doesn't support hierarchical namespaces, so I've determined that there are only two solutions:

确保不同类所有方法唯一命名的Web服务 打破单一的Web服务为多种服务,使每个人都有自己独特的隐含的命名空间的

由于后者选项需要更多的政府(无论是在code,并在IIS),我决定给班级唯一的名称。我可能还是以分手服务成倍数(用于组织或负载处理),但这是可选的,如果类名是唯一的。

Since the latter option requires more administration (both in the code and within IIS), I decided to give the classes unique names. I may still end up breaking the service into multiples (for organization or load handling), but that's optional if the class names are unique.