Friday, August 29, 2008

[7] ASP.NET Calling Clarity Web Services - Code Example

Here is an Example of ASP.NET calling Clarity Web Services ( Here ASP.NET Calls Project XOG to get properties of a Particular Project )

Steps :-

1. Add Web reference http://localhost/niku/wsdl/Object/Projects and name it as PRJ


2. Create a New "ASP.NET Web application Project". Create a Multiline Textbox in it say Textbox1 ( To display XOG output )

3. On the PageLoad event add following :-

Dim PS As New PRJ.ProjectsService
Dim Log As New PRJ.Login
Dim Auth As New PRJ.Auth

Dim SoapXML As New System.Xml.XmlDocument
Dim DataBus As System.Xml.XmlElement
Dim XOGOutput As System.Xml.XmlElement
Dim sessionId As String

Log.Password = "admin"
Log.Username = "admin"
sessionId = PS.Login(Log)
Auth.SessionID = sessionId
PS.AuthValue = Auth

SoapXML.Load("c:\xog\Read_project.xml")

XOGOutput = PS.ReadProject(SoapXML.DocumentElement)
TextBox1.Text = XOGOutput.InnerXml

PS.Logout(sessionId)

4. Read_Project.xml looks like as below :-
---------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<NikuDataBus xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
<Header version="6.0.11" action="read" objectType="project" externalSource="NIKU">
<!-- you change the order by simply swap 1 and 2 number in the name attribute -->
<args name="order_by_1" value="name"/>
<args name="order_by_2" value="projectID"/>
<args name="include_tasks" value="false"/>
<args name="include_resources" value="false"/>
<args name="include_custom" value="false"/>
<args name="include_dependencies" value="false"/>
</Header>
<Query>
<Filter name="projectID" criteria="EQUALS">Clarity_test</Filter>
</Query>
</NikuDataBus>

------------------------------------------------------------------------------

* This was tested on Clarity 7.5.3.