Example usage for javax.xml.ws.soap SOAPBinding setMTOMEnabled

List of usage examples for javax.xml.ws.soap SOAPBinding setMTOMEnabled

Introduction

In this page you can find the example usage for javax.xml.ws.soap SOAPBinding setMTOMEnabled.

Prototype

public void setMTOMEnabled(boolean flag);

Source Link

Document

Enables or disables use of MTOM.

Usage

From source file:eu.planets_project.ifr.core.servreg.utils.client.PlanetsCommand.java

/**
 * //from   w  w w .ja  va 2 s. c  o  m
 * @param args
 */
public static void main(String[] args) {

    /* FIXME, point to log4j.properties instead of doing this? */
    /*
    java.util.logging.Logger.getLogger("com.sun.xml.ws.model").setLevel(java.util.logging.Level.WARNING); 
    java.util.logging.Logger.getAnonymousLogger().setLevel(java.util.logging.Level.WARNING);
    Logger sunlogger = Logger.getLogger("com.sun.xml.ws.model");
    sunlogger.setLevel(Level.WARNING);
    java.util.logging.Logger.getLogger( com.sun.xml.ws.util.Constants.LoggingDomain).setLevel(java.util.logging.Level.WARNING);
    */
    /* Lots of info please: */
    java.util.logging.Logger.getAnonymousLogger().setLevel(java.util.logging.Level.FINEST);
    java.util.logging.Logger.getLogger(com.sun.xml.ws.util.Constants.LoggingDomain)
            .setLevel(java.util.logging.Level.FINEST);
    // TODO See https://jax-ws.dev.java.net/guide/Logging.html for info on more logging to set up.
    //System.setProperty("com.sun.xml.ws.transport.local.LocalTransportPipe.dump","true");
    //System.setProperty("com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.dump","true");
    //System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump","true");
    // Doing this KILLS STREAMING. Log that.
    //System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump","true");

    URL wsdl;
    try {
        wsdl = new URL(args[0]);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return;
    }

    PlanetsServiceExplorer pse = new PlanetsServiceExplorer(wsdl);

    System.out.println(".describe(): " + pse.getServiceDescription());

    Service service = Service.create(wsdl, pse.getQName());
    //service.addPort(portName, SOAPBinding.SOAP11HTTP_MTOM_BINDING, endpointAddress)
    PlanetsService ps = (PlanetsService) service.getPort(pse.getServiceClass());

    // TODO The client wrapper code should enforce this stuff:
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) ps).getBinding();
    System.out.println("Logging MTOM=" + binding.isMTOMEnabled());
    ((BindingProvider) ps).getRequestContext().put(JAXWSProperties.MTOM_THRESHOLOD_VALUE, 8192);
    ((BindingProvider) ps).getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
    System.out.println("Logging MTOM=" + binding.isMTOMEnabled());
    binding.setMTOMEnabled(true);
    System.out.println("Logging MTOM=" + binding.isMTOMEnabled());
    //System.out.println("Logging MTOM="+((BindingProvider)ps).getBinding().getBindingID()+" v. "+SOAPBinding.SOAP11HTTP_MTOM_BINDING);

    /* 
     * The different services are invoked in different ways...
     */
    if (pse.getQName().equals(Migrate.QNAME)) {
        System.out.println("Is a Migrate service. ");
        Migrate s = MigrateWrapper.createWrapper(wsdl);

        DigitalObject dobIn = new DigitalObject.Builder(Content.byReference(new File(args[1]))).build();

        MigrateResult result = s.migrate(dobIn, URI.create(args[2]), URI.create(args[3]), null);

        System.out.println("ServiceReport: " + result.getReport());

        DigitalObjectUtils.toFile(result.getDigitalObject(), new File("output"));

    } else if (pse.getQName().equals(Identify.QNAME)) {
        System.out.println("Is an Identify service. ");
        Identify s = new IdentifyWrapper(wsdl);

        DigitalObject dobIn = new DigitalObject.Builder(Content.byReference(new File(args[1]))).build();

        IdentifyResult result = s.identify(dobIn, null);

        System.out.println("ServiceReport: " + result.getReport());
    }
}

From source file:de.extra.extraClientLight.util.SendWebService.java

/**
 * /*from ww  w .j  a  va 2  s.c  o  m*/
 * @param extraRequest
 * @param url
 * @param mtomActive
 * @return
 */
public TransportResponseType sendRequest(TransportRequestType extraRequest, String url, boolean mtomActive) {
    TransportResponseType response = new TransportResponseType();

    Extra_Service extraService = new Extra_Service(null, SERVICE_NAME);

    Extra extraPort = extraService.getPort(Extra.class);
    BindingProvider bp = (BindingProvider) extraPort;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

    SOAPBinding soapBinding = (SOAPBinding) bp.getBinding();
    soapBinding.setMTOMEnabled(mtomActive);

    try {
        LOGGER.debug("Versand gestartet...");
        response = extraPort.execute(extraRequest);
        LOGGER.debug("...Empfang Response");

        if (mtomActive) {
            Collection<Attachment> attachmentList = (Collection<Attachment>) bp.getResponseContext()
                    .get(Message.ATTACHMENTS);

            LOGGER.debug("Attachments: " + attachmentList.size());

        }
    } catch (SOAPFaultException e) {
        SOAPFault soapFault = e.getFault();

        LOGGER.error(soapFault.getTextContent(), e);

    } catch (ExtraFault e) {
        ExtraErrorHelper.printExtraError(e);
    }

    return response;

}

From source file:com.tangfan.test.UserServiceTest.java

@Before
public void init() {
    try {//from w w w  .ja v  a 2 s. c om
        URL url = new URL("http://localhost:8085/soap/us?wsdl");
        QName qName = new QName(ns, "UserService");
        ws = new UserService_Service(url, qName);
        //         port = ws.getUserServicePort(new MTOMFeature());
        port = ws.getUserServicePort();
        BindingProvider bp = (BindingProvider) port;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}

From source file:org.apache.servicemix.camel.nmr.AttachmentTest.java

private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface,
        boolean enableMTOM) throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(bus);//  w  w w .j  a  va 2  s. c o  m
    serviceFactory.setServiceName(serviceName);
    serviceFactory.setServiceClass(serviceEndpointInterface);
    serviceFactory.setWsdlURL(getClass().getResource("/wsdl/mtom_xop.wsdl"));
    Service service = serviceFactory.create();
    EndpointInfo ei = service.getEndpointInfo(portName);
    JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
    SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
    jaxWsSoapBinding.setMTOMEnabled(enableMTOM);

    Client client = new ClientImpl(bus, jaxwsEndpoint);
    InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
    Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(),
            new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
    return serviceEndpointInterface.cast(obj);
}

From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java

/**
 * Get mime type of document from DTL/*from  w  w w .  j av  a 2s .  c  o m*/
 * @param docId The document id
 * @param dtlUrl The url of dtl
 * @return The mime type
 */
private String getDocumentMimeFromDtl(String docId, String eDtlUrl) throws Exception {
    URL url = null;
    try {
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        if (eDtlUrl.equalsIgnoreCase(dtlUrl))
            return docservice.getDocumentMime(docId, "");
        else
            return docservice.getDocumentMime(docId, eDtlUrl);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in getDocumentFromDtl", e);
    }
}

From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java

/**
 * Update document in DTL// w w w .j  a  v  a  2  s . c o m
 * @param docData The docment data
 * @param docId The document ID
 * @param signResponse The signature response
 * @return True if successful
 * @throws SimpleException
 */
private boolean updateDocumentInDtl(byte[] docData, String docId, String signResponse) throws Exception {
    boolean success = false;
    URL url = null;
    try {
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        success = docservice.updateDocument(docId, signResponse, docData);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in updateDocumentInDtl", e);
    }

    return success;
}

From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java

/**
   * Get document from DTL// w  ww  .j av  a2 s  . c  o  m
   * @param transferRequest The transfer request (attribute query)
   * @param eDtlUrl The DTL url of external DTL
   * @return the document data
   * @throws SimpleException
   */
private byte[] getDocumentFromDtl(String transferRequest, String eDtlUrl) throws Exception {
    URL url = null;
    try {
        Logger.debug("getDocumentFromDtl:" + dtlUrl);
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        if (eDtlUrl.equalsIgnoreCase(dtlUrl))
            return docservice.getDocument(transferRequest, "");
        else
            return docservice.getDocument(transferRequest, eDtlUrl);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in getDocumentFromDtl", e);
    }
}

