Home > Backend Development > PHP Tutorial > PHP calls .NET's WebService simple example_PHP tutorial

PHP calls .NET's WebService simple example_PHP tutorial

WBOY
Release: 2016-07-13 09:59:44
Original
879 people have browsed it

A simple example of using PHP to call .NET's WebService

This article mainly introduces a simple example of using PHP to call .NET's WebService. It is very simple. Friends in need You can expand it yourself. If you have any questions, please leave a message.

Create a C# web service. I won’t go into details about this. I used the wizard of vs2008 to create the simplest one and let it run at: http://localhost/webservice1/service1.asmx

There is a web method like this:

The code is as follows:


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

ok, everything is ready. The following is written in a certain php file: php5 itself supports SOAP to call Web Service:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

//get localization strings from C# webservice

$client = new SoapClient('http://localhost/webservice1/Localization.asmx?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";

}

?>

1 2

3

4

5 6

78 9 10 11 12 13
14
15
16
<🎜>//get localization strings from C# webservice<🎜> <🎜>$client = new SoapClient('http://localhost/webservice1/Localization.asmx?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"; } ?>
That’s OK, I will continue to introduce SOAP The above is the entire content of this article, I hope you all like it. http://www.bkjia.com/PHPjc/975129.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/975129.htmlTechArticle A simple example of PHP calling .NET's WebService. This article mainly introduces a simple example of using PHP to call .NET's WebService. The example is very simple. Friends who need it can extend it by themselves...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template