Tuesday, May 25, 2010

Error in Web Service: The test form is only available for requests from the local machine

I have faced a problem when try to access a Web service from a remote computer I cannot see the Invoke button. And received the following error message:

The test form is only available for requests from the local machine

The reason is .NET-connected Web services support HTTP GET, HTTP POST and SOAP protocols. By default, in .NET Framework 1.0, all three protocols are enabled. By default, in .NET Framework 1.1, HTTP GET and HTTP POST are both disabled for security reasons.

Applications that use HTTP GET or HTTP POST to invoke a Web service fail when the Web service is upgraded to .NET Framework 1.1.

The .NET Framework 1.1 defines a new protocol that is named HttpPostLocalhost. By default, this new protocol is enabled. This protocol permits invoking Web services that use HTTP POST requests from applications on the same computer.

To solve this problem we have to enable HTTP GET and HTTP POST by editing the Web.config file where the Web service resides.

<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>