Monday 6 August 2012

Read response from invoking Siebel CRM “EAI HTTP Transport” business service

 

I wrote a post some time ago about how to call URL from Siebel CRM. This post will deal with processing the response from remote page.

So here you go, follow the instructions from my previous post and submit data to remote page. Many times you expect not only to send data, but also receive a response back.

To remind you , in order to send data you have to invoke

oService.InvokeMethod("SendReceive", oInputs, oOutputs);


Common sense tells you that response is probably located in object.


But if you try to run



oOutputs.GetValue();


You will get the following error message


PropertySet GetValue call failed. PropertySet Value is marked as binary data, starting with….


And this is because Siebel can process data only in UTF-16 encoding. If it is not, Siebel “thinks” that it is a binary data.


Bellow is very simple code to convert the HTTP output to a proper format


var oTransService = TheApplication().GetService("Transcode Service");
var oTransOutputs = TheApplication().NewPropertySet();
oOutputs.SetProperty(
"ConversionMode", "EncodingToString");
oOutputs.SetProperty(
"SourceEncoding", "CP1252");
oTransService.InvokeMethod(
"Convert", oOutputs, oTransOutputs);
var sResponse = oTransOutputs.GetValue();

 


After you execute it. You will fine HTTP response string in sResponse variable.


 


P.S. You can find more information in 536101.1 metalink note

Sunday 5 August 2012

Prolog–remove duplicate list members without member predicate

 

This is completely not relevant to all my posts and a work I do. I am taking a “Prolog” class and find this language just amazing. So decided to post some of my assignments, because probably students all over a world also get similar one

My assignment is to write a program that removes duplicate list members, BUT you cannot use “member” predicate.

Lets start…

So if my list is empty there are no duplicate members for sure

rem([],[]).

The same is true if I have only one member in the list

rem([X],[X]).

Now comes the tricky part. If we recognize 2 members in the list with a same value, we will return the same list , but only with one member

rem([X,X|Tail],[X|Tail]).

And this is the start point for the program. Get the list and check it , by sending list tail to recursion

rem([X|Xs],Res):-rem(Xs,Res0),append([X],Res0,Res).

Ok, lets run it….

image

 

Well, we definitely got a correct answer, but what about incorrect answers? This is because of Prolog backtracking mechanism. After it find the correct answer it doesn’t stop and continue to check other options. So we add “red cut” to prevent backtracking

image

Now we have the correct answer