2010-12-12 156 views
1

我想下面的XML請求發送到WSDL Web服務:WSDL客戶端問題,PHP


<?xml version="1.0" encoding="utf-8"?> 
<soapenv:Envelope 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 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-'.$nonce.'"> 
<wsse:Username>xxxxx</wsse:Username> 
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxx</wsse:Password> 
</wsse:UsernameToken> 
<wsu:Timestamp wsu:Id="Timestamp-'.$nonce.'" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
<wsu:Created>'.$timestamp.'</wsu:Created> 
<wsu:Expires>'.$expiration.'</wsu:Expires> 
</wsu:Timestamp> 
</wsse:Security> 
</soapenv:Header> 
<soapenv:Body> 
<prep:requestListeSeancesCtrlAcces> 
    <codeManifestation>xxxx</codeManifestation> 
    <!--Optional:--> 
    <debutIntervalle/> 
    <!--Optional:--> 
    <finIntervalle/> 
    </prep:requestListeSeancesCtrlAcces> 
</soapenv:Body> 
</soap:Envelope> 

我怎樣才能做到這一點?我試着PHP SOAP擴展,並且還的NuSOAP沒有成功:(您的幫助

感謝

+0

向我們展示您嘗試過的。 – svens 2010-12-12 22:46:46

+0

因此,您確定此SOAP消息符合WSDL,並且您想知道如何將此消息作爲請求的主體發送到HTTP端點? – ivy 2010-12-12 22:58:24

回答

1

你有沒有嘗試過的HttpRequest ::發送如看到的例子在http://www.php.net/manual/en/function.httprequest-send.php#95734並在自己的數據填:?

<?php 
//set up variables 
$theData = '<?xml version="1.0" encoding="utf-8"?> 
<soapenv:Envelope 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 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-'.$nonce.'"> 
<wsse:Username>xxxxx</wsse:Username> 
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxx</wsse:Password> 
</wsse:UsernameToken> 
<wsu:Timestamp wsu:Id="Timestamp-'.$nonce.'" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
<wsu:Created>'.$timestamp.'</wsu:Created> 
<wsu:Expires>'.$expiration.'</wsu:Expires> 
</wsu:Timestamp> 
</wsse:Security> 
</soapenv:Header> 
<soapenv:Body> 
<prep:requestListeSeancesCtrlAcces> 
    <codeManifestation>xxxx</codeManifestation> 
    <!--Optional:--> 
    <debutIntervalle/> 
    <!--Optional:--> 
    <finIntervalle/> 
    </prep:requestListeSeancesCtrlAcces> 
</soapenv:Body> 
</soap:Envelope>'; 

$url = 'http://www.example.com'; 
$options = array(); 

//create the httprequest object     
$httpRequest_OBJ = new httpRequest($url, HTTP_METH_POST, $options); 
//add the content type 
$httpRequest_OBJ->setContentType = 'Content-Type: text/xml'; 
//add the raw post data 
$httpRequest_OBJ->setRawPostData ($theData); 
//send the http request 
$result = $httpRequest_OBJ->send(); 
//print out the result 
echo "<pre>"; print_r($result); echo "</pre>"; 
?> 
0

當我使用WSDL我使用捲曲

用於修改標頭和信封使用此: curl_setopt($ CH,CURLOPT_HTTPHEADER,$頭); curl_setopt($ CH,CURLOPT_POSTFIELDS,$ S oapenvelope);