I developed the following code in 2007 for Service Desk. The code was derived originally from Peregrine supplied Incident Samples, although they are different, the setup is very similiar so I left the Peregrine Copyright notice in tact. This package is part of the webservice.interaction package is generated from the WSDL that I will post to this site.
/*
* (C) Copyright Peregrine Systems, Inc. All Rights Reserved.
*
* Modified By: Joe Morrow
* Morrow Technologies
* 05/10/2007
* Created from Incident Samples to support interactions
*
*/
package webservice.interaction;
import java.math.BigDecimal;
import java.util.Map;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.Stub;
import com.peregrine.servicecenter.PWS.InteractionInstanceType;
import com.peregrine.servicecenter.PWS.InteractionInstanceTypeDescription;
import com.peregrine.servicecenter.PWS.InteractionInstanceTypeAssignmentGroup;
import com.peregrine.servicecenter.PWS.InteractionInstanceTypeInformation;
import com.peregrine.servicecenter.PWS.InteractionKeysType;
import com.peregrine.servicecenter.PWS.ServiceDesk_PortType;
import com.peregrine.servicecenter.PWS.ServiceDesk_ServiceLocator;
import com.peregrine.servicecenter.PWS.InteractionModelType;
import com.peregrine.servicecenter.PWS.Common.MessagesType;
import com.peregrine.servicecenter.PWS.Common.StatusType;
import com.peregrine.servicecenter.PWS.Common.StringType;
import webservice.ServiceUtility;
/**
* A utility class for Interaction Management.
*/
public class ServiceDesk extends ServiceUtility
{
public static final String ARGUMENT_CALLID = "-callid";
public static final String ARGUMENT_SERVICE = "-service";
/**
* Returns an {@link InteractionKeysType} set with the Interaction id from the
* given argument map's {@link #ARGUMENT_Interaction_ID} value. If the
* argument map does not have a {@link #ARGUMENT_Interaction_ID} value,
* null will be returned.
*
* @param arguments Argument map to get values
*
* @return An {@link InteractionKeysType} with the required values set or
* null if the argument map does not have the required
* values.
*/
public static InteractionKeysType createInteractionKeys(Map arguments)
{
InteractionKeysType keys = null;
String value = (String) arguments.get(ARGUMENT_CALLID);
if (value != null)
{
keys = new InteractionKeysType();
keys.setCallID(new StringType(value));
}
return keys;
}
/**
* Returns a connection to Peregrine's Interaction Management web service
* as specified in the given argument map. The argument map is expected to
* contain values for {@link ServiceUtility#ARGUMENT_HOST},
* {@link ServiceUtility#ARGUMENT_PORT},
* {@link ServiceUtility#ARGUMENT_USERNAME},
* and {@link ServiceUtility#ARGUMENT_PASSWORD}.
*
* @param arguments Argument map to get values
*
* @return Connection to Peregrine's Interaction Management web service
*
* @throws ServiceException
*/
public static ServiceDesk_PortType createService(Map arguments)
throws ServiceException
{
ServiceDesk_PortType servicePort = null;
String host = (String) arguments.get(ARGUMENT_HOST);
String port = (String) arguments.get(ARGUMENT_PORT);
String address = "http://" + host + ":" + port + "/sc61server/ws";
ServiceDesk_ServiceLocator locator = new ServiceDesk_ServiceLocator();
locator.setServiceDeskEndpointAddress(address);
servicePort = locator.getServiceDesk();
ServiceUtility.initServiceAuthentication(((Stub) servicePort),
arguments);
ServiceUtility.initServiceForAttachments(((Stub) servicePort), arguments);
return servicePort;
}
/**
* Details the given Interaction to the given {@link StringBuffer}.
*
* @param instance The Interaction
* @param buffer The {@link StringBuffer}
*/
public static void detailInteraction(InteractionInstanceType instance,
StringBuffer buffer)
{
if (instance != null)
{
detailValue("-callid", instance.getCallID(), buffer);
detailValue("-contactname", instance.getContactName(), buffer);
detailValue("-severity", instance.getSeverity(), buffer);
detailValue("-opentime", instance.getOpenTime(), buffer);
detailValue("-updatetime", instance.getUpdateTime(), buffer);
detailValue("-openedby", instance.getOpenedBy(), buffer);
/*
value = (String) arguments.get(ARGUMENT_DESCRIPTION);
description.setDescription(new StringType[] { new StringType(value) });
*/
String value;
Integer ivalue;
int i,length;
/*---------------------------------------*/
/* Description */
/*---------------------------------------*/
InteractionInstanceTypeDescription description = new InteractionInstanceTypeDescription();
description=instance.getDescription();
if (description==null) {
detailValue("-description"," ", buffer);
}
else {
StringType[] desc=description.getDescription();
length=java.lang.reflect.Array.getLength(desc);
for (i=0;i