From source file:at.gv.egovernment.moa.id.auth.servlet.PEPSConnectorServlet.java

/**
   * Get document from DTL//from   www  .jav a 2  s  .  co m
   * @param transferRequest The transfer request (attribute query)
   * @param eDtlUrl The DTL url of external DTL
   * @return the document data
   * @throws SimpleException
   */
private byte[] getDocumentFromDtl(String transferRequest, String eDtlUrl) throws Exception {
    URL url = null;
    try {
        Logger.debug("getDocumentFromDtl, dtlUrl:'" + dtlUrl + "' eDtlUrl:'" + eDtlUrl + "'");
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        if (eDtlUrl.equalsIgnoreCase(dtlUrl))
            return docservice.getDocument(transferRequest, "");
        else
            return docservice.getDocument(transferRequest, eDtlUrl);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in getDocumentFromDtl", e);
    }
}

From source file:com.mirth.connect.connectors.ws.WebServiceMessageDispatcher.java

private void processMessage(MessageObject mo) throws Exception {
    /*//from  w ww . j  ava  2  s  . c  o  m
     * Initialize the dispatch object if it hasn't been initialized yet, or
     * create a new one if the connector properties have changed due to
     * variables.
     */
    createDispatch(mo);

    SOAPBinding soapBinding = (SOAPBinding) dispatch.getBinding();

    if (connector.isDispatcherUseAuthentication()) {
        dispatch.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, currentUsername);
        dispatch.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, currentPassword);
        logger.debug("Using authentication: username=" + currentUsername + ", password length="
                + currentPassword.length());
    }

    // See: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
    String soapAction = replacer.replaceValues(connector.getDispatcherSoapAction(), mo);

    if (StringUtils.isNotEmpty(soapAction)) {
        dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction);
    }

    // build the message
    logger.debug("Creating SOAP envelope.");
    String content = replacer.replaceValues(connector.getDispatcherEnvelope(), mo);
    Source source = new StreamSource(new StringReader(content));
    SOAPMessage message = soapBinding.getMessageFactory().createMessage();
    message.getSOAPPart().setContent(source);

    if (connector.isDispatcherUseMtom()) {
        soapBinding.setMTOMEnabled(true);

        List<String> attachmentIds = connector.getDispatcherAttachmentNames();
        List<String> attachmentContents = connector.getDispatcherAttachmentContents();
        List<String> attachmentTypes = connector.getDispatcherAttachmentTypes();

        for (int i = 0; i < attachmentIds.size(); i++) {
            String attachmentContentId = replacer.replaceValues(attachmentIds.get(i), mo);
            String attachmentContentType = replacer.replaceValues(attachmentTypes.get(i), mo);
            String attachmentContent = replacer.replaceValues(attachmentContents.get(i), mo);

            AttachmentPart attachment = message.createAttachmentPart();
            attachment.setBase64Content(new ByteArrayInputStream(attachmentContent.getBytes("UTF-8")),
                    attachmentContentType);
            attachment.setContentId(attachmentContentId);
            message.addAttachmentPart(attachment);
        }
    }

    message.saveChanges();

    // make the call
    String response = null;
    if (connector.isDispatcherOneWay()) {
        logger.debug("Invoking one way service...");
        dispatch.invokeOneWay(message);
        response = "Invoked one way operation successfully.";
    } else {
        logger.debug("Invoking web service...");
        SOAPMessage result = dispatch.invoke(message);
        response = sourceToXmlString(result.getSOAPPart().getContent());
    }
    logger.debug("Finished invoking web service, got result.");

    // process the result
    messageObjectController.setSuccess(mo, response, null);

    // send to reply channel
    if (connector.getDispatcherReplyChannelId() != null
            && !connector.getDispatcherReplyChannelId().equals("sink")) {
        new VMRouter().routeMessageByChannelId(connector.getDispatcherReplyChannelId(), response, true);
    }
}

From source file:com.mirth.connect.connectors.ws.WebServiceDispatcher.java

@Override
public Response send(ConnectorProperties connectorProperties, ConnectorMessage connectorMessage) {
    WebServiceDispatcherProperties webServiceDispatcherProperties = (WebServiceDispatcherProperties) connectorProperties;

    eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
            getDestinationName(), ConnectionStatusEventType.SENDING));

    String responseData = null;//  ww w . j  a v a2s. c  o m
    String responseError = null;
    String responseStatusMessage = null;
    Status responseStatus = Status.QUEUED;
    boolean validateResponse = false;

    try {
        long dispatcherId = getDispatcherId();
        DispatchContainer dispatchContainer = dispatchContainers.get(dispatcherId);
        if (dispatchContainer == null) {
            dispatchContainer = new DispatchContainer();
            dispatchContainers.put(dispatcherId, dispatchContainer);
        }

        /*
         * Initialize the dispatch object if it hasn't been initialized yet, or create a new one
         * if the connector properties have changed due to variables.
         */
        createDispatch(webServiceDispatcherProperties, dispatchContainer);

        Dispatch<SOAPMessage> dispatch = dispatchContainer.getDispatch();

        configuration.configureDispatcher(this, webServiceDispatcherProperties, dispatch.getRequestContext());

        SOAPBinding soapBinding = (SOAPBinding) dispatch.getBinding();

        if (webServiceDispatcherProperties.isUseAuthentication()) {
            String currentUsername = dispatchContainer.getCurrentUsername();
            String currentPassword = dispatchContainer.getCurrentPassword();

            dispatch.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, currentUsername);
            dispatch.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, currentPassword);
            logger.debug("Using authentication: username=" + currentUsername + ", password length="
                    + currentPassword.length());
        }

        // See: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
        String soapAction = webServiceDispatcherProperties.getSoapAction();

        if (StringUtils.isNotEmpty(soapAction)) {
            dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true); // MIRTH-2109
            dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction);
        }

        // Get default headers
        Map<String, List<String>> requestHeaders = new HashMap<String, List<String>>(
                dispatchContainer.getDefaultRequestHeaders());

        // Add custom headers
        if (MapUtils.isNotEmpty(webServiceDispatcherProperties.getHeaders())) {
            for (Entry<String, List<String>> entry : webServiceDispatcherProperties.getHeaders().entrySet()) {
                List<String> valueList = requestHeaders.get(entry.getKey());

                if (valueList == null) {
                    valueList = new ArrayList<String>();
                    requestHeaders.put(entry.getKey(), valueList);
                }

                valueList.addAll(entry.getValue());
            }
        }

        dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);

        // build the message
        logger.debug("Creating SOAP envelope.");
        AttachmentHandlerProvider attachmentHandlerProvider = getAttachmentHandlerProvider();
        String content = attachmentHandlerProvider.reAttachMessage(webServiceDispatcherProperties.getEnvelope(),
                connectorMessage);
        Source source = new StreamSource(new StringReader(content));
        SOAPMessage message = soapBinding.getMessageFactory().createMessage();
        message.getSOAPPart().setContent(source);

        if (webServiceDispatcherProperties.isUseMtom()) {
            soapBinding.setMTOMEnabled(true);

            List<String> attachmentIds = webServiceDispatcherProperties.getAttachmentNames();
            List<String> attachmentContents = webServiceDispatcherProperties.getAttachmentContents();
            List<String> attachmentTypes = webServiceDispatcherProperties.getAttachmentTypes();

            for (int i = 0; i < attachmentIds.size(); i++) {
                String attachmentContentId = attachmentIds.get(i);
                String attachmentContentType = attachmentTypes.get(i);
                String attachmentContent = attachmentHandlerProvider.reAttachMessage(attachmentContents.get(i),
                        connectorMessage);

                AttachmentPart attachment = message.createAttachmentPart();
                attachment.setBase64Content(new ByteArrayInputStream(attachmentContent.getBytes("UTF-8")),
                        attachmentContentType);
                attachment.setContentId(attachmentContentId);
                message.addAttachmentPart(attachment);
            }
        }

        message.saveChanges();

        if (StringUtils.isNotBlank(webServiceDispatcherProperties.getLocationURI())) {
            dispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                    webServiceDispatcherProperties.getLocationURI());
        }

        boolean redirect = false;
        int tryCount = 0;

        /*
         * Attempt the invocation until we hit the maximum allowed redirects. The redirections
         * we handle are when the scheme changes (i.e. from HTTP to HTTPS).
         */
        do {
            redirect = false;
            tryCount++;

            try {
                DispatchTask<SOAPMessage> task = new DispatchTask<SOAPMessage>(dispatch, message,
                        webServiceDispatcherProperties.isOneWay());
                SOAPMessage result;

                /*
                 * If the timeout is set to zero, we need to do the invocation in a separate
                 * thread. This is because there's no way to get a reference to the underlying
                 * JAX-WS socket, so there's no way to forcefully halt the dispatch. If the
                 * socket is truly hung and the user halts the channel, the best we can do is
                 * just interrupt and ignore the thread. This means that a thread leak is
                 * potentially introduced, so we need to notify the user appropriately.
                 */
                if (timeout == 0) {
                    // Submit the task to an executor so that it's interruptible
                    Future<SOAPMessage> future = executor.submit(task);
                    // Keep track of the task by adding it to our set
                    dispatchTasks.add(task);
                    result = future.get();
                } else {
                    // Call the task directly
                    result = task.call();
                }

                if (webServiceDispatcherProperties.isOneWay()) {
                    responseStatusMessage = "Invoked one way operation successfully.";
                } else {
                    responseData = sourceToXmlString(result.getSOAPPart().getContent());
                    responseStatusMessage = "Invoked two way operation successfully.";
                }
                logger.debug("Finished invoking web service, got result.");

                // Automatically accept message; leave it up to the response transformer to find SOAP faults
                responseStatus = Status.SENT;
            } catch (Throwable e) {
                // Unwrap the exception if it came from the executor
                if (e instanceof ExecutionException && e.getCause() != null) {
                    e = e.getCause();
                }

                // If the dispatch was interrupted, make sure to reset the interrupted flag
                if (e instanceof InterruptedException) {
                    Thread.currentThread().interrupt();
                }

                Integer responseCode = null;
                String location = null;

                if (dispatch.getResponseContext() != null) {
                    responseCode = (Integer) dispatch.getResponseContext()
                            .get(MessageContext.HTTP_RESPONSE_CODE);

                    Map<String, List<String>> headers = (Map<String, List<String>>) dispatch
                            .getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
                    if (MapUtils.isNotEmpty(headers)) {
                        List<String> locations = headers.get("Location");
                        if (CollectionUtils.isNotEmpty(locations)) {
                            location = locations.get(0);
                        }
                    }
                }

                if (tryCount < MAX_REDIRECTS && responseCode != null && responseCode >= 300
                        && responseCode < 400 && StringUtils.isNotBlank(location)) {
                    redirect = true;

                    // Replace the endpoint with the redirected URL
                    dispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);
                } else {
                    // Leave the response status as QUEUED for NoRouteToHostException and ConnectException, otherwise ERROR
                    if (e instanceof NoRouteToHostException
                            || ((e.getCause() != null) && (e.getCause() instanceof NoRouteToHostException))) {
                        responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("HTTP transport error",
                                e);
                        responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(),
                                "HTTP transport error", e);
                        eventController.dispatchEvent(
                                new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(),
                                        ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(),
                                        connectorProperties.getName(), "HTTP transport error.", e));
                    } else if ((e.getClass() == ConnectException.class) || ((e.getCause() != null)
                            && (e.getCause().getClass() == ConnectException.class))) {
                        responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("Connection refused.",
                                e);
                        eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(),
                                connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR,
                                getDestinationName(), connectorProperties.getName(), "Connection refused.", e));
                    } else {
                        if (e instanceof SOAPFaultException) {
                            try {
                                responseData = new DonkeyElement(((SOAPFaultException) e).getFault()).toXml();
                            } catch (DonkeyElementException e2) {
                            }
                        }
                        responseStatus = Status.ERROR;
                        responseStatusMessage = ErrorMessageBuilder
                                .buildErrorResponse("Error invoking web service", e);
                        responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(),
                                "Error invoking web service", e);
                        eventController.dispatchEvent(
                                new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(),
                                        ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(),
                                        connectorProperties.getName(), "Error invoking web service.", e));
                    }
                }
            }
        } while (redirect && tryCount < MAX_REDIRECTS);
    } catch (Exception e) {
        responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("Error creating web service dispatch",
                e);
        responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(),
                "Error creating web service dispatch", e);
        eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(),
                connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(),
                connectorProperties.getName(), "Error creating web service dispatch.", e));
    } finally {
        eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(),
                getDestinationName(), ConnectionStatusEventType.IDLE));
    }

    return new Response(responseStatus, responseData, responseStatusMessage, responseError, validateResponse);
}