我无法设置PHP SOAP调用的主体。我相信我很接近,只是不知道如何以正确的格式获得它。
这是我到目前为止在PHP中的内容
$client = new SoapClient('http://url');
$username='username';
$password='password';
$headers='
'.$username.'
'.$password.'
';
$securityTags = new SoapVar($headers, XSD_ANYXML);
$header=new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security",$securityTags,true);
$client->__setSoapHeaders(array($header));
//HOW DO I SET THE BODY????
$params = array('deal'=>'PT10M', 'StoreIds'=>64);
return $client->__soapCall("PullDeals", array('searchCriteria'=>$params));
以下是请求应该是什么样的
<soapenv:Envelope xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:deal="http://url.com" xmlns:ns="http://url" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-145" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>YOUR_USERNAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">YOUR_PASSWORD</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">JQT6P7Zd3COZerXkREww2g==</wsse:Nonce>
<wsu:Created>2013-11-19T22:18:54.122Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns:PullDeals>
<ns:searchCriteria>
<deal:MaxElapsedSinceUpdate>PT10M</deal:MaxElapsedSinceUpdate>
<deal:StoreIds><arr:long>64</arr:long></deal:StoreIds>
</ns:searchCriteria>
</ns:PullDeals>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:1)
将您的请求与请求的内容进行比较,将'trace' => true
添加到您的soap客户端。
$client = new SoapClient("my.wsdl", array('trace' => true));
and then use echo $client->__getLastRequest();
to spit out the XML.
我通常只是在带有chrome's Inspector的页面上查看它,以便很好地缩进。
您可以在看到它的形成后重新格式化您的电话。