PHP USES SOAP to call.net'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:
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.
First make sure your PHP.ini is turned on.SOAP = php_soap.dll semicolon.
The code is simple:
<?php
$client = new SoapClient('http://www.aa.net/SearchService.asmx?WSDL');// 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');
//$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; // The class returned here must be used -> I get the value of the element
print_r($data);
}
?>
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
Host: 202.105.183.61
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetTrafficViolationInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetArticle xmlns="http://tempuri.org/">
<param1>string</param1>
<param2>string</param2>
</GetArticle>
</soap:Body>
</soap:Envelope>