开发者

WCF "Always generate message contracts" does not generate MessageContract

I'm importing a WSDL as a service definition (inbound to my service), and for whatever reason the client is formatting the request such that WCF cannot deserialize it without the proxy classes having MessageContract decorations.

I've gotten it to work this way by adding the MessageContract attribute on the main container class, which is fine because WCF builds these as partial classes, which means I can decorate my part and leave the generated part alone. However, in order to correctly deserialize the properties on the main container class, I have to decorate them with MessageBodyMember attributes that specify the namespace.

This is obviously a Bad Thing®, as it means that every time I regenerate from the WSDL I'm going to lose the ability to receive messages from the client. I've already set "Always generate message contracts" on the service reference configuration, but it appears to be a lie - the message contracts are not generated, regardless of whether I leave my partial class decorated with MessageContract or not.

Is there any way I can force WCF to generate these MessageContracts?

EDIT

I'm not sure whether it's pertinent, but when svcutil generates the proxy class, it decorates the properties with

[XmlElement(Order=0)]
//Property definition

And when I add the MessageContract attribute the service breaks with the message

Explicit sequencing may not be used on parameters or return values. Please remove Order property from custom attributes.

I have to remove all of the Order directives from the generated XmlE开发者_StackOverflow中文版lement attributes before I can successfully call the service.


I've found something similar. It seems that the service that I was binding to is issuing a response that had fields in an order that does not match the WSDL used to build the reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