Example usage for javax.xml.soap SOAPException getClass

List of usage examples for javax.xml.soap SOAPException getClass

Introduction

In this page you can find the example usage for javax.xml.soap SOAPException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:au.edu.anu.portal.portlets.sakaiconnector.support.WebServiceSupport.java

/**
 * Make a web service call to the given endpoint, calling the method and using the params supplied
 * @param endpoint   wsdl url/*from www  .jav  a 2s .  co m*/
 * @param method   method to call
 * @param params   LinkedHashMap of params:
 *  1. Must be in order required to be sent
 *  2. Must be keyed on the parameter name to be sent, must match the webservice param exactly or it will fail
 *  3. Should contained a single Map of items, containing 'value' and 'type' keys
 *  4. The type attribute will be converted and supported values are string or boolean, case insensitive
 * 
 * @return the response, or null if any exception is thrown.
 */
public static String call(String endpoint, String method, Map<String, Map<String, String>> params) {

    Service service = new Service();

    try {
        Call nc = (Call) service.createCall();

        nc.setTargetEndpointAddress(endpoint);

        nc.removeAllParameters();
        nc.setOperationName(method);

        List<Object> values = new ArrayList<Object>();

        for (Map.Entry<String, Map<String, String>> entry : params.entrySet()) {

            //add value
            values.add(entry.getValue().get("value"));

            //setup the type
            QName qname = null;
            try {
                qname = getNameForType(entry.getValue().get("type"));
            } catch (SOAPException e) {
                e.printStackTrace();
                return null;
            }

            //add the parameter
            nc.addParameter(entry.getKey(), qname, ParameterMode.IN);

        }

        nc.setReturnType(XMLType.XSD_STRING);

        return (String) nc.invoke(values.toArray());

    } catch (RemoteException e) {
        //e.printStackTrace();
        log.error("A connection error occurred: " + e.getClass() + ": " + e.getMessage());
    } catch (ServiceException e) {
        //e.printStackTrace();
        log.error("A connection error occurred: " + e.getClass() + ": " + e.getMessage());
    }

    return null;
}