Example usage for javax.xml.soap SOAPMessage getSOAPBody

List of usage examples for javax.xml.soap SOAPMessage getSOAPBody

Introduction

In this page you can find the example usage for javax.xml.soap SOAPMessage getSOAPBody.

Prototype

public SOAPBody getSOAPBody() throws SOAPException 

Source Link

Document

Gets the SOAP Body contained in this SOAPMessage object.

Usage

From source file:com.nortal.jroad.mapping.XTeeEndpointMapping.java

@Override
protected Object getEndpointInternal(MessageContext messageCtx) throws Exception {
    SOAPMessage message = SOAPUtil.extractSoapMessage(messageCtx.getRequest());
    if (message.getSOAPHeader() != null) {
        AbstractXTeeBaseEndpoint endpoint = methodMap.get(getRequestMethod(message.getSOAPHeader()));
        if (endpoint != null) {
            if (log.isDebugEnabled()) {
                log.debug("Matched " + endpoint + " to " + endpoint.getClass().getSimpleName());
            }// www .j  a v  a2  s . c o  m
            return endpoint;
        }
    }

    try {
        if (SOAPUtil.getNodeByXPath(message.getSOAPBody(), "/*/*/*[local-name()='listMethods']") != null) {
            log.debug("Matched headerless listMethods request.");
            return getApplicationContext()
                    .getBean(getApplicationContext().getBeanNamesForType(ListMethodsEndpoint.class)[0]);
        }
    } catch (NullPointerException e) {
        // ListMethods lookup failed
    }
    return null;
}

From source file:io.hummer.util.ws.WebServiceClient.java

private SOAPMessage createSOAPMessage(Element request, List<Element> headers, String protocol)
        throws Exception {
    MessageFactory mf = MessageFactory.newInstance(protocol);
    SOAPMessage message = mf.createMessage();
    SOAPBody body = message.getSOAPBody();

    // check if we have a complete soap:Envelope as request..
    String ns = request.getNamespaceURI();
    if (request.getTagName().contains("Envelope")) {
        if (ns.equals("http://schemas.xmlsoap.org/soap/envelope/"))
            message = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage(
                    new MimeHeaders(), new ByteArrayInputStream(xmlUtil.toString(request).getBytes()));
        if (ns.equals("http://www.w3.org/2003/05/soap-envelope"))
            message = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage(
                    new MimeHeaders(), new ByteArrayInputStream(xmlUtil.toString(request).getBytes()));

    } else {/*from w ww  . j  a  va 2 s .  c om*/
        xmlUtil.appendChild(body, request);
    }
    for (Element h : headers) {
        xmlUtil.appendChild(message.getSOAPHeader(), h);
    }
    for (Element h : eprParamsAndProps) {
        xmlUtil.appendChild(message.getSOAPHeader(), h);
    }
    xmlUtil.appendChild(message.getSOAPHeader(), xmlUtil.toElement(
            "<wsa:To xmlns:wsa=\"" + EndpointReference.NS_WS_ADDRESSING + "\">" + endpointURL + "</wsa:To>"));
    message.saveChanges();
    return message;
}

From source file:com.fortify.bugtracker.tgt.archer.connection.ArcherAuthenticatingRestConnection.java

public Long addValueToValuesList(Long valueListId, String value) {
    LOG.info("[Archer] Adding value '" + value + "' to value list id " + valueListId);
    // Adding items to value lists is not supported via REST API, so we need to revert to SOAP API
    // TODO Simplify this method?
    // TODO Make this method more fail-safe (like checking for the correct response element)?
    Long result = null;//from  ww w  . j av  a2  s. c om
    try {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        SOAPPart soapPart = message.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPElement bodyElement = body.addChildElement(
                envelope.createName("CreateValuesListValue", "", "http://archer-tech.com/webservices/"));
        bodyElement.addChildElement("sessionToken").addTextNode(tokenProviderRest.getToken());
        bodyElement.addChildElement("valuesListId").addTextNode(valueListId + "");
        bodyElement.addChildElement("valuesListValueName").addTextNode(value);
        message.saveChanges();

        SOAPMessage response = executeRequest(HttpMethod.POST,
                getBaseResource().path("/ws/field.asmx").request()
                        .header("SOAPAction", "\"http://archer-tech.com/webservices/CreateValuesListValue\"")
                        .accept("text/xml"),
                Entity.entity(message, "text/xml"), SOAPMessage.class);
        @SuppressWarnings("unchecked")
        Iterator<Object> it = response.getSOAPBody().getChildElements();
        while (it.hasNext()) {
            Object o = it.next();
            if (o instanceof SOAPElement) {
                result = new Long(((SOAPElement) o).getTextContent());
            }
        }
        System.out.println(response);
    } catch (SOAPException e) {
        throw new RuntimeException("Error executing SOAP request", e);
    }
    return result;
}

