Using Siebel CRM On Demand Web Services in Microsoft.NET

1) Create a new windows application.

2) Put the following code in the form load

private void Form1_Load(object sender, EventArgs e)

{

string loginUrlString = https://servername/Services/Integration?command=login”;

String sessionID = ManageSession.Login(loginUrlString, @”orgname-devusername”, “password”);

}

3) Define the login method within ManageSession class in the following manner


public static string SessionID = “”;

public static String Login(String loginUrlString, String userName, String password)

{

try

{

// create a http request and set the headers for authentication

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(loginUrlString);

HttpWebResponse myResponse;

myRequest.Method = “POST”;

// passing username and password in the http header

// username format if it includes slash should be the forward slash /

myRequest.Headers[“UserName”] = userName;

myRequest.Headers[“Password”] = password;

myResponse = (HttpWebResponse)myRequest.GetResponse();

Stream sr = myResponse.GetResponseStream();

// retrieve session id

char[] sep = { ‘;’ };

String[] headers = myResponse.Headers[“Set-Cookie”].Split(sep);

for (int i=0; i <= headers.Length-1; i++)

{

if (headers[i].StartsWith(“JSESSIONID”))

{

sep[0] = ‘=’;

SessionID = headers[i].Split(sep)[1];

break;

}

}

sr.Close();

myResponse.Close();

}

catch (WebException webException)

{

}

catch (Exception ex)

{

}

// send back the session id that should be passed to subsequent calls

// to webservices

return SessionID;

}

That’s it..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

6 thoughts on “Using Siebel CRM On Demand Web Services in Microsoft.NET”

  1. I tried it out and wrote the code using one of your articles which is;
    https://nishantrana.wordpress.com/2009/03/23/updating-account-record-using-oraclesiebel-crm-on-demand-web-service-in-net/

    Now I have a main function called InsertAccount in which I am calling another function called GetAccountName which actually calls the webservice functions.

    InsertAccount just inserts the values in SQL Server using SqlCommand and SqlConnection objects.

    In GetAccountName function I have used AccountQueryPage in place of AccountUpdate as in your article.

    The first error is “the name ManageSession doesn’t exist in the current context”

    … whereas it is done exactly the same in your article at above link.

    Secondly, the line myAccUpdateInput.ListOfAccount = myLstOfAcctData; …. is giving error because the datatype of ListOfAccount in AccountQueryPage_Input is ListOfAccountQuery.

    Other than ManageSession thing, I think all I am missing is the sequence of calls.

    Please comment.

    Like

  2. Hi,
    Create a new project in Visual studio it could be windows application or webapplication.
    You can select the project name, right click on it, and select add web reference, there you could pass on the location of your wsdl files. It would create a proxy class, which you can use.

    Using the proxy class first you could retrieve the values for your entities.
    And the using SqlConnection,SqlCommand object in .NET you could save it in your SQL server database.

    Like

  3. Hi Nishat,

    I am trying to use webservices in SIEBEL CRM on Demand to extract data and store it in an in-house SQL Server 2005 system.

    All I have is WSDL files that I downloaded from Siebel CRM on Demand web interface, one for every entity.

    Can you please comment on how to use these WSDL files in SQL Server 2005(and Visual Studio if required) to extract data.

    Thanks,
    Owais

    Like

  4. That’s great – except SessionID is undefined in this code, as it is in the Oracle manual. A small oversight, perhaps, but shouldn’t they test this stuff before they print it?

    Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s