Example usage for javax.xml.ws Holder toString

List of usage examples for javax.xml.ws Holder toString

Introduction

In this page you can find the example usage for javax.xml.ws Holder toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:se.vgregion.usdservice.USDServiceImpl.java

@Override
public String createRequest(Properties requestParameters, String userId, Collection<Attachment> attachments) {
    int sessionID = 0;
    try {//from  ww w  .j  ava  2 s .c om
        sessionID = getUSDWebService().login(wsUser, wsPassword);

        String contactHandle = lookupContactHandle(userId, sessionID);
        if (contactHandle == null) {
            // Use the wsUser as fallback if the user is unknown
            contactHandle = lookupContactHandle(wsUser, sessionID);
        }

        requestParameters.setProperty("customer", contactHandle);

        List<String> lAttributes = new ArrayList<String>();
        List<String> lAttributeValues = new ArrayList<String>();

        for (Enumeration<Object> e = requestParameters.keys(); e.hasMoreElements();) {
            String key = (String) e.nextElement();
            lAttributes.add(key);
            lAttributeValues.add(key);
            lAttributeValues.add(requestParameters.getProperty(key));
        }

        List<String> properties = Collections.<String>emptyList();

        Holder<String> reqHandle = new Holder<String>("");
        Holder<String> reqNumber = new Holder<String>("");

        String template = "";

        Holder<String> result = new Holder<String>();
        getUSDWebService().createRequest(sessionID, contactHandle, toArrayOfString(lAttributeValues),
                toArrayOfString(properties), template, toArrayOfString(lAttributes), reqHandle, reqNumber,
                result);

        String handle = null;
        try {
            handle = extractHandle(result.toString());
        } catch (Exception e) {
            throw new RuntimeException("Error parsing handle to USD incident from xml response...\n" + result,
                    e);
        }

        if (!StringUtils.isEmpty(handle)) {
            for (Attachment attachment : attachments) {
                int i = 0;
                try {
                    createAttachment(sessionID, wsAttachmentRepHandle, handle, "Attachment " + i, attachment);
                } catch (Exception e) {
                    log.error("Failed to create attachment in USD [" + attachment.getFilename() + "]");
                }
                i++;
            }

        }

        return result.toString();
    } finally {
        getUSDWebService().logout(sessionID);
    }
}