SoFunction
Updated on 2025-03-09

A simple example of WebService calling in PHP.NET

To create a C# web service, I won't say much about this. I used vs2008's wizard to create the easiest one to run in:http://localhost/webservice1/

There is a web method like this:

Copy the codeThe code is as follows:

[WebMethod]
public string HelloWorld()
{
    return "Hello World";
}

OK, everything is ready. In a certain php file, the following is written: php5 itself supports SOAP calling Web Service:

<?php
  //get localization strings from C# webservice
  $client = new SoapClient('http://localhost/webservice1/?wsdl');

  echo "Call web service method from C# WebService:\n";
  $result = $client->GetLocalizationResource();

  if(!is_soap_fault($result))
  {  
    echo "return:\n", $result->GetLocalizationResourceResult;
  }
  else
  {
    echo "soap call fault";
  }
?>

This is OK, and I will continue to introduce SOAP

The above is the entire content of this article, I hope you like it.

Please take some time to share the article with your friends or leave a comment. We will sincerely thank you for your support!