2013-11-22 78 views
1

我在設置PHP SOAP調用的主體時遇到了問題。我相信我很近,只是不知道如何以正確的格式獲取它。如何創建一個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> 

回答