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:
ok, everything is ready. The following is written in a certain php file: php5 itself supports SOAP to call Web Service:
?
3 4 5 614 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"; } ?> |