简体   繁体   中英

WCF Service Wsdl Error: operation references a message element that has already been exported

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).

如果您具有复制-粘贴operation1,然后将名称更改为operation2,但没有更改DataContract属性以匹配新名称,则可能发生此错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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