Reputation: 1
I am calling a webservice in C# and am getting an array of objects back.
Is there a way of getting an xml string instead?
Upvotes: 0
Views: 1609
Reputation: 122624
Do you want the entire XML, including all of the SOAP chatter, or just an XML representation of the array itself?
If you only want the array as XML, then serialize it using the XmlSerializer class. You can either serialize it within the WebService and return it as a string, or leave it as an array and serialize it on the client side.
Upvotes: 0
Reputation: 29041
Change the return type of the webservice method into a string, and serialize your data into XML before returning it.
Also, why do you want to do this? If you're getting an array of objects back, isn't that what the XML/SOAP contains?
Upvotes: 1
Reputation: 7201
If you are using the ScriptService attribute on your web service class (server side), that forces the service to return JSON. If you have it, delete it. (Same for ScriptMethod attribute on methods.)
Upvotes: 0
Reputation: 57926
You can make a raw call directly by using WebClient
and get your webservice return value as SOAP-formatted XML data.
Upvotes: 0