[英]Siebel > HTTP Post request is not being received properly
從Siebel,我正在使用客戶端業務服務將HTTP Post請求發送到Oracle RightNow。 在請求中,我將XML作為字符串發送到RightNow,但未正確接收。 當我使用'binary'選項從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 Accept-Encoding:gzip,deflate Accept-Language:en-GB,en-US; q = 0.9,en; q = 0.8
我正在尋找廣告“接受編碼”。 它發送壓縮請求嗎?
更新我使用Fiddler跟蹤請求,發現以下內容:
POST http:// <> .rightnowdemo.com / cgi-bin / <> .cfg / php / custom / <> .php HTTP / 1.1用戶代理:Mozilla / 4.0接受:文本/ *內容類型:文本/ xml主機:<>。rightnowdemo.com內容長度:910語法:無緩存
ÿþ<xmlversion =“ 1. 0”編碼=“ utf-8”> <請求> <頭> <身份>
<帳戶>公司名稱</帳戶>
<用戶>用戶N ame </用戶> <通過> P屁股</通過> </身份驗證> <操作> sendsms </操作> </頭> <正文> <地址> <從> 0 3 9 5 3 5 6 4 0 </從>
<到> <cli> 9 7 2 5 4 5 4 5 4 5 0 </ cli>
</到> </ addr> <數據> <msgtype>文本</ msgtype> <文本> T hisis SMS消息文本</文本> </數據> <計費> <端口> 0 </端口> </計費> < /正文> </請求>
我不確定這兩個(ÿþ)字符從哪里開始?
從日志中可以清楚地看到該問題。 Siebel正在向rightnow發送UTF-16消息,這就是為什么您看到每個字符與主要垃圾字符之間存在空格的原因。 這是Siebel escript中的默認功能。 為了解決該問題,您必須使用轉碼服務消息到UTF-8,以便立即接受它。
解決方案是,我們必須以HTTP傳輸業務服務中''的輸入參數中的二進制形式發送xml。 我知道此參數未在輸入中定義,但是它將被視為Siebel OOTB,並且將發送正確的數據。 因此,如上所述,您使用的是腳本還是工作流程都沒有關系。 您只需要在''中設置xml,然后將其作為輸入參數傳遞即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.