PHP Soap调用.net webservice丢失第一个参数

  1. 云栖社区>
  2. 博客>
  3. 正文

PHP Soap调用.net webservice丢失第一个参数

填坑大人 2013-07-03 10:20:28 浏览337
展开阅读全文

这两天使用php调用.net做的webservice,一直不成功。

$output = $soap->__soapCall("sds", array(new SoapParam("192.168.0.100", "ip"), new SoapParam("abcdefg", "input")));
经抓包后,发现丢了第一个参数:

POST /PostLiftData.asmx HTTP/1.1
Host: 192.168.0.113:9001
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.8
Content-Type: application/soap+xml; charset=utf-8; action="http://tempuri.org/sds"
Content-Length: 206

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/"><env:Body><ns1:sds/><input>abcdefg</input></env:Body></env:Envelope>
要改成以下这个,才能完成我想发送的两个参数:input, ip。

$output = $soap->__soapCall("sds", array('', new SoapParam("192.168.0.100", "ip"), new SoapParam("abcdefg", "input")));
结果:

POST /PostLiftData.asmx HTTP/1.1
Host: 192.168.0.113:9001
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.8
Content-Type: application/soap+xml; charset=utf-8; action="http://tempuri.org/sds"
Content-Length: 228

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/"><env:Body><ns1:sds/><ip>192.168.0.100</ip><input>abcdefg</input></env:Body></env:Envelope>


------------------------------------------------------------------------------

发现了问题,原来php调用.net的SOAP是需要这样子调用:

$params = array('ip'=>"192.168.0.100", 'input'=>"abcdefg");
$output = $soap->__soapCall("sds", array("parameters" => $params));

那么,如果是调用java的和Php的呢?是否同样适用?







网友评论

登录后评论
0/500
评论
填坑大人
+ 关注