From source file:io.hummer.util.ws.WebServiceClient.java

private InvocationResult doInvokeSOAP(Element request, List<Element> headers, int retries, String protocol,
        int connectTimeoutMS, int requestTimeoutMS) throws Exception {
    if (retries < 0)
        throw new Exception("Invocation to " + endpointURL + " failed: " + xmlUtil.toString(request));

    // if the service is null here because the WSDL is unavailable, 
    // create a plain HTTP POST invocation..
    if (service == null) {
        return doInvokePOST(request, new HashMap<String, String>(), retries);
    }//from w  w w . java2s  .  c o  m

    Dispatch<SOAPMessage> dispatch = null;
    synchronized (service) {
        dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
    }

    dispatch.getRequestContext().put("com.sun.xml.ws.connect.timeout", connectTimeoutMS);
    dispatch.getRequestContext().put("com.sun.xml.ws.request.timeout", requestTimeoutMS);
    dispatch.getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", connectTimeoutMS);
    dispatch.getRequestContext().put("com.sun.xml.internal.ws.request.timeout", requestTimeoutMS);
    dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
            Collections.singletonMap("Connection", Collections.singletonList("close")));

    try {
        SOAPMessage message = createSOAPMessage(request, headers, protocol);
        String tmpID = PerformanceInterceptor.event(EventType.START_SEND_INVOCATION);
        SOAPMessage response = dispatch.invoke(message);
        PerformanceInterceptor.event(EventType.FINISH_SEND_INVOCATION, tmpID);
        InvocationResult result = new InvocationResult(response.getSOAPBody());
        return result;
    } catch (Exception e) {
        if (!(e.getCause() instanceof ThreadDeath)) {
            //logger.warn("Exception in invocation; to: " + endpointURL + "; " + e);
        }

        if (retries <= 0) {
            throw new Exception("Invocation to " + endpointURL + " failed: " + xmlUtil.toString(request), e);
        }
        if (e instanceof BindException || e.getCause() instanceof BindException) {
            long sleep = 200L + (long) (Math.random() * 800);
            logger.warn("Cannot bind to (client) port, sleeping " + sleep);
            Thread.sleep(sleep);
        }
        request = xmlUtil.clone(request);
        return doInvokeSOAP(request, headers, retries - 1, protocol, connectTimeoutMS, requestTimeoutMS);
    } finally {
        //PerformanceInterceptor.event(EventType.FINISH_INVOCATION, eID);
        //System.out.println(eID + " finished " + endpointURL);
    }
}

From source file:org.jasig.portal.security.provider.saml.SAMLDelegatedAuthenticationService.java

/**
 * Assume that the InputStream has a SOAP fault message and return a String
 * suitable to present as an exception message
 *  /*from w  w  w  .ja  v a  2  s. c o  m*/
 * @param is InputStream that contains a SOAP message
 * @return String containing a formated error message
 * 
 * @throws IOException
 * @throws SOAPException
 */
private String getSOAPFaultAsString(InputStream is) throws IOException, SOAPException {
    is.reset();
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage(null, is);
    SOAPBody body = message.getSOAPBody();

    if (body.hasFault()) {
        SOAPFault fault = body.getFault();
        String code, string, actor;
        code = fault.getFaultCode();
        string = fault.getFaultString();
        actor = fault.getFaultActor();
        String formatedMessage = "SOAP transaction resulted in a SOAP fault.";

        if (code != null)
            formatedMessage += "  Code=\"" + code + ".\"";

        if (string != null)
            formatedMessage += "  String=\"" + string + ".\"";

        if (actor != null)
            formatedMessage += "  Actor=\"" + actor + ".\"";

        return formatedMessage;
    }
    return null;
}

