Monday, September 8, 2008

To invoke a Wolf based SaaS application from a .NET program

Hi Friends,

Recently we designed a small web based billing application for our partner using our Wolf XML Platform. The partner needed the billing application to work with their existing product, which can be accessed online. So here's the simple .Net Web Services & how to invoke it from your application for you.

The first thing was to authenticate the user using the login ID and password from the application.The second thing was to invoke a business rule of our application & it will give the output in xml format. And the last thing was to use web service since it is independent of OS ,independent of programming languages and easy to use. Here are the steps, you should try when you get time :)

Steps to invoke a webservice in our application:

First step:
create a windows application and click on the solution explorer window & then click on webreferences then enter the url of webservice http://www.wolfframeworks.com/webservices/wf.session/session.asmx?wsdl
this url is for login authentication.

Second step:

add a reference to this url http://www.wolfframeworks.com/webservices/wf.object/businessrules.asmx?wsdl

Third step:

//code to authenticate user id & login
/******************************************/
private void button1_Click(object sender, EventArgs e)
{
WolfSession.Session obj = new WolfSession.Session();
try
{
this.Cursor = Cursors.WaitCursor;
System.Net.CookieContainer c = new System.Net.CookieContainer();
obj.CookieContainer = c;
string s = obj.IsUserAuthenticated("your login id","your login password","application id");
//application id You can see the application id in the Run URL. Please refer to the ?appid= querystring parameter.
MessageBox.Show(s);
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
this.Cursor = Cursors.Default;
}
/***********************************************/

Fourth step:

//code to invoke a business rule
private void button2_Click(object sender, EventArgs e)
{
WolfSession.Session obj = new WolfSession.Session();
try
{
this.Cursor = Cursors.WaitCursor;
System.Net.CookieContainer c = new System.Net.CookieContainer();
obj.CookieContainer = c;
string s = obj.IsUserAuthenticated("your login id", "login password", "application id");
/*--------------------------------------------------------------*/
wolfbusiness.BusinessRules obj1 = new wolfbusiness.BusinessRules();
try
{
this.Cursor = Cursors.WaitCursor;
obj1.CookieContainer = c;
string var = "";
string x = obj1.processbusinessrule("name of the business rule", var);
MessageBox.Show(x);
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
this.Cursor = Cursors.Default;
}
}
Last step press F5

click on first button it will give ur expected output in xml format
true
if ur login id & password is correct
false
if ur login id & password is wrong
click on second button it will give ur expected output in xml format.

All the best and dont forget to send me your feedback...

SharpDeveloper

No comments: