Sunday, August 30, 2009

protocol configuration of .asmx webservice

The default protocol configuration of .asmx webservice is -
<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
</protocols>
</webServices>

So it supports data & payload in soap envelope and documentation for all; but supports post only for localhost. Thus if we want to test a webservice using post method, we can test it only from localhost.

If we want to allow to invoke the webservice via get & post method we have to add the following under the system.web node -

<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>

Suppose you want to invoke a webmethod(MethodName which takes a parameter param) of a webservice(SomeService.asmx) using get method, then you need to hit the following url-
http://localhost/WebXmlHttpDemo/SomeService.asmx/MethodName?param=value