Hi all,
I am trying to handcraft messages to send to a WCF service (for a JS client sending JSON messages to a WCF endpoint that has a custom JSONEncoder on it) and I am looking to generate the Message headers. I see that MessageID and ActivityID are essentially GUIDs, and are added automatically by WCF.
MessageID is from the Addressing namespace, and w3 define it as any URI (which seems to be done by prepending "urn:uuid:" to the generated GUID). So I am assuming that any unique identifier within that field will do.
However, on investigating the ActivityID I see that it is a pure GUID in the SOAP, and this is confirmed by using reflector on System.ServiceModel.Diagnostics.ActivityIDHeader. Is this an essential header What is it used for Could it be any other unique string
Sincerely
Pete

Format of ActivityId
AshokKumarTD
It was a custom encoder that I wrote. It's effectively a JSON formatted encoding of the SOAP infoset. I wrote a custom XMLReader and XMLWriter that spits out/reads JSON. The writer is easy - you can come up with your own scheme for the json format - attributes could be written as JSON properties, and elements as nested JSON objects (I then had a special property called "_text" which represented text nodes within an element). But a better scheme (had I discovered it sooner) would have been to use one of the new standards for json encoding XML like Badgerfish (http://badgerfish.ning.com/).
The XMLReader is a lot tougher since it's a forward only reader, you need to have a JSON tokenizer and statemachine to properly implment the parser. This is not for the faint of heart..
But, at the end of the day, all I achieved was to have a SOAP message (with headers etc) in JSON format. So on the clientside (the webpage with embedded javascript) I needed to have Javascript proxies that could create a JSON SOAP message. I wrote a little tool that would generate these proxies via reflection over the WCF data/service contract assemblies.
I did get it working, but like most times a programmer sets out to do something, I had lost sight of the fact that this was supposed to be simple for the page designers to use. I ended up scrapping it, and decided to use the built in POX (plain ole XML) encoder (TextMessageEncoder with MessageVersion=None). AJAX page widgets now just speak XML to the WCF server, rather than JSON. It achieves the same result as speaking JSON, granted, perhaps the client side parsing of an XML message vs an "eval" of a JSON string may be a little less performant - but what's a few milliseconds on the clientside You can argue as well about message size and "anglebracketitis", but XML messages have a high compression ratio so are good candidates for gzip. A badly written JSON encoder on the server side could impact performance a lot more.
Think twice before pursuing JSON over the wire on your own... I've no doubt the atlas team will come out with some kind of WCF binding.. so it may be worth waiting for that than rolling your own as I did...
Pete
Sorry, I'm afraid I can't share code, company owns the IP...
VitCon
Hi Peter,
Could you please explain how did you make WCF endpoint unterstand JSON messages Did you write your own binding
When i'm sending json formatted messages to my WCF service i get an error 415 (not an expected format), i've tried to use different binding types but with no success, service expects text/xml or application/soap+xml, but client sends requests in application/json format.
P.S. Sorry for writing you not regarding your subj.
Cardin
if you didn't enable the trace(particularly activity tracing),we should not see activity headers in the message
<MessageLogTraceRecord>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1" u:Id="_2">http://Microsoft.ServiceModel.Samples/ICalculator/Add</a:Action>
<a:MessageID u:Id="_3">urn:uuid:bd700729-882c-4395-881f-6097749b68b3</a:MessageID>
<a:ReplyTo u:Id="_4">
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1" u:Id="_5">http://localhost:8000/servicemodelsamples/service</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="uuid-d3e8dbf9-43eb-477a-a0b8-748a57ee2047-8">
<u:Created>2006-09-11T17:49:29.984Z</u:Created>
<u:Expires>2006-09-11T17:54:29.984Z</u:Expires>
</u:Timestamp>
<c:SecurityContextToken u:Id="uuid-d60e6ecf-83c5-4a07-9d3b-e5b5b7fbdd3a-2" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc">
<c:Identifier>urn:uuid:ca9305ac-5a56-4631-8af1-18c6aac76bfe</c:Identifier>
</c:SecurityContextToken>
<c:DerivedKeyToken u:Id="uuid-d3e8dbf9-43eb-477a-a0b8-748a57ee2047-6" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-d60e6ecf-83c5-4a07-9d3b-e5b5b7fbdd3a-2"></o:Reference>
</o:SecurityTokenReference>
<c:Offset>0</c:Offset>
<c:Length>24</c:Length>
<c:Nonce></c:Nonce>
</c:DerivedKeyToken>
<c:DerivedKeyToken u:Id="uuid-d3e8dbf9-43eb-477a-a0b8-748a57ee2047-7" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-d60e6ecf-83c5-4a07-9d3b-e5b5b7fbdd3a-2"></o:Reference>
</o:SecurityTokenReference>
<c:Nonce></c:Nonce>
</c:DerivedKeyToken>
<e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:DataReference URI="#_1"></e:DataReference>
<e:DataReference URI="#_6"></e:DataReference>
</e:ReferenceList>
<e:EncryptedData Id="_6" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#uuid-d3e8dbf9-43eb-477a-a0b8-748a57ee2047-7"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>jY/+v7vVzGEqVa01rfbXvwLaUvwxsoYFlVKvttrzImRnH103h0PI5rKzD7szj5K1eTP2z8R7zW/LUrKhj4QzLre5jcz+CXvn7XJLUCVz8MKlidvsqTHQWdJ+1oQFfkIJ5TJDR/KKASYkBfSD4DQA5FHyRzCIdox4SgohGhUErjczmCUeGypCqsJPjfC5g7LkPGq5omjMOw5C7efbQ4O80JiltpaHZT8abCXRDhBiidgZUESPT2oEPADe/EwB23LGLYftwjapq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VTGXvoVmTsSgTT5OFWQ/SC5KjNGUk5wNiZY4JJhgdMrQgDqsiGpeUMe02CrcpNVcKP2MpO6JS4rG3SqM8HASy3AFoJ3LM2TLrFx13uQXJ7TRx7KtVGXijYkvJ0/XhqP1CpoYfeAE9kpFvOz2MbzYTxFf9QdUHd82rKG/KRoRXoGafV6xS1i6C7tvQf5XoV/y+24aTY2cljnPWxtNVrZCCRMpopGDQ1cC+dwD4H8TwMmJkpMrafMlXeLOvanGg6sgNdDIGNOiCM8SHeC6US/4dbI3FJcz4NqOYP3Hi1oO1L8NEhT1a4Am9X+IYiGX5ZuAg17A9b2EJ1vE0L3iDLzkumBOZFLFZhMFxutmo/bLSZbhwGUhD7uhyCj11iVwv9KGoyM4</e:CipherValue>
</e:CipherData>
</e:EncryptedData>
</o:Security>
</s:Header>
<s:Body u:Id="_0">
<e:EncryptedData Id="_1" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#uuid-d3e8dbf9-43eb-477a-a0b8-748a57ee2047-7"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>2mVtiuRNQyixpoYNPMu+EojV6gUOV67LXJF2vA8kin7nRp8bVP8qvtmjpeVrMLtTaUND0dd1J7WNf+z4J3xGCmMq5+Y23PlB+poTw19t1mdQkSauDkRR+IpYjEWEcBKLZi3NKHCTea06wTT3g1oxFw==</e:CipherValue>
</e:CipherData>
</e:EncryptedData>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>