Siebel > 未正确接收 HTTP Post 请求

问题描述 投票:0回答:2

我正在使用 Siebel 客户端业务服务向 Oracle RightNow 发送 HTTP Post 请求。在请求中,我将 XML 作为字符串发送到 RightNow,但未正确接收。当我使用“二进制”选项从 Postman 发送时,相同的 XML 可以按需要工作。邮递员请求如下:

但是当我从 Siebel 发送请求时,我只能在 RightNow php 脚本中获取这些字符:

??<

在 RightNow 方面,我将在字段中设置它时获得的值转储以了解即将发生的情况。从 Postman 请求中,该字段显示具有正确值的完整 XML,但从 Siebel 请求中,我只是得到上述字符。

Siebel 业务服务代码:

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

RightNow PHP 脚本:

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

更新

在 Chrome 中,我跟踪标题并发现以下内容:

POST http://desktop-i7nrnuh/start.swe 接受:/ 来源: http://desktop-i7nrnuh X-Requested-With:XMLHttpRequest 用户代理: Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML、 像 Gecko)Chrome/64.0.3282.186 Safari/537.36 内容类型: application/x-www-form-urlencoded 引用者: http://desktop-i7nrnuh/start.swe?SWECmd=GotoView&SWEView=Business+Service+Test+View&SWERF=1&SWEHo=desktop-i7nrnuh&SWEBU=1 接受编码:gzip、deflate 接受语言: en-GB,en-US;q=0.9,en;q=0.8

我正在寻找广告“Accept-Encoding”。是否发送压缩请求?

更新 我使用Fiddler跟踪请求并发现以下内容:

发布 http://<>.rightnowdemo.com/cgi-bin/<>.cfg/php/custom/<>.php HTTP/1.1 用户代理:Mozilla/4.0 接受:text/* 内容类型:text/xml 主机:<>.rightnowdemo.com 内容长度:910 编译指示: 无缓存

ÿþ< 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 > 公司名称 < / a c c o u n t >
< u s e r > 用户名 < / 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 > 发送 < / 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 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 >

我不确定这两个 (ÿþ) 字符一开始会出现在哪里?

siebel rightnow-crm
2个回答
0
投票

从日志中可以清楚地看到该问题。 Siebel 现在正在发送 UTF-16 消息,这就是您在每个字符和前导垃圾字符之间看到空格的原因。这是 Siebel escript 中的默认功能。为了解决此问题,您必须使用转码服务消息转为 UTF-8,以便立即接受它。


0
投票

解决方案是,我们必须将 xml 作为二进制发送,该 xml 位于 HTTP 传输业务服务中的输入参数 '' 中。我知道该参数未在输入中定义,但这将被视为 Siebel OOTB 并且将发送正确的数据。 如上所述,您使用的是脚本还是工作流程并不重要。您只需在 '' 中设置 xml,然后将其作为输入参数传递即可。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.