简体   繁体   English

一个具有不同 XSD/WSDL 版本的 WCF 服务

[英]One WCF Service with different XSD/WSDL versions

I have a problem where I can't find a good solution.我有一个问题,我找不到一个好的解决方案。 Maybe someone can help me.也许有人可以帮助我。

There is a WCF service and it was created years ago.有一个 WCF 服务,它是多年前创建的。 Now an adjustment has to be made.现在必须进行调整。 Here is the scenario:这是场景:

Example WCF CarService.svc.示例 WCF CarService.svc。 This WCF has a generated class CarV1.cs which was created from a Car WSDL (v1) with svcutil.exe.此 WCF 具有生成的 class CarV1.cs,它是从带有 svcutil.exe 的汽车 WSDL (v1) 创建的。 Thus, this CarV1.cs contains several classes and properties.因此,这个 CarV1.cs 包含几个类和属性。 In the CarV1.cs there is also an interface CarIdentification which is derived in the CarService.svc.cs.在 CarV1.cs 中还有一个接口 CarIdentification,它是在 CarService.svc.cs 中派生的。 So far so good.到目前为止,一切都很好。 Now there is a new version of the Car WSDL (v2).现在有新版本的汽车 WSDL (v2)。 I have also generated a class CarV2.cs from the WSDL with svcutil.exe.我还使用 svcutil.exe 从 WSDL 生成了 class CarV2.cs。 Now I have two generated.cs (one v1 and one v2).现在我有两个 generate.cs(一个 v1 和一个 v2)。 Apart from a few adjustments (new classes and a few classes have been renamed), the rest is identical in v2, ie the class names and names of the properties as well as the name of the interface, both are called CarIdentification. rest除了一些调整(新的类和一些类已重命名)外,在v2中是相同的,即class名称和属性名称以及接口名称,都称为CarIdentification。

My problem is that both versions have to be offered and I don't know how to integrate both in WCF.我的问题是两个版本都必须提供,我不知道如何将两者集成到 WCF 中。 Since both have the same name of the interface, which is derived, and also many classes have the same name.由于两者具有相同的接口名称,这是派生的,而且许多类也具有相同的名称。 I could make a copy of the whole solution and then offer version 1 and version 2 in the IIS.我可以复制整个解决方案,然后在 IIS 中提供版本 1 和版本 2。 But I would like to have 1 WCF with both versions.但我想要两个版本都有 1 个 WCF。 I could also work with multiple endpoints, but how do I do that if most of the names are the same?我也可以使用多个端点,但如果大多数名称都相同,我该怎么做? Is that possible at all?这有可能吗? The next thing is that in CarService.svc.cs there is a derived method which is defined in the interface and which has a return value from CarV1.cs.接下来是在 CarService.svc.cs 中有一个派生方法,该方法在接口中定义,并具有来自 CarV1.cs 的返回值。 CarV2 of course has the method "GetDetails" as well and I can't address it because it is always referenced to CarV1. CarV2 当然也有方法“GetDetails”,我无法解决它,因为它总是引用 CarV1。 I have already tried to address the method with CarV2.GetDetails, but that does not work.我已经尝试使用 CarV2.GetDetails 解决该方法,但这不起作用。

How can I implement the whole thing sensibly?我怎样才能明智地实施整个事情? It would be an advantage if I didn't have to adapt the client application that accesses the service.如果我不必调整访问服务的客户端应用程序,那将是一个优势。

Thank you谢谢

The first problem is that the class parameters created after implementing the interface can be distinguished.第一个问题是可以区分实现接口后创建的class参数。

The second problem is that if the method name is the same and cannot be distinguished, it can also be implemented by adding different parameters in the same method name.第二个问题是,如果方法名相同,无法区分,也可以通过在同一个方法名中加入不同的参数来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM