PHP USES SOAP to's WebService data

  • 2020-11-18 06:09:03
  • OfStack

This is a little different from the 1-like PHP POST or GET, which USES SOAP module and has a very simple processing method. There are some things that need to be paid attention to.
First make sure your PHP.ini is turned on.SOAP = php_soap.dll semicolon.
The code is simple:

$client = new SoapClient('');// this SOAP Change the address to your own 
$client->soap_defencoding = 'utf-8';  
$client->decode_utf8 = false;   
$client->xml_encoding = 'utf-8'; 
$param = array('param1'=>'01', '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);
    $data = $result->GetArticleResult; // The class returned here must be used -> I get the value of the element 

One thing to note is that the parameters are one layer above the array, array(array()).
Some parameters of the SOAP interface are attached:
Here is an example of SOAP 1.2 request and response. The placeholder displayed needs to be replaced with the actual value.

POST /SearchService.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: ""
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <GetArticle xmlns="">

Related articles: