Search code examples
siebelrightnow-crm

Siebel > HTTP Post request is not being received properly


From Siebel I am using client side business service to send a HTTP Post request to Oracle RightNow. In the request I am sending XML as string to the RightNow but it is not being received correctly. The same XML is working as desired when I send from Postman by using 'binary' option. The Postman request is as below: enter image description here

But when I send request from Siebel I am getting these characters only at the RightNow php script:

??<

At the RightNow side, I am dumping the value I am getting at setting it in a field to know what is coming. From the Postman request, the field is showing complete XML with correct values but from Siebel request, I am just getting above mentioned characters.

The Siebel business service code:

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
 if(MethodName == "Create")
 {
     var bs = TheApplication().GetService("EAI HTTP Transport");
     var inp = TheApplication().NewPropertySet();
     var outputs1 = TheApplication().NewPropertySet(); 

     inp.SetProperty("HTTPRequestMethod","POST");
     inp.SetProperty("HTTPContentType", "text/html; charset=UTF-8");
     inp.SetProperty("HTTPRequestURLTemplate","http://<REMOVED>.rightnowdemo.com/cgi-bin/<REMOVED>.cfg/php/custom/REMOVED.php");

    var reqVal = '<?xml version="1.0" encoding="utf-8" ?> '+
    '<request> '+
    '  <head> '+
    '    <auth> '+
    '      <account>CompanyName</account> '+
    '     <user>userName</user> '+
    '    <pass>Pass</pass> '+
    '</auth> '+
    '      <action>sendsms</action> '+
    '  </head> '+
    ' <body> '+
    '   <addr> '+
    '     <from>039535640</from> '+
    '    <to> '+
    '      <cli>97254545450</cli> '+
    '  </to> '+
    '</addr> '+
    '<data> '+
    '  <msgtype>text</msgtype> '+
    '   <text>This is SMS message text</text> '+
    ' </data> '+
    '  <billing> '+
    '      <port>0</port> '+
    '    </billing> '+
    '  </body> '+
    '</request>';

    inp.SetProperty("HTTPRequestBodyTemplate",reqVal);

    bs.InvokeMethod("SendReceive",inp,Outputs);

  return (CancelOperation);
 }
 return (ContinueOperation);
}

The RightNow PHP Script:

<?php
ini_set('display_errors', 1);
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
require_once( get_cfg_var("doc_root")."/ConnectPHP/Connect_init.php");
use RightNow\Connect\v1_2 as RNCPHP;

$response = file_get_contents('php://input'); //file_get_contents('http://www.google.com');//
        $p = xml_parser_create();
        //xml_parser_set_option( $p, XML_OPTION_CASE_FOLDING, 0 );
        //xml_parser_set_option( $p, XML_OPTION_SKIP_WHITE, 1 );
        xml_parse_into_struct( $p, $response, $index );
        xml_parser_free( $p );

        foreach ($index as $tag) 
        {
            if($tag["type"]=="complete")
            {
                $temparr = array($tag['tag'] => $tag['value']);             
            }
        }   

$username="<REMOVED>";
$password="<REMOVED>";


//Checking authentication
try 
{
    initConnectAPI($username, $password);
    $testVar= RNCPHP\Incident::fetch(2620);
} catch (Exception $e) {
    echo "Authentication failed.";
    die;
}

$incident->CustomFields->c->Onsitegoissuedescription=$response;

Update

In the chrome, I tracked the header and found following:

POST http://desktop-i7nrnuh/start.swe Accept: / Origin: http://desktop-i7nrnuh X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Content-Type: application/x-www-form-urlencoded Referer: http://desktop-i7nrnuh/start.swe?SWECmd=GotoView&SWEView=Business+Service+Test+View&SWERF=1&SWEHo=desktop-i7nrnuh&SWEBU=1 Accept-Encoding: gzip, deflate Accept-Language: en-GB,en-US;q=0.9,en;q=0.8

I am looking ad "Accept-Encoding". Is it sending compressed request?

Update I used Fiddler to trace the request and found following:

POST http://<>.rightnowdemo.com/cgi-bin/<>.cfg/php/custom/<>.php HTTP/1.1 User-Agent: Mozilla/4.0 Accept: text/* Content-Type: text/xml Host: <>.rightnowdemo.com Content-Length: 910 Pragma: no-cache

ÿþ< x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " u t f - 8 " > < r e q u e s t > < h e a d > < a u t h >
< a c c o u n t > C o m p a n y N a m e < / a c c o u n t >
< u s e r > u s e r N a m e < / u s e r > < p a s s > P a s s < / p a s s > < / a u t h > < a c t i o n > s e n d s m s < / a c t i o n > < / h e a d > < b o d y > < a d d r > < f r o m > 0 3 9 5 3 5 6 4 0 < / f r o m >
< t o > < c l i > 9 7 2 5 4 5 4 5 4 5 0 < / c l i >
< / t o > < / a d d r > < d a t a > < m s g t y p e > t e x t < / m s g t y p e > < t e x t > T h i s i s S M S m e s s a g e t e x t < / t e x t > < / d a t a > < b i l l i n g > < p o r t > 0 < / p o r t > < / b i l l i n g > < / b o d y > < / r e q u e s t >

I am not sure where these (ÿþ) two characters are coming at the start?


Solution

  • The solution is, we have to send xml as binary that is in the input parameter of '' in the HTTP transport business service. I know this parameter is not defined in the inputs but this will be taken as Siebel OOTB and correct data will be sent. So having said above, it does not matter if you are using a escript or a workflow. You just need to set the xml in the '' and then pass it as input argument.