Last post Apr 30, 2013 03:54 AM by Steven Cheng - MSFT
Apr 26, 2013 02:58 PM|dewpt|LINK
I have written an asmx web service which was tested successfully by the user. When I deployed the same web service to the production server, the user complained the response from the web service was different. The difference was that test server response
had a tns prefix for the elements in the xml.
If nothing changed in the code and tns prefix was never specified by me, why are the two responses different?
Thanks in advance
Apr 30, 2013 03:54 AM|Steven Cheng - MSFT|LINK
First, for XML document, whether using namespace prefix or not doesn't matter (doesn't make XML document different) from XML standard's perspective. And for ASMX webservice, it is the underlying XML reader/writer or serializer which determines to emit prefix
or not. For your case, if you're working with some certain partners which will care about XML namespace prefix, you can consider the following means.
You can consider define the request/response of your ASMX webservice as custom classes and use XML serialization related attributes to control its serialization format(after converted to XML format). here are some web articles and threads talking on this:
#Webservice response using namespace prefix
#Remove namespace from ASP.NET web service, or add namespace prefix?
and another approach is using Soap extension component to intercept and modify the underlying SOAP request/response message generated by the runtime. Soap Extension is a low level component which can help you intercept the SOAP xml messages generated for
sending over HTTP transport layer, you can get them and perform some custom tranformation or modification. But building soap extension is somewhat complicated, here are some related web references:
#Fun with SOAP Extensions
#Using SOAP Extensions in ASP.NET