- 论坛徽章:
- 27
|
下面是我以前对Php的soap接口进行抓包分析出的结果,这个分析在当服务端或者客户端的Php没有安装soap模块时,可以使用构建xml的方式实现相同的功能 服务端: - <?php
-
$data = $HTTP_RAW_POST_DATA;
-
$data = file_get_contents('php://input');
-
$server = new SoapServer(null, array('uri' => "http://abc-soap-duba/"));
-
$server->addFunction("sendtask");
-
$server->handle($data);
-
function sendtask()
-
{
-
return "ok";
-
}
-
?>
客户端代码 - <?php
-
$client = new SoapClient(null, array('location' => "http://api.abc.cn/taskserver.php",
-
'uri' => "http://abc-soap-duba/"));
-
$username="cdn@abc.cn";
-
$password=md5("123456");
-
$domain="www.abc.cn";
-
$pathsizelist="/images/ad2.gif,4846,/images/ad3.gif,5788,/images/ico01.gif,1089,/images/logo.gif,1605";
-
echo $client->sendtask($username,$password,$domain,$pathsizelist);
-
?>
客户端发出的数据: - POST /b.php HTTP/1.1
-
Host: api.abc.cn
-
Connection: Keep-Alive
-
User-Agent: PHP-SOAP/5.2.2
-
Content-Type: text/xml; charset=utf-8
-
SOAPAction: "http://abc-soap-duba/#sendtask"
-
Content-Length: 766
-
-
<?xml version="1.0" encoding="UTF-8"?>
-
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://abc-soap-duba/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
-
<SOAP-ENV:Body>
-
<ns1:sendtask>
-
<param0 xsi:type="xsd:string">cdn@abc.cn</param0>
-
<param1 xsi:type="xsd:string">e10adc3949ba59abbe56e057f20f883e</param1>
-
<param2 xsi:type="xsd:string">www.abc.cn</param2>
-
<param3 xsi:type="xsd:string">/images/ad2.gif,4846,/images/ad3.gif,5788,/images/ico01.gif,1089,/images/logo.gif,1605</param3>
-
</ns1:sendtask>
-
</SOAP-ENV:Body>
-
</SOAP-ENV:Envelope>
当server中没有改函数时返回的结果 - <?xml version="1.0" encoding="UTF-8"?>
-
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Function 'sendtasks' doesn't exist</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
当server中有该函数时的结果 - <?xml version="1.0" encoding="UTF-8"?>
-
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://abc-soap-duba/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
-
<SOAP-ENV:Body>
-
<ns1:sendtaskResponse>
-
<return xsi:type="xsd:string">ok</return>
-
</ns1:sendtaskResponse>
-
</SOAP-ENV:Body>
-
</SOAP-ENV:Envelope>
end |
|