WCF and input order in SOAP envelope

I get a reference to an object that is not installed in an object error instance in my WCF web service that uses webHttpBinding (soap 1.1). I noticed that if you have input parameters in a specific order, an error does not occur.

i.e.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService"> <soapenv:Header/> <soapenv:Body> <not:NotifyWorkflowItemUpdate> <not:userIDs>testUserID</not:userIDs> <not:taskID>testTaskID</not:taskID> <not:taskType>testTaskType</not:taskType> <not:status>testStatus</not:status> <not:appID>testAppID</not:appID> <not:message>testMessage</not:message> </not:NotifyWorkflowItemUpdate> </soapenv:Body> </soapenv:Envelope> 

However, if I change the order of the input parameters in the request template, I get the above error. i.e. (note message and user id options switch)

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService"> <soapenv:Header/> <soapenv:Body> <not:NotifyWorkflowItemUpdate> <not:message>testMessage</not:message> <not:taskID>testTaskID</not:taskID> <not:taskType>testTaskType</not:taskType> <not:status>testStatus</not:status> <not:appID>testAppID</not:appID> <not:userIDs>testUserID</not:userIDs> </not:NotifyWorkflowItemUpdate> </soapenv:Body> </soapenv:Envelope> 

Why is this happening? Are query parameters mapped to .Net method parameters in order, rather than by name? Is there an attribute that I must specify in the service contract in order to enable the comparison of the named parameters?

+4
source share
2 answers

You need to use the XmlSerializerFormat class in your WCF service interface.

 [ServiceContract, XmlSerializerFormat] public interface IGoodMessageService { ... } 

The problem and solution are explained in this link: http://neimke.blogspot.com.tr/2012/03/serialization-ordering-causes-problems.html

+3
source

The XML schema of your SOAP message indicates the order. In the XML element order and WCF checks the XML for schema.

+3
source

All Articles