How can I setup web service method to accept parameters in the SOAP action?
-
Friday, June 04, 2010 10:36 AM
Hi,
Well the subject is my best desciption in words, but let me show you what I mean.
<soap:Body> <HelloWorld Version="1" /> </soap:Body>
I need to be able to accept the soap body in the example above. But I cant see how my webmethod in my code must look like for this to work. Any suggestions?
--
Werner
All Replies
-
Friday, June 04, 2010 2:41 PMModerator
First of all, what you posted has nothing to do with the SOAP Action header.
Second, as an experiment, try defining your web method to accept a single parameter of type XmlElement. Send the XML you posted, then examing the XmlElement to see what you get.
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects -
Monday, June 07, 2010 9:36 AM
First of all, what you posted has nothing to do with the SOAP Action header.
Second, as an experiment, try defining your web method to accept a single parameter of type XmlElement. Send the XML you posted, then examing the XmlElement to see what you get.
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
Hi, thanks for your answer.Well I know about the soap action but it is something along that concept, explanation: I'm used to have a webservice expose methods that accepts a request and respond with a response. The soap action is then the method name to put it simple. To continue with the HelloWorld example I would have a method called "HelloWorld" which accepts a request called "HelloWorldRQ" and respond with "HelloWorldRS". This would give me something like this:
<soap:Body> <HelloWorld xmlns="http://tempuri.org/"> <request Version="int" /> </HelloWorld> </soap:Body>
Here the action is "HelloWorld" which is my method name. Now the issue is that I must accept this body:
<soap:Body> <request Version="int" /> </soap:Body>
As you can see the only difference is the lack of method name / action. Hence my choice of words on the subject line. The first thing in the soap body is the request itself - not a method name. To me, the only way to do this would be to have a method called "request". But then my problem with the attributes arise...
Unfortunately having the web service accept an XmlElement does not produce correct behaviour :(
--
Werner -
Monday, June 07, 2010 11:18 AM
You can specify the request and response elements using SoapDocumentMethod attribute.
if you want to accept the xml without the a wrapping element and directly you want to pass the parameters, then it is not possible with standard asmx web service. You have to achieve this by extending it using soap extension. Here you can write the method which is called before XML reaches to web method. Using this you can modify the xml to proper format before it reaches to web method. Link http://msdn.microsoft.com/en-us/magazine/cc164007.aspx
Also asmx web service has become obsolete. WCF extensions if you want to use WCF web services.
Jagatheesan- Marked As Answer by Werner Clausen Thursday, June 10, 2010 9:28 AM
- Unmarked As Answer by Werner Clausen Thursday, June 10, 2010 9:43 AM
-
Monday, June 07, 2010 7:08 PMModeratorWhy would he want to use WCF Extensions? That was pre-release software for VS2005. He should just use VS2010 or VS2008, which support all of WCF.
John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects- Marked As Answer by Werner Clausen Thursday, June 10, 2010 9:28 AM
- Unmarked As Answer by Werner Clausen Thursday, June 10, 2010 9:43 AM
-
Thursday, June 10, 2010 9:58 AM
Thanks both, I understand your answers so that it would be possible to achieve using WCF, yes? But I fail to see how. For example if I post the following SOAP envelope to a WCF endpoint how should my WCF service pick up that?
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Header /> <soap:Body> <HelloRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1" xmlns="somenamespace" /> </soap:Body> </soap:Envelope>
Now imagine that this xml is posted from any application - for example using a HttpWebRequest. How should my method or whatever look like - in a WCF service - to pick up this? Obviously in a way that has an advantage over the simple way: Just to pick up the Request.InputStream from an ASPX page.
--
Werner -
Friday, June 11, 2010 7:04 AM
Posted new question in WCF forum: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/655958df-cce3-472b-99f1-2d3018e3d007
Thanks.
- Proposed As Answer by edhickey Tuesday, June 15, 2010 6:08 PM
-
Friday, June 11, 2010 11:05 AM
Hello,
Have you tryed marking your web method with:
[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]? This should be enough to remove wrapping HelloRequest element.Best regards,
Ladislav Mrnka

