Scott Hanselman


July 29, '03 Comments [0] Posted in Web Services | XML
Sponsored By

After discovering that .NET/ASMX didn't want to let me change the prefix on the root element of a SOAP payload, I did the unthinkable, but appropriate action and wrote a SoapExtension to please the client of this Web Service.  Certainly the world of Web Services is a worse place that I had to write this.

Of course, the prefix is not needed, but it made them happy, and that is satisfaction enough, eh?  And at least it is implemented as an Attribute, so it can be easily removed in the future.

I won't ruin my karma by posting the project here, but the gist is this.  (If you want the code, and to go to hell, email me):

public Car HelloFord()
   Car c =
new Car();
   return c;

results in this (added stuff in red).  Note that the default namespace remains, and the added prefix uses that full qualified namespace.  The goal wasn't to fundamentally change the structure of the document, just add the prefix.

<soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
    <scott:MyCar xmlns="" xmlns:scott="">
      <car xmlns:yoyoyo="hanselman" xmlns="hanselman">
        <yoyoyo:engine>some engine</yoyoyo:engine>
    </scott:MyCar >

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.