From source file:ee.ria.xroad.proxy.serverproxy.ProxyMonitorServiceHandlerTest.java

@Test
public void startHandingShouldProduceAllMetrics() throws Exception {

    // setup//w  w  w . j av a2 s .co m
    ProxyMonitorServiceHandlerImpl handlerToTest = new ProxyMonitorServiceHandlerImpl();

    final SoapMessageImpl soapMessage = build(DEFAULT_OWNER_CLIENT, MONITOR_SERVICE_ID, "testUser",
            randomUUID().toString());

    when(mockProxyMessage.getSoap()).thenReturn(soapMessage);
    when(mockProxyMessage.getSoapContent())
            .thenReturn(new ByteArrayInputStream(soapMessage.getXml().getBytes(soapMessage.getCharset())));

    handlerToTest.canHandle(MONITOR_SERVICE_ID, mockProxyMessage);

    final String expectedMetricsSetName = "someName";

    MetricSetType metricSetType = new MetricSetType();
    metricSetType.setName(expectedMetricsSetName);

    final List<MetricType> metrics = metricSetType.getMetrics();

    StringMetricType type = new StringMetricType();
    final String expectedMetricName = "metricName123-23";
    type.setName(expectedMetricName);

    final String expectedMetricValue = "123SomeValue";
    type.setValue(expectedMetricValue);
    metrics.add(type);

    MonitorClient mockMonitorClient = PowerMockito.mock(MonitorClient.class);
    PowerMockito.when(mockMonitorClient.getMetrics(anyList())).thenReturn(metricSetType);

    RestoreMonitorClientAfterTest.setMonitorClient(mockMonitorClient);

    // execution
    handlerToTest.startHandling(mockRequest, mockProxyMessage, mock(HttpClient.class),
            mock(OpMonitoringData.class));

    //verification
    assertThat("Wrong content type", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8));

    final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent());

    final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue();

    assertThat("Response client does not match", xrHeader.getClient(), is(DEFAULT_OWNER_CLIENT));
    assertThat("Response client does not match", xrHeader.getService(), is(MONITOR_SERVICE_ID));

    final MetricSetType root = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(),
            GetSecurityServerMetricsResponse.class, () -> unmarshaller).getMetricSet();
    // root metrics should have the security server id as name
    assertThat("Metrics set name does not match", root.getName(), is(DEFAULT_OWNER_SERVER.toString()));

    final List<MetricType> responseMetrics = root.getMetrics();
    assertThat("Missing proxy version from metrics", responseMetrics,
            hasItem(hasProperty("name", is("proxyVersion"))));

    assertThat("Missing the expected metrics set", responseMetrics, hasItem(instanceOf(MetricSetType.class)));

    final MetricSetType responseDataMetrics = (MetricSetType) responseMetrics.stream() // we just asserted this..
            .filter(m -> m instanceof MetricSetType).findFirst().orElseThrow(IllegalStateException::new);

    assertThat(responseDataMetrics.getName(), is(expectedMetricsSetName));
    assertThat(responseDataMetrics.getMetrics().size(), is(1));

    final StringMetricType responseMetric = (StringMetricType) responseDataMetrics.getMetrics().get(0);
    assertThat("Wrong metric name", responseMetric.getName(), is(expectedMetricName));
    assertThat("Wrong metric value", responseMetric.getValue(), is(expectedMetricValue));
}

From source file:ee.ria.xroad.proxy.serverproxy.ProxyMonitorServiceHandlerTest.java

/**
 * As above but only environmental parameters defined in outputSpec.
 *
 * @throws Exception/*from w  w  w .j  a  v  a  2s .c  om*/
 */
