Quantcast
Channel: Discussion Forum > Connect Data Services
Viewing all articles
Browse latest Browse all 2504

Send request to the queryCSV method of rightnow webservice using PHP (1 Comment)

$
0
0

Topic by swap mas

I want to send request parameters & client info header to te rightnow webservice using PHP SOAP calls. How can I do this ? Please help

My wsdl structure is as follows:

<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>

I want to pass client header and parameters (query, pagesize, delimiter, returnrawresult, disableMTOM) to the queryCSV method. I am getting following error:

Fatal error: Uncaught SoapFault exception: [soapenv:Sender] Data element in the Message is NULL in C:\wamp\www\querycsv\index.php:112 Stack trace: #0 C:\wamp\www\querycsv\index.php(112): SoapClient->__soapCall('QueryCSV', Array) #1 {main} thrown in C:\wamp\www\querycsv\index.php on line 112

I tried several ways, one of the way I tried is here:

<?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);

 

 

 


Viewing all articles
Browse latest Browse all 2504

Trending Articles