Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I finally got it to work!!! The problem was that the ShipmentInformationMessage did not receive a prefix and thus was not recognized by the mock service (obviously). After A LOT of searching on the internet, I finally tried out the code from <a href="http://blogs.msdn.com/b/andrewarnottms/archive/2008/01/18/using-the-xmlserializer-as-an-xmlobjectserializer-with-wcf.aspx" rel="nofollow">this excellent MSDN blog by Andrew Arnott</a>! </p> <p>I modified the code so xml namespaces could be added, plugged it in, and now it works!!!</p> <p>This is what the top of the working message looks like: </p> <pre><code> &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;s:Header&gt; &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://www.noneofyour.biz/ShipmentInformationService/PutShipmentInformationMessage&lt;/Action&gt; &lt;/s:Header&gt; &lt;s:Body&gt; &lt;ns1:ShipmentInformationMessage xmlns:ns2="http://www.noneofyour.biz/schema/Transportation/2011/01" xmlns:ns3="http://www.noneofyour.biz/schema/Common/2011/01" xmlns:ns1="http://www.noneofyour.biz/message/Transportation/2011/01"&gt; &lt;ns1:SenderId&gt;NOSOTROS&lt;/ns1:SenderId&gt; &lt;ns1:RecipientId&gt;PARTNER&lt;/ns1:RecipientId&gt; &lt;ns1:CreationTimeStamp&gt;2011-08-10T07:44:52.9423961+02:00&lt;/ns1:CreationTimeStamp&gt; &lt;ns1:Version&gt;2.0&lt;/ns1:Version&gt; &lt;ns1:TestIndicator&gt;true&lt;/ns1:TestIndicator&gt; &lt;ns1:ControlParty&gt; &lt;ns3:Name&gt;PrimaryContact&lt;/ns3:Name&gt; &lt;ns3:Contact d5p1:nil="true" xmlns:d5p1="http://www.w3.org/2001/XMLSchema-instance" /&gt; &lt;/ns1:ControlParty&gt; &lt;ns1:Action&gt;new&lt;/ns1:Action&gt; </code></pre> <p>Please note the prefix of the ShipmentInformationMessage-element that does the trick! </p> <p>I now understand that to provide an alternative to the default formatter, which is based on WCF's DataContractSerializer, just a bare XmlSerialzer doesn't cut it. You need something at least as good as DataContractSerializer. </p> <hr> <p><strong>EDIT</strong></p> <p>The piece of code that does the trick here is the following: </p> <pre><code> XmlRootAttribute root = new XmlRootAttribute(wrapperName); root.Namespace = wrapperNamespace; serializer = new XmlSerializer(this.objectType, root); </code></pre> <p>Here, the root element is defined and the necessary namespace is added and the xml-serializer is initialized with it. I am passing "ShipmentInformationMessage" as wrapperName as well as its namespace. </p> <p>Then, with all three namespaces and their prefixes added to the xml-serializer afterwards as well (like in the code example of my original post), I am getting exactly what I need and the SOAP UI mock service totally accepts it! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload