consuming php web service in asp.net

Below is the code to consume a webservice of php in asp.net.

In the given code we assume the web service return a string value to us.

We are passing the string type input to that web service.

Then we can use the return value according to our requirements.

private string GetResults(string url of web service)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url of web service);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string Test;
StreamReader reader = new StreamReader(response.GetResponseStream());
Test = reader.ReadToEnd();
Test = Server.HtmlDecode(Test);
return Test;
}
catch (Exception ex)
{
throw ex;
}
}

Now call this function on page load and pass the url of webservice with your input. Like:
GetTextFromPPT("http://webservice/index.php?value=" + test);

ref:

http://www.dotnetspider.com/resources/35554-Code-consume-php-webservice-asp-net.aspx

http://www.prescod.net/rest/dotnet/

http://www.simple-talk.com/dotnet/asp.net/calling-cross-domain-web-services-in-ajax/

Advertisements

~ by UTS on May 9, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: