Php calls the. Net WebService asmx file through soap, webserviceasmx
This example describes how to call the. Net WebService asmx file through soap in php. We will share this with you for your reference. The details are as follows:
Recently, it was used for testing in the same industry. the C # WebService Interface written by net has passed the call. Now we need to test the php version's call to it. After Various explorations, the related PHP's webservice calling process is as follows:
1. Open the php extension:
Find the configuration file php. ini and open the following extension:
extension = php_soap.dllextension = php_curl.dllextension = php_openssl.dll
2. the php code is as follows:
<? Phpheader ("content-type: text/html; charset = UTF-8"); $ client = new SoapClient ("http: // 192.168.3.178: 8080/ChkWelePsw. asmx? WSDL "); // This row test is not feasible $ client = new SoapClient (" http: // 192.168.3.178: 8080/chkwelepsw. asmx? WSDL/ChkWele? Username = test3 & psw = 123 "); // pass the parameter to encapsulate $ param = array ('username' => 'test3 ', 'psw' => '123'); // The call must use _ soapCall $ p = $ client->__ soapCall ('chkwele ', array ('parameters '=> $ param); print_r ($ p-> ChkWeleResult); // output the variable $ p first to see what type it is.?>
Note: After php calls a method, its soap object will automatically generate a Result method to conveniently display the call Result. The preceding "ChkWele" method of the WebService to be called,
The caller has the corresponding "ChkWeleResult" method.
Some WebServices of. NET should pay attention
/** <System. web> add the following content to this node <webServices> <protocols> <add name = "HttpSoap"/> <add name = "HttpPost"/> <add name = "HttpGet" /> <add name = "Documentation"/> </protocols> </webServices> */[WebMethod (Description = "This ...... ", EnableSession = false)] public string ChkWele (string username, string psw) {string ret =" "; return ret ;}