P-IV: Create 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, Create New

 

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 creating a new CSR from another Help Desk System, or one of your own internal applications.

What’s the goal of this Post?

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

Examples of this may be:

  • When a ticket gets created in Service Now, HP Quality Center, Remedy or another Help Desk System you may want to have that ticket created automatically in Stat or vise-versa.
  • Create a new CSR from another application – That could be 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 creating a new CSR.

Create a new CSR:

To create a CSR we need to make the following Web Service call: saveNewCSR()

For this, I’m using a 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:

%JAXWS_RUN_COMMAND% StatWSCSRCalls %HOSTNAME% %WSPORT% %USERID% %PASSWORD% %CALL_2_RUN%

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

Here’s a screenshot of the Java call running: 

 

Let’s see the results within Stat:

Before adding a new CSR we’ll take a look at the currently existing ones so we can see which one gets created:


 

After creating the new CSR we can see we’ve successfully created a new one:

 

 

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

Here’s the CSR Type Bean:

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

Begin CSRType Bean/Class:

<xsd:complexType name="CSRType">

<xsd:sequence>

<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" />

</xsd:sequence>

</xsd:complexType>

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

Here’s the call: *1, *2

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

 

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

 

… Set Variables and the like…

 

case 1: // Do saveNewCSR

//Call: Users will call this method to save a new CSR in Stat.

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

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

// Users will call this method to save a new CSR in Stat.

// Input Parameters:

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

// csr - CSRType Bean.

// attachments - AttachmentType Bean.

// Return Parameter: Long (CSRID)

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

System.out.println(" ");

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

System.out.println(" ");

try {

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

//Create & Populate the CSRType csr data

CSRType csr = new CSRType();

csr.setSdcd("HRS"); // Enter Valid Service Domain Code.

csr.setCustomerId("9"); // Enter Valid Customer ID #.

csr.setCustomerPriorityCode("WCRT"); // Enter Valid Cust Priority Code.

csr.setApplicationCode("HRMSC"); // Enter Valid Application Code.

csr.setEnvironmentCode(""); // Enter Valid Environ Code or Leave Blank.

csr.setOpenedById("WRHART"); // Enter Valid UserID Code.

csr.setProjectCode(""); // Enter Valid Project Code.

csr.setTitle("CSR From Blog P-IV CSR Create"); // Enter Valid Text Title.

csr.setCsrTypeCode("EMR"); // Enter Valid CSR Type Code.

csr.setStatusCode("Propd"); // Enter Valid Status Code.

csr.setPriorityCode("CRIT"); // Enter Valid Priority Code.

csr.setWorkflowId("2"); // Enter Valid Workflow ID.

csr.setQueueId("FuncOwners"); // Enter Valid Queue ID.

csr.setAssignedToId("WRHART"); // Enter Valid User ID in Queue.

csr.setDescription("CSR Description"); // Enter Description Format Code.

csr.setTextDescription("CSR Description Txt"); // Enter Description Text.

csr.setResolution("Resolution"); // Enter Resolution Format

csr.setTextResolution("Resolution Text"); // Enter Resolution Text.

csr.setAltNumber("949-754-8000"); // Enter Valid Alt Phone # Code.

csr.setTrackingNumber("949-TRACK#"); // Enter Valid Tracking Number Value.

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

 

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

// Set & Populate AttachmentType attachments: (OPTIONAL)

List<AttachmentType> attList = new ArrayList<AttachmentType>();

 

AttachmentType att = new AttachmentType();

DataHandler content = new DataHandler(new FileDataSource("C:/Temp/BillAttached_0.txt"));

att.setComments("This is BillAttached_0.txt file.");

att.setFilename("BillAttached_0.txt");

att.setContentType("text/plain");

att.setContent(content);

attList.add(att);

 

 

//Enable MTOM on client side:

SOAPBinding binding = (SOAPBinding)((BindingProvider)csrPort).getBinding();

binding.setMTOMEnabled(true);

 

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

// Do Call: saveNewCSR:

long csrId = csrPort.saveNewCSR(connectId, csr, attList);

System.out.println("===================================");

System.out.println(" CSR ID Created: " + csrId);

System.out.println("===================================");

} catch(WSCsrFault e) {

WSCsrFaultType ue = e.getFaultInfo();

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

return;

}

break;

 

// ... next series of calls...

} // 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 created a new CSR, taking 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.

One more key point:

With all processes and activities that are done within Stat or through the Stat Web Service calls, all activities are captured for Auditing and Reporting.

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.

Respectfully,

 

William R. Hart

Solutions Architect

William.Hart@quest.com

Dell | Quest Group, Pre-Sales

Anonymous