Home  >  Article  >  Backend Development  >  PHP uses SOAP to call .net's WebService data_PHP tutorial

PHP uses SOAP to call .net's WebService data_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:16968browse

This is a bit different from the general PHP POST or GET method of passing values ​​and then checking the database to get the data. You need to use the SOAP module. The processing method is also very simple, but there are some things that need to be paid attention to.
First make sure that .SOAP is enabled in your PHP.ini, that is, remove the semicolon in front of extension=php_soap.dll.
The code is very simple:

Copy the code The code is as follows:

$client = new SoapClient('http://www.aa.net/SearchService.asmx?WSDL');//This SOAP address needs to be replaced with your own
$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'utf-8';
$param = array('param1'=>'01', 'param2'=> '02');
//$param["param1"]="01";
//$param["param2"]="02";
//$result = $client- >__soapCall("GetArticle", array( $param ));
$result = $client->__Call("GetArticle", array( $param ));
if (is_soap_fault($result))
{
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}
else
{
$data = $result->GetArticleResult; //What is returned here is the class, you must use -> to get the value of the element
print_r($data);
}
? >

One thing to note is that the parameter is an array wrapped with an array, which is array( array() )
Attached are some parameters of the SOAP interface:
The following are SOAP 1.2 request and response examples. Placeholders shown need to be replaced with actual values.
Copy code The code is as follows:

POST /SearchService.asmx HTTP/1.1
Host: 202.105.183.61
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetTrafficViolationInfo"




" string
" string
"


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825144.htmlTechArticleThis is a bit different from the general PHP POST or GET method of passing values ​​and then checking the library to get the data. You need to use The processing method of SOAP module is also very simple, but there are some things that need to be paid attention to. First make sure...
Statement:
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