我想使用PHP SOAP調用將請求參數&客戶端信息標頭髮送到目前的webservice。我怎樣才能做到這一點 ?請幫助使用PHP發送請求到rightnow webservice的queryCSV方法使用PHP
我的WSDL結構如下:
<wsdl:operation name="QueryCSV">
<soap:operation soapAction="QueryCSV" style="document"/>
<wsdl:input>
<soap:body parts="parameters" use="literal"/>
<soap:header message="rnw_v1_2:ClientInfoHeader" part="request_header" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
我想通過客戶端頭和參數(查詢時,頁面大小,分隔符,returnrawresult,disableMTOM)到queryCSV方法。我收到以下錯誤:
致命錯誤:Uncaught SoapFault異常:[soapenv:發件人]在消息中的數據元素在index.php(112)中爲NULL:SoapClient - > __ soapCall('QueryCSV',Array)#1 {}主扔在index.php文件
我試過幾種方法,我試過的方法之一是在這裏:
<?php
class clsWSSEAuth {
private $Username;
private $Password;
function __construct($username, $password) {
$this->Username=$username;
$this->Password=$password;
}
}
class clsWSSEToken {
private $UsernameToken;
function __construct ($innerVal){
$this->UsernameToken = $innerVal;
}
}
class ClientInfoHeader {
private $AppID;
function __construct ($appid){
$this->AppID = $appid;
/}
}
$username = "***";
$password = "***";
$WSDL = "https://*****/services/soap?wsdl";
$arrOptions = array('trace' => true);
$appid = "*****";
// SECURITY NAMESPACE
$strWSSENS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
//client infoheader namespace
$v1 = "urn:wsdl.ws.rightnow.com/v1_2";
$objSoapVarUser = new SoapVar($username, XSD_STRING, NULL, $strWSSENS, NULL, $strWSSENS);
$objSoapVarPass = new SoapVar($password, XSD_STRING, NULL, $strWSSENS, NULL, $strWSSENS);
$objWSSEAuth = new clsWSSEAuth($objSoapVarUser, $objSoapVarPass);
$objSoapVarWSSEAuth = new SoapVar($objWSSEAuth, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS);
// token object
$objWSSEToken = new clsWSSEToken($objSoapVarWSSEAuth);
$objSoapVarWSSEToken = new SoapVar($objWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS);
$objSoapVarHeaderVal = new SoapVar($objSoapVarWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'Security', $strWSSENS);
# Create the ClientInfoHeader header
$objAppId = new SoapVar($appid, XSD_STRING, NULL, $v1, NULL, $v1);
$objClientInfoHeader = new SoapVar($objAppId, SOAP_ENC_OBJECT, NULL, $v1, 'ClientInfoHeader', $v1);
//soap header
$objSoapVarWSSEHeader = array();
$objSoapVarWSSEHeader[] = new SoapHeader($strWSSENS, 'Security', $objSoapVarHeaderVal, true);
$objSoapVarWSSEHeader[] = new SoapHeader($v1, 'ClientInfoHeader', $objClientInfoHeader);
$objClient = new SoapClient($WSDL, $arrOptions);
//set headers
$wss_header = $objClient->__setSoapHeaders($objSoapVarWSSEHeader);
$Query = "select ********** from ******** where id > *** ";
$PageSize = 50;
$Delimiter = '|';
$ReturnRawResult = false;
$DisableMTOM = true;
$params = array('Query' => $Query, 'PageSize' => $PageSize, 'Delimiter' => $Delimiter, 'ReturnRawResult' => $ReturnRawResult, 'DisableMTOM' => $DisableMTOM);
$objResponse = $objClient->__soapCall("QueryCSV", array('parameters' => $params));
var_dump($objResponse);
?>