PHP uses SOAP to call. net WebService data

Source: Internet
Author: User

This is a little different from the general idea of passing values through php post or GET and checking the database for data. The SOAP module is required, and the processing method is 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:
Copy codeThe Code is as follows:
<? Php
$ 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.
Copy codeThe 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"
<? Xml version = "1.0" encoding = "UTF-8"?>
<Soap: Envelope xmlns: xsi = "The http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "The http://www.w3.org/2001/XMLSchema" xmlns: soap = "The http://schemas.xmlsoap.org/soap/envelope/">
<Soap: Body>
<GetArticle xmlns = "http://tempuri.org/">
<Param1> string </param1>
<Param2> string </param2>
</GetArticle>
</Soap: Body>
</Soap: Envelope>

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.