PHP uses SOAP to call. net WebService data

Source: Internet
Author: User
And. the other party provides a WebService interface. how does PHP call this data, next let's take a look at the method called by using SOAP. this is a little different from the idea of passing values through php post or GET and then checking the database for data. The SOAP module is required, and the processing method is also very simple, there are some things to be aware.
First, check that your PHP. ini has enabled. SOAP, that is, the semicolon before extension = php_soap.dll.
The code is simple:
The code is as follows:
$ Client = new SoapClient ('http: // www.aa.net/SearchService.asmx? WSDL '); // replace the SOAP address 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; // The Returned class must be-> get the element value
Print_r ($ data );
}
?>

It should be noted that the parameter is an array containing an array outside the array, that is, array ())
Some parameters of the SOAP interface are attached:
The following are examples of SOAP 1.2 requests and responses. The displayed placeholder must be replaced with the actual value.
The code is as follows:
POST or 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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.