By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://machine.domain.com" xmlns:types="http://machine.domain.com/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <tns:SimonsXMLResponse> <SimonsXMLResult xsi:type="xsd:string">string</SimonsXMLResult> </tns:SimonsXMLResponse> </soap:Body> </soap:Envelope>Firstly, how I can change
"<env:Envelope"? Also the my webmethod returns a string thus
return mystr;And the ASP.NET parser seems to do a wonderful job of encoding this as
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <tns:SimonsXMLResponse> <SimonsXMLResult xsi:type="xsd:string">string</SimonsXMLResult> </tns:SimonsXMLResponse> </soap:Body>How can I make the return into, say for example,
<env:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <fe:Conversation>Hello</fe:Conversation> </env:Body>Finally, how do I add header information to my messages. The format I'm after is something like...
<env:Header> <fe:MessageHeader> <sif:SIF_Name>blahdy blah</sif:SIF_Name> </fe:MessageHeader> </env:Header>
1- Regarding the env: namespace qualifier:
I have to ask why you would want to do such a thing. The string that you use as your namespace qualifier is irrelevant. (it's basically a variable name--you just have to use it consistently within your message.) The SOAP runtime system that generates the SOAP message (in your case ASP.NET) chooses the namespace qualifier. I don't think you have the ability to tell ASP/NET to use env: rather than soap:. If you really want to do this, you have three choices:
1- use a different SOAP runtime system that uses the env: namespace qualifier
2- use a low-level API (or use a straight XML processing API) to manually construct your SOAP message
3- transform the message when you receive it using XSLT
2- Regarding the response message format:
The ASP.NET-generated response message is generated because you are using RPC/encoded. If you want to return your example message then you would need to define the service as document/literal (but in that case you would not specify the encodingStyle attribute). Instead your return message would look something like:
<env:Body xmlns:fe="fe-namespace-uri"> <fe:Conversation>Hello</fe:Conversation> </env:Body>3- Regarding building SOAP headers:
Here are some resources for you:
- a free article with code samples
- a for fee article that explain how to develop SOAP Headers using ASP.NET
- Rob Howard's page (see ASP.NET Advanced Web Services presentation and code samples)
Related Q&A from Anne Thomas Manes
Anne Thomas Manes explains the differences between open source clients and open source implementations.continue reading
Anne Thomas Manes discusses the best way to go about creating an enterprise data dictionary and why the systems works well.continue reading
Anne Thomas Manes explains the difference between 'hard' real time and 'live' real time systems.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.