Here is an Example of ASP.NET calling Clarity's Query Web Service. This is useful in scenarios like .NET app wants to get Resource OBS by supplying ResourceID or say want to get Team member listing by passing in Projet ID...
Lets see first how it works...
1. Clarity creates a Web Service when a query is created. (Interesting.. Isn't it ?)
2. Any other system (.NET, Java, others ) can access this query and get data from Clarity. (if it knows Clarity login/pwd)
3. External System can supply Query Filter Criteria and get "Filtered" data from that query.
I am taking a simple example where .NET app will pass "user name" to Clarity and will in turn receive "Resource Manager". Here are the steps :
Step 1 : Create NSQL Query (QueryID = "res_manager") with two columns User Name and Resource Manager.
Step 2 : Create .NET Application, Add Web Reference to http://localhost/niku/wsdl/Query/res_manager Set Web Reference name say Q
Step 3 : Create a Webform and add Textbox to it named say TextBox1
Step 4 : Add following code in Page/Form load or under a button
------------------------------------------------------------------------
Dim QS As New Q.res_managerQueryService
Dim Q As New Q.res_managerQuery
Dim Auth As New Q.Auth
Dim Log As New Q.Login
Dim ClaritySessionID As String
Log.Username = "admin"
Log.Password = "clarity"
ClaritySessionID = QS.Login(Log)
Auth.SessionID = ClaritySessionID
Dim F As New Q.res_managerFilter
Dim QueryResult As New Q.res_managerQueryResult
Dim Rec As New Q.res_managerRecord
QS.AuthValue = Auth
Q.Code = "res_manager"
F.user_name = "jsmith"
Q.Filter = F
QueryResult = QS.Query(Q)
TextBox1.Text = QueryResult.Records(0).resource_manager_id
QS.Logout(ClaritySessionID)
--------------------------------------------------------------------------
* This example above would return only one Record as desired. For instances where multiple records are expected, you would need to loop though QueryResult.Records and get field elements.
** "MS Visual Web Developer 2008 Express Edition" is free to download..
Sunday, February 1, 2009
Subscribe to:
Posts (Atom)