Thursday, January 15, 2009

It's Frost bites time!!!

New year is here and I think it will be already in the books for the lowest temperature recorded in years. Its freezing cold here, temperature in -20 and sucks big time. Well my coffee is not invigorating any more but it helps me keep warm for some time. So I spent most of my time at home and been burning lot of time talking on the phone.

Our man AR rocks the western world now and every Indian should be proud of him. Saw the Slumdog millionaire and loved the screenplay. But I wish that the director has shown atleast one nice shot of Business Capital of India. I heard one of the audience in the theater commenting , “Now I understand why it’s easy to take Indian out of India”. Well some of the scenes were gross than Saw for sure. But screenplay of the movie stands tall. I wish AR wins Oscar for this sound track. I feel some of his scores in the nineties are much better than Slumdog soundtrack but the media was not big in the 90s as it is now.

Other than watching movie and talking to my friends my week has been pretty drab .Guess what spend the rest of time in Siebel trying to invoke .net web service from Siebel.It was interesting and good that it was not a smooth ride..Learnt a lot .So here is how I did it.

1.Wrote a program in C# and exposed it as web service.
Code:

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

/*[WebMethod]
public string HelloWorld() {
return "Hello World";
}*/

[WebMethod]

public decimal AddNumbers(decimal lnNumber1, decimal lnNumber2) {

decimal AddNumbersResult;
AddNumbersResult = lnNumber1 + lnNumber2;
return AddNumbersResult;

}


}

2.Compiled and saved the WSDL. It’s easier to generate WSDL in .net .You just change the published web service from http://localhost:1569/WebSite1/Service.asmx?op=AddNumbers to
http://localhost:1569/WebSite1/Service.asmx?wsdl .

3.Imported the WSDL into Siebel

4.Siebel generates IO and Bus Srvc for the WSDL

5. Created a BusSrvc to build the hierarchy to send the numbers over to .net.Also, note in the program below how you define the variable type as number. This is new in Siebel and helps to improve the performance.

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var svc;
var psInputs;
var psOutputs;
var outputListOfNum;
var getNumbersResponse;
var outputAddNum ;
var num_result;
var Rev_1:Number;
var Rev_2:Number;


try
{
if(MethodName == 'Invoke WS')
{
svc = TheApplication().GetService("ServiceSoap_1");


psInputs = TheApplication().NewPropertySet();
psOutputs = TheApplication().NewPropertySet();


psInputs.SetType("AddNumbersSoapIn:parameters");
psInputs.SetProperty("MessageId","");
psInputs.SetProperty("MessageType","Integration Object");
psInputs.SetProperty("IntObjectName","AddNumbers");
psInputs.SetProperty("IntObjectFormat","Siebel Hierarchical");

var pchild = TheApplication().NewPropertySet();
var pchild1 = TheApplication().NewPropertySet();

Rev_1 =ToNumber(Inputs.GetProperty("Revenue I"));
Rev_2 =ToNumber(Inputs.GetProperty("Revenu II"));

pchild.SetType("ListOfAddNumbers");
pchild1.SetType("AddNumbers");
pchild1.SetProperty("lnNumber1",Rev_1);
pchild1.SetProperty("lnNumber2",Rev_2);

pchild.AddChild(pchild1);
psInputs.AddChild(pchild);


Outputs.AddChild(psInputs);

return(CancelOperation);


}// if(MethodName == 'Invoke WS')

else if (MethodName == 'ParseReturn')
{
if (Inputs.GetChildCount() > 0)
{
getNumbersResponse = Inputs.GetChild(0);
if (getNumbersResponse.GetType() == "AddNumbersSoapOut:parameters")
{
if (getNumbersResponse.GetChildCount() > 0)
{
outputListOfNum = getNumbersResponse.GetChild(0);
if (outputListOfNum.GetType() == "ListOfAddNumbersResponse")
{
if (outputListOfNum.GetChildCount() > 0)
{
outputAddNum = outputListOfNum.GetChild(0);
if (outputAddNum.GetType() == "AddNumbersResponse")
num_result = outputAddNum.GetProperty("AddNumbersResult");
Outputs.SetProperty("AddResponse",num_result);
}
}

}
}
}

return(CancelOperation);

}


else
return (ContinueOperation);

}//try

catch(e)
{
//calling a function to handle the error, with event name and error object as inputs

throw(e);
}
finally
{
}

}

6. Created a workflow to :
• Build Hirerachy
• Invoke Web Service
• Parse return from .net
• Update Siebel for the result from .net




It works perfect.So that’s all it is. I should say it was easy to integrate Siebel with .net than Java. More in next.