Determin How WebService method was invoked

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

Is it possible to tell how a WebMethod was invoked? For example I would
like to determin if it was invoked via SOAP or HTTP Post. Other than
creating 2 methods I am no sure if I can do this.

Many thanks for your time.

Nick.
 
Nick said:
Is it possible to tell how a WebMethod was invoked? For example I would
like to determine if it was invoked via SOAP or HTTP Post.

I've no idea how to do this but I'm curious - why would need to know this?

Regards,
Phill W.
 
Hi there,

Is it possible to tell how a WebMethod was invoked? For example I would
like to determin if it was invoked via SOAP or HTTP Post. Other than
creating 2 methods I am no sure if I can do this.

Many thanks for your time.

Nick.

Since its a web application, i would first try

HttpContext.Current.Request.HttpMethod
 
Hi Phil,

Well basically I'm creating an API that reacts differently depending how
it is invoked. For example, if invoked via SOAP within a client based
application I want to return some verbose XML data, but if invoked via HTTP
Post I would like to respond by redirecting to different URLS with limited
return value information. The idea behind this is that it won't mean that
the Post based calls won't have to parse loads of XML data.

That's the theory anyway.

Nick.
 
Hi Parez,

Thanks for the help, unfortunately that only seems to return GET, POST
or HEAD, so SOAP requests return POST. Unfortunately I need to know if it's
a SOAP request.

Maybe I'm misunderstanding something which is quite possible...

Nick.
 
Ahhaa got it...

If (Not
String.IsNullOrEmpty(HttpContext.Current.Request.Headers.Item("SOAPAction")))
Then
'//It was a SOAP request
Else
'//It wasn't a SOAP request
End If

excellent, thanks for your time peeps.
 
Hi Nick,

Generally both http post and SOAP based webservice invoking are over http
POST protocol. And after the requests arrive at ASP.NET side, different
kind of requewst( http get/post or SOAP are handled by different webservice
handler).

But I think your solution on using the "SoapAction" header is really smart
:)

Regards,


Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
 
Hi Steven

Cheers for the information that's really helpful, it makes sense why it
was always Post now :)

Thanks.

Nick.
 
Back
Top