Tuesday 31 July 2012

Invoking web service from Siebel with EAI HTTP Transport Business Service

 

Some recent task I did was to invoke a web-service from Siebel to send SMS message.

I have to admit that I never did such a thing before. So I started to read Siebel “bookshelf”  documentation (you can throw this crap to the garbage . It is worthless), search Google. Found plenty bad written tutorials about invoking workflow process that can invoke web service or call http URL.

        Half of the staff I didn’t understand, the  other half didn’t like, but I understood one thing: at the end Siebel works with a Business Service (BC) called “EAI HTTP Transport “.

As I mentioned I am not to good with clicking on buttons in Siebel Tools, but pretty good with writing code. So if I know that Siebel uses a BC, why not to use it directly?

  The result is this simple function that defines XML message and uses POST method to submit data to remote web-service


function SendSms(Inputs, Outputs)
{
//get Business Service
var bs = TheApplication().GetService("EAI HTTP Transport");
var inp = TheApplication().NewPropertySet();
var outputs1 = TheApplication().NewPropertySet();
// it is web-service, so use POST method
inp.SetProperty("HTTPRequestMethod","POST");
//Content type as in all HTTP request
inp.SetProperty("HTTPContentType", "text/xml; charset=UTF-8");
//web-service end point
inp.SetProperty("HTTPRequestURLTemplate","https://**********/imsc/interfaces/largeaccount/la3.sms");
//define the data to be send
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>';
//set the data
inp.SetProperty("HTTPRequestBodyTemplate",reqVal);
//invoke. The result can be found in "Outputs"
bs.InvokeMethod("SendReceive",inp,Outputs);
}

2 comments:

  1. Does this work can you explain me how it will work

    //web-service end point
    inp.SetProperty("HTTPRequestURLTemplate","https://**********/imsc/interfaces/largeaccount/la3.sms");

    hear i need to mention SMS third party url to send sms right

    ReplyDelete