捕捉soap的xml形式

下面是我以前对Php的soap接口进行抓包分析出的结果,这个分析在当服务端或者客户端的Php没有安装soap模块时,可以使用构建xml的方式实现相同的功能

服务端:

 

  
  
  
  
  1. <?php  
  2.  
  3. $data = $HTTP_RAW_POST_DATA;  
  4.  
  5. $data = file_get_contents('php://input');  
  6.  
  7. $server = new SoapServer(null, array('uri' => "http://abc-soap-duba/"));  
  8.  
  9. $server->addFunction("sendtask");  
  10.  
  11. $server->handle($data);  
  12.  
  13. function sendtask()  
  14.  
  15. {  
  16.  
  17.     return "ok";  
  18.  
  19. }  
  20.  
  21. ?> 
客户端代码
  
  
  
  
  1. <?php  
  2.  
  3. $client = new SoapClient(null, array('location' => "http://api.abc.cn/taskserver.php",  
  4.  
  5.                                      'uri' => "http://abc-soap-duba/"));  
  6.  
  7. $username="[email protected]";  
  8.  
  9. $password=md5("123456");  
  10.  
  11. $domain="www.abc.cn";  
  12.  
  13. $pathsizelist="/images/ad2.gif,4846,/images/ad3.gif,5788,/images/ico01.gif,1089,/images/logo.gif,1605";  
  14.  
  15. echo $client->sendtask($username,$password,$domain,$pathsizelist);  
  16.  
  17. ?> 
客户端发出的数据:
  
  
  
  
  1. POST /b.php HTTP/1.1  
  2. Host: api.abc.cn  
  3. Connection: Keep-Alive  
  4. User-Agent: PHP-SOAP/5.2.2  
  5. Content-Type: text/xml; charset=utf-8  
  6. SOAPAction: "http://abc-soap-duba/#sendtask"  
  7. Content-Length: 766  
  8.  
  9. <?xml version="1.0" encoding="UTF-8"?> 
  10. <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/"> 
  11. <SOAP-ENV:Body> 
  12. <ns1:sendtask> 
  13. <param0 xsi:type="xsd:string">[email protected]</param0> 
  14. <param1 xsi:type="xsd:string">e10adc3949ba59abbe56e057f20f883e</param1> 
  15. <param2 xsi:type="xsd:string">www.abc.cn</param2> 
  16. <param3 xsi:type="xsd:string">/images/ad2.gif,4846,/images/ad3.gif,5788,/images/ico01.gif,1089,/images/logo.gif,1605</param3> 
  17. </ns1:sendtask> 
  18. </SOAP-ENV:Body> 
  19. </SOAP-ENV:Envelope> 
当server中没有改函数时返回的结果
  
  
  
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <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中有该函数时的结果
  
  
  
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <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/"> 
  3. <SOAP-ENV:Body> 
  4. <ns1:sendtaskResponse> 
  5. <return xsi:type="xsd:string">ok</return> 
  6. </ns1:sendtaskResponse> 
  7. </SOAP-ENV:Body> 
  8. </SOAP-ENV:Envelope> 

 

你可能感兴趣的:(xml,PHP,职场,SOAP,休闲)