P-V: Retrieve a CSR with Java Web Service Calls

Intended Audience: Technical Users and Administrators of Stat

Intended Subject: Create a new CSR via Java Web Service calls

Intended Reaction: Happy Stat Customers

Keywords: Stat, Web Services, Java, CSR, Retrieve Existing CSR

Hello fellow Stat Technical Users & Administrators!

Welcome to a new year and a new series of Blog posts!

This series will focus on getting the most out of Stat integration with other systems such as retrieving an existing CSR from Stat to pass to another Help Desk System, or one of your own internal applications.

The call to retrieveCSR() is limited to just the retrieval of the CSR information. To update that same CSR you will want to call the 3rd routine in the list below which is updateCSR()

What’s the goal of this Post?

The goal of post number four is to enable your technical team to quickly retrieve an existing CSR’s through a Web Service call.

Examples of this may be:

  • When a ticket gets created in Stat, pass that CSR information to another system such as Service Now, HP Quality Center, Remedy or another Help Desk System you may want to have updated automatically from Stat or vise-versa.
  • Retrieve an existing CSR for another application – That could be to pass information to a commercial product or a home grown application.

Caution & User Reference:

If you have not worked with Stat Web Services in the past, this is not the place to begin. You’ll need to setup your environment and ensure other settings are verified.

If you are not familiar with Stat Web Services, please refer to “Appendix G: Stat Web Services” in the Stat System Administrators Guide.

You can also find sample code and further documentation on the Stat Installation CD. On the CD you will see a directory called “web_services_sample“.

In this directory is a PDF on Stat Web Services along with a Zip file called StatWS.zip The zip file contains the sample code and additional instructions on setting up your environment and running the samples included.


Let’s Go!

For this specific post we will look at retrieving an existing CSR.

Retrieve an existing CSR:

To retrieve a CSR we need to make the following Web Service call: retrieveCSR ()

For this, I’m using the same Java Source/Class file named = StatWSCSRCalls.java, and StatWSCSRCalls.class respectively.

In the StatWSCSRCalls class there are two calls available to me:

/* StatWSCSRCalls CSR Attachment Related Calls:

1 = saveNewCSR(long connectId, CSRType csr, List<AttachmentType> attachments)

2 = retrieveCSR(long connectId, String sdcd, long csrId)

3 = updateCSR(long connectId, String sdcd, long csrId)

4 = getCSRTemplateValues(long connectId, String sdcd)

5 = getApplicationDescriptionTemplate(long connectId, String sdcd, String appcode)

6 = getApplicationResolutionTemplate(long connectId, String sdcd, String appcode)

7 = getCSRTypeDescriptionTemplate(long connectId, String sdcd, String appcode)

8 = getCSRTypeResolutionTemplate(long connectId, String sdcd, String appcode)


Remembering that we need to first establish a connection to the Stat Web Service as part of the process, we will pass in our User Id and Password along with the call to make.

For the test environment that would be:


My actual call is %JAXWS_RUN_COMMAND% StatWSCSRCalls WIN-52C9JR1VJH7 8080 MyUserID MyPassword 2

Here’s a screenshot of the Java call running: (RetrieveCSRCall_Mrkd.jpg)



Let’s see the results within Stat:

After the call we can look at the output and ensure it is what we expected by comparing the output to the above screenshot (CSR133InStat_Mrkd.jpg)



Now let’s see what’s happening in the code:

We will use the CSRType bean again for this call along with the AttachmentType we used in the previous blog posts.

Here’s the CSR Type Bean:

// --------------------------------------------------------------

Begin CSRType Bean/Class:

<xsd:complexType name="CSRType">


<xsd:element name="sdcd" type="xsd:string" />

<xsd:element name="csrId" type="xsd:long" />

<xsd:element name="applicationCode" type="xsd:string" />

<xsd:element name="environmentCode" type="xsd:string" />

<xsd:element name="customerId" type="xsd:string" />

<xsd:element name="csrTypeCode" type="xsd:string" />

<xsd:element name="workflowId" type="xsd:string" />

<xsd:element name="statusCode" type="xsd:string" />

<xsd:element name="queueId" type="xsd:string" />

<xsd:element name="assignedToId" type="xsd:string" />

<xsd:element name="priorityCode" type="xsd:string" />

<xsd:element name="openedById" type="xsd:string" />

<xsd:element name="title" type="xsd:string" />

<xsd:element name="openDate" type="xsd:dateTime" />

<xsd:element name="dueDate" type="xsd:dateTime" />

<xsd:element name="closeDate" type="xsd:dateTime" />

<xsd:element name="description" type="xsd:string" />

<xsd:element name="textDescription" type="xsd:string" />

<xsd:element name="resolution" type="xsd:string" />

<xsd:element name="textResolution" type="xsd:string" />

<xsd:element name="projectCode" type="xsd:string" />

<xsd:element name="customerPriorityCode" type="xsd:string" />

<xsd:element name="trackingNumber" type="xsd:string" />

<xsd:element name="altNumber" type="xsd:string" />



// End CSR Type Bean/Class
// --------------------------------------------------------------

Here’s the call: *1, *2

%JAXWS_RUN_COMMAND% StatWSCSRCalls WIN-52C9JR1VJH7 8080 MyUserID MyPassword 2


public static void main(String[] args) throws Exception {


... Set variables, make connection, and the like...


case 2: // Do retrieveCSR:

// ===================================================================================

// 2 = retrieveCSR (long connectId, String sdcd, long csrId)

// User will call this method to retrieve the content of a CSR from Stat.

// Input Parameters:

// connectId - A valid connect Id obtained by calling WSLoginService.connect.

// sdcd - Service Domain Code.

// csrId - CSR Id Number.

// Return Parameter:

// A CSRType() representing the retrieved CSR Field Values

// ===================================================================================

System.out.println(" ");

System.out.println("Call #" + calltorun + ": retrieveCSR...");

System.out.println(" ");

try {

//Create the CSRType csr for the CSR Data - Unpopulated:

CSRType csr = new CSRType();


csr.getSdcd; // Service Domain Code.

csr.getCustomerId; // Customer ID #.

csr.getCustomerPriorityCode // Cust Priority Code.

csr.getApplicationCode // Application Code.

csr.getEnvironmentCode; // Environ Code or Leave Blank.

csr.getOpenedById; // UserID Code.

csr.getProjectCode; // Project Code.

csr.getTitle; // Text Title.

csr.getCsrTypeCode; // CSR Type Code.

csr.getStatusCode; // Status Code.

csr.getPriorityCode; // Priority Code.

csr.getWorkflowId; // Workflow ID.

csr.getQueueId; // Queue ID.

csr.getAssignedToId; // User ID in Queue.

csr.getDescription; // Description Field Text.

csr.getTextDescription; // Description Format Text.

csr.getResolution; // Resolution Text

csr.getTextResolution; // Resolution Format.

csr.getAltNumber; // Alt Phone # Code.

csr.getTrackingNumber; // Tracking Number Value.



// ---------------------------------------------------------

// Set SDCode & CSR # Values: (Hardcoded for Blog Space & Readability.)

Integer csrId = 133; // This is the CSR we Created in Blog Post # Four.

// ---------------------------------------------------------

// Do Call: csrPort.retrieveCSR(connectId, sdcd, csrId);

csr = csrPort.retrieveCSR(connectId, sdcd, csrId);


System.out.println("CSR Data For CSR: " + sdcd + "-" + csrId);


System.out.println("Service Domain = " + csr.getSdcd() + ", CSR Type = " + csr.getCsrTypeCode() + ", Priority Code = " + csr.getPriorityCode() + ", Assigned To Id = " + csr.getAssignedToId() + " ... ");

} catch(WSCsrFault e) {

WSCsrFaultType ue = e.getFaultInfo();

System.out.println("ERROR: Call = retrieveCSR. Error = " + ue.getMessage());






... Remaining Series of Calls and Code Close...


} // end switch (calltorun)

System.out.println(" ");

System.out.println("Java Web Service Call Completed Successfully.");

System.out.println(" ");



And that’s it!

With roughly 100 lines of code we set and established a connection to Stat, we then retrieved the CSR information and output parts of it to the screen for viewing.

We also took into consideration error control and user feedback/output.

The above code set is not a complete standalone app. With the proper imports, variables, and a few other wrappers, it would still not be more than 100 lines or so.

*1 If you would like a copy of the sample code used here, please see the Documents section of the Stat User Community.

*2 I do not profess to be a pro at Java, but more of a Java noob. Please excuse any blatant coding mishaps.


In Closing…

In the next post we will move on to another area of Stat Web Services. Stay Tuned!

Thank you for taking the time to read this post. I hope you found it informative.



William R. Hart

Solutions Architect


Dell | Quest Group, Pre-Sales