@Test
public void startHandingShouldProduceRequestedMetrics() throws Exception {

    // setup
    ProxyMonitorServiceHandlerImpl handlerToTest = new ProxyMonitorServiceHandlerImpl();

    final SoapMessageImpl soapMessage = build(false, DEFAULT_OWNER_CLIENT, MONITOR_SERVICE_ID, "testUser",
            randomUUID().toString(),
            new MetricsQueryBuilder(Arrays.asList("proxyVersion", "CommittedVirtualMemory", "DiskSpaceFree")));

    when(mockProxyMessage.getSoap()).thenReturn(soapMessage);
    when(mockProxyMessage.getSoapContent())
            .thenReturn(new ByteArrayInputStream(soapMessage.getXml().getBytes(soapMessage.getCharset())));

    handlerToTest.canHandle(MONITOR_SERVICE_ID, mockProxyMessage);

    final String expectedMetricsSetName = "someName";

    MetricSetType metricSetType = new MetricSetType();
    metricSetType.setName(expectedMetricsSetName);

    final List<MetricType> metrics = metricSetType.getMetrics();

    StringMetricType type = new StringMetricType();
    final String expectedMetricName = "metricName123-23";
    type.setName(expectedMetricName);

    final String expectedMetricValue = "123SomeValue";
    type.setValue(expectedMetricValue);
    metrics.add(type);

    MonitorClient mockMonitorClient = PowerMockito.mock(MonitorClient.class);
    PowerMockito.when(mockMonitorClient.getMetrics(org.mockito.Matchers.anyList())).thenReturn(metricSetType);

    RestoreMonitorClientAfterTest.setMonitorClient(mockMonitorClient);

    // execution
    handlerToTest.startHandling(mockRequest, mockProxyMessage, mock(HttpClient.class),
            mock(OpMonitoringData.class));

    //verification
    assertThat("Wrong content type", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8));

    final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent());

    final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue();

    assertThat("Response client does not match", xrHeader.getClient(), is(DEFAULT_OWNER_CLIENT));
    assertThat("Response client does not match", xrHeader.getService(), is(MONITOR_SERVICE_ID));

    final MetricSetType root = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(),
            GetSecurityServerMetricsResponse.class, () -> unmarshaller).getMetricSet();
    // root metrics should have the security server id as name
    assertThat("Metrics set name does not match", root.getName(), is(DEFAULT_OWNER_SERVER.toString()));

    final List<MetricType> responseMetrics = root.getMetrics();
    assertThat("Missing proxy version from metrics", responseMetrics,
            hasItem(hasProperty("name", is("proxyVersion"))));

    assertThat("Missing the expected metrics set", responseMetrics, hasItem(instanceOf(MetricSetType.class)));

    final MetricSetType responseDataMetrics = (MetricSetType) responseMetrics.stream() // we just asserted this..
            .filter(m -> m instanceof MetricSetType).findFirst().orElseThrow(IllegalStateException::new);

    assertThat(responseDataMetrics.getName(), is(expectedMetricsSetName));
    assertThat(responseDataMetrics.getMetrics().size(), is(1));

    final StringMetricType responseMetric = (StringMetricType) responseDataMetrics.getMetrics().get(0);
    assertThat("Wrong metric name", responseMetric.getName(), is(expectedMetricName));
    assertThat("Wrong metric value", responseMetric.getValue(), is(expectedMetricValue));
}

From source file:ee.ria.xroad.proxy.serverproxy.MetadataServiceHandlerTest.java

@Test
public void shouldHandleListMethods() throws Exception {

    // setup/*  w  w  w .ja va 2  s.  c  o m*/
    List<ServiceId> expectedServices = Arrays.asList(ServiceId.create(DEFAULT_CLIENT, "getNumber"),
            ServiceId.create(DEFAULT_CLIENT, "helloThere"), ServiceId.create(DEFAULT_CLIENT, "putThings"));

    final ClientId expectedClient = DEFAULT_CLIENT;
    final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, LIST_METHODS);

    ServerConf.reload(new TestServerConf() {
        @Override
        public List<ServiceId> getAllServices(ClientId serviceProvider) {
            assertThat("Client id does not match expected", serviceProvider, is(expectedClient));
            return expectedServices;
        }
    });

    MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();

    InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId)
            .withModifiedBody(
                    soapBody -> soapBody.addChildElement(LIST_METHODS_REQUEST).addChildElement(REQUEST))
            .buildAsInputStream();

    when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);

    handlerToTest.canHandle(serviceId, mockProxyMessage);

    // execution

    handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));

    // verification
    assertThat("Content type does not match", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8));

    final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent());

    final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue();

    List<ServiceId> resultServices = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(),
            MethodListType.class).getService();

    assertThat("Response client does not match", xrHeader.getClient(), is(expectedClient));
    assertThat("Response client does not match", xrHeader.getService(), is(serviceId));

    assertThat("Wrong amount of services", resultServices.size(), is(expectedServices.size()));

    assertThat("Wrong services", resultServices, containsInAnyOrder(expectedServices.toArray()));
}

From source file:ee.ria.xroad.proxy.serverproxy.MetadataServiceHandlerTest.java

@Test
public void shouldHandleAllowedMethods() throws Exception {

    // setup//from  w  w  w  .  j  a v a  2 s  .c  o m
    List<ServiceId> expectedServices = Arrays.asList(ServiceId.create(DEFAULT_CLIENT, "getNumber"),
            ServiceId.create(DEFAULT_CLIENT, "helloThere"), ServiceId.create(DEFAULT_CLIENT, "putThings"));

    final ClientId expectedClient = DEFAULT_CLIENT;
    final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, ALLOWED_METHODS);

    ServerConf.reload(new TestServerConf() {

        @Override
        public List<ServiceId> getAllowedServices(ClientId serviceProvider, ClientId client) {

            assertThat("Wrong client in query", client, is(expectedClient));

            assertThat("Wrong service provider in query", serviceProvider, is(serviceId.getClientId()));

            return expectedServices;
        }
    });

    MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();

    InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId)
            .withModifiedBody(
                    soapBody -> soapBody.addChildElement(ALLOWED_METHODS_REQUEST).addChildElement(REQUEST))
            .buildAsInputStream();

    when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);

    handlerToTest.canHandle(serviceId, mockProxyMessage);

    // execution

    handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));

    // verification
    assertThat("Content type does not match", handlerToTest.getResponseContentType(), is(TEXT_XML_UTF8));

    final SOAPMessage message = messageFactory.createMessage(null, handlerToTest.getResponseContent());

    final SoapHeader xrHeader = unmarshaller.unmarshal(message.getSOAPHeader(), SoapHeader.class).getValue();

    List<ServiceId> resultServices = verifyAndGetSingleBodyElementOfType(message.getSOAPBody(),
            MethodListType.class).getService();

    assertThat("Response client does not match", xrHeader.getClient(), is(expectedClient));
    assertThat("Response client does not match", xrHeader.getService(), is(serviceId));

    assertThat("Wrong amount of services", resultServices.size(), is(expectedServices.size()));

    assertThat("Wrong services", resultServices, containsInAnyOrder(expectedServices.toArray()));
}

From source file:com.centurylink.mdw.hub.servlet.SoapServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    CodeTimer timer = new CodeTimer("SoapServlet.doPost()", true);

    InputStream reqInputStream = request.getInputStream();
    // read the POST request contents
    String requestString = getRequestString(request);
    if (logger.isMdwDebugEnabled()) {
        logger.mdwDebug("SOAP Listener POST Request:\n" + requestString);
    }/*from w  w w  .j av a  2s .  com*/

    Map<String, String> metaInfo = buildMetaInfo(request);

    String responseString = null;
    MessageFactory factory = null;
    String soapVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
    try {
        SOAPMessage message = null;
        SOAPBody body = null;
        try {
            // Intuitively guess which SOAP version is needed
            // factory = getMessageFactory(requestString, true);
            soapVersion = getSoapVersion(requestString, true);
            factory = getSoapMessageFactory(soapVersion);
            reqInputStream = new ByteArrayInputStream(requestString.getBytes());

            message = factory.createMessage(null, reqInputStream);
            body = message.getSOAPBody();
        } catch (SOAPException e) {
            // Unlikely, but just in case the SOAP version guessing
            // has guessed incorrectly, this catches any SOAP exception,
            // in which case try the other version
            if (logger.isMdwDebugEnabled()) {
                logger.mdwDebug(
                        "SOAPListenerServlet failed to find correct Message Factory:" + "\n" + e.getMessage());
            }
            // Try with the other unintuitive MessageFactory
            // factory = getMessageFactory(requestString, false);
            soapVersion = getSoapVersion(requestString, false);
            factory = getSoapMessageFactory(soapVersion);
            reqInputStream = new ByteArrayInputStream(requestString.getBytes());

            message = factory.createMessage(null, reqInputStream);
            body = message.getSOAPBody();
            // Only 2 versions, so let any exceptions bubble up
        }
        Node childElem = null;
        Iterator<?> it = body.getChildElements();
        while (it.hasNext()) {
            Node node = (Node) it.next();
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                childElem = node;
                break;
            }
        }
        if (childElem == null)
            throw new SOAPException("SOAP body child element not found");

        String requestXml = null;

        boolean oldStyleRpcRequest = false;
        if (request.getServletPath().endsWith(RPC_SERVICE_PATH)
                || RPC_SERVICE_PATH.equals(request.getPathInfo())) {
            NodeList nodes = childElem.getChildNodes();
            for (int i = 0; i < nodes.getLength(); i++) {
                if (StringUtils.isNotBlank(nodes.item(i).getNodeName())
                        && nodes.item(i).getNodeName().equals("RequestDetails")) {
                    oldStyleRpcRequest = true;
                    Node requestNode = nodes.item(i).getFirstChild();
                    if (requestNode.getNodeType() == Node.CDATA_SECTION_NODE) {
                        requestXml = requestNode.getTextContent();
                    } else {
                        requestXml = DomHelper.toXml(requestNode);
                        if (requestXml.contains("&lt;"))
                            requestXml = StringEscapeUtils.unescapeXml(requestXml);
                    }
                }
            }
        } else {
            requestXml = DomHelper.toXml(childElem);
        }

        metaInfo = addSoapMetaInfo(metaInfo, message);
        ListenerHelper helper = new ListenerHelper();

        try {
            authenticate(request, metaInfo, requestXml);
            String handlerResponse = helper.processEvent(requestXml, metaInfo);

            try {
                // standard response indicates a potential problem
                MDWStatusMessageDocument responseDoc = MDWStatusMessageDocument.Factory.parse(handlerResponse,
                        Compatibility.namespaceOptions());
                MDWStatusMessage responseMsg = responseDoc.getMDWStatusMessage();
                if ("SUCCESS".equals(responseMsg.getStatusMessage()))
                    responseString = createSoapResponse(soapVersion, handlerResponse);
                else
                    responseString = createSoapFaultResponse(soapVersion,
                            String.valueOf(responseMsg.getStatusCode()), responseMsg.getStatusMessage());
            } catch (XmlException xex) {
                if (Listener.METAINFO_ERROR_RESPONSE_VALUE
                        .equalsIgnoreCase(metaInfo.get(Listener.METAINFO_ERROR_RESPONSE))) {
                    // Support for custom error response
                    responseString = handlerResponse;
                } else {
                    // not parseable as standard response doc (a good thing)
                    if (oldStyleRpcRequest) {
                        responseString = createOldStyleSoapResponse(soapVersion,
                                "<m:invokeWebServiceResponse xmlns:m=\"http://mdw.qwest.com/listener/webservice\"><Response>"
                                        + StringEscapeUtils.escapeXml(handlerResponse)
                                        + "</Response></m:invokeWebServiceResponse>");
                    } else {
                        responseString = createSoapResponse(soapVersion, handlerResponse);
                    }
                }
            }
        } catch (ServiceException ex) {
            logger.severeException(ex.getMessage(), ex);
            responseString = createSoapFaultResponse(soapVersion, String.valueOf(ex.getCode()),
                    ex.getMessage());
        }
    } catch (Exception ex) {
        logger.severeException(ex.getMessage(), ex);
        try {
            responseString = createSoapFaultResponse(soapVersion, null, ex.getMessage());
        } catch (Exception tex) {
            logger.severeException(tex.getMessage(), tex);
        }
    }

    if (logger.isMdwDebugEnabled()) {
        logger.mdwDebug("SOAP Listener Servlet POST Response:\n" + responseString);
    }

    if (metaInfo.get(Listener.METAINFO_CONTENT_TYPE) != null) {
        response.setContentType(metaInfo.get(Listener.METAINFO_CONTENT_TYPE));
    } else {
        if (soapVersion.equals(SOAPConstants.SOAP_1_1_PROTOCOL))
            response.setContentType(Listener.CONTENT_TYPE_XML);
        else
            response.setContentType("application/soap+xml");
    }

    response.getOutputStream().print(responseString);

    timer.stopAndLogTiming("");
}