WCF 服务 Wsdl 错误:操作引用已导出的消息元素
我们有一个 WCF 服务,它有两个具有相同消息协定的操作(操作 1 和操作 2)。当您访问 Wsdl (Get/Http) 时,我们收到此错误:
System.InvalidOperationException: 调用 WSDL 导出扩展时抛出异常:System.ServiceModel.Description.DataContractSerializerOperationBehavior
契约:Xxxxx ----> System.InvalidOperationException: Xxxx.IServiceInterface.Operation1 操作 引用已从 Xxxx.IServiceInterface.Operation2 操作导出的消息元素 [http://schemas.somecompany.com/namespace/version/:MessageContract]。
您可以通过更改方法名称或使用OperationContractAttribute 的Name 属性来更改其中一项操作的名称。或者,您可以使用 MessageContract 编程模型更详细地控制元素名称。
在我看来,对于不同的服务操作重用相同的消息应该是可能的。我理解错误中给出的解决方案,但我们希望对于许多不同的操作都有相同的消息。
想法?
更多信息:我们实现了事件发布/订阅机制。事件订阅者使用他们想要处理的事件类型声明一个服务操作,并将其包装在通用消息契约类中。此通用消息类使用消息代码属性来使用事件发布者 xml 名称 - 这是单个消息结构。所有事件订阅者都在 UDDI 中注册,发布/订阅机制使用这些端点将事件推送给订阅者。 UDDI 中服务操作的注册会检测特定的事件名称空间,以将这些服务操作注册为事件处理程序(而不是请求/响应操作)。
We have a WCF service that has two operations (Operation1 and Operation2) with the same message contract. When you access the Wsdl (Get/Http) we get this error:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
contract: Xxxxx ---->
System.InvalidOperationException: The Xxxx.IServiceInterface.Operation1 operation
references a message element [http://schemas.somecompany.com/namespace/version/:MessageContract] that has already been exported from the Xxxx.IServiceInterface.Operation2 operation.
You can change the name of one of the operations by changing the method name or using the Name property of OperationContractAttribute. Alternatively, you can control the element name in greater detail using the MessageContract programming model.
Seems to me that reusing the same message for different service operations should be possible. I understand the resolution that is given in the error, but we want to have the same message for a number of different operations.
Thoughts?
More Info: We implement an event pub/sub mechanism. Event subscribers declare a service operation with the event type they want to handle and wrap that in a generic message contract class. This generic message class uses the message code attributes to use the event-publisher xml names - which is a single message structure. All event subscribers are registered in UDDI and the pub/sub mechanism use those endpoints to push events to the subscribers. Registration of service operations in UDDI detect the specific event-namespace to register those service operations as event handlers (and not req/response operations).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您复制粘贴了操作 1,然后将名称更改为操作 2,但未更改 DataContract 属性以匹配新名称,则可能会发生此错误。
This error can occur if you have copy - pasted operation1, then changed the name to operation2, but not changed the DataContract attribute to match the new name.