Search in sources :

Example 21 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class SOAP11ClientHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    try {
        SOAPEnvelope soapEnvelope = msgContext.getMessage().getSOAPPart().getEnvelope();
        String nsURI = soapEnvelope.getNamespaceURI();
        log.info("nsURI=" + nsURI);
        if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI)) {
            return false;
        }
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
    ContentType contentType = getContentType(msgContext);
    if (contentType != null) {
        log.info("contentType=" + contentType);
        String startInfo = contentType.getParameter("start-info");
        if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE)) {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ContentType(javax.mail.internet.ContentType) SOAPException(javax.xml.soap.SOAPException) SOAPEnvelope(javax.xml.soap.SOAPEnvelope)

Example 22 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class SOAP11ServerHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    ContentType contentType = getContentType(msgContext);
    if (contentType != null) {
        log.info("contentType=" + contentType);
        String startInfo = contentType.getParameter("start-info");
        if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE)) {
            return false;
        }
    } else {
        return false;
    }
    try {
        SOAPEnvelope soapEnvelope = ((SOAPMessageContext) msgContext).getMessage().getSOAPPart().getEnvelope();
        String nsURI = soapEnvelope.getNamespaceURI();
        log.info("nsURI=" + nsURI);
        if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI)) {
            return false;
        }
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
    return true;
}
Also used : ContentType(javax.mail.internet.ContentType) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) SOAPException(javax.xml.soap.SOAPException) SOAPEnvelope(javax.xml.soap.SOAPEnvelope)

Example 23 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class SOAP12ClientHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    try {
        SOAPEnvelope soapEnvelope = msgContext.getMessage().getSOAPPart().getEnvelope();
        String nsURI = soapEnvelope.getNamespaceURI();
        log.info("nsURI=" + nsURI);
        if (!SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(nsURI)) {
            return false;
        }
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
    ContentType contentType = getContentType(msgContext);
    if (contentType != null) {
        log.info("contentType=" + contentType);
        String startInfo = contentType.getParameter("start-info");
        if (!startInfo.equals(SOAPConstants.SOAP_1_2_CONTENT_TYPE)) {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ContentType(javax.mail.internet.ContentType) SOAPException(javax.xml.soap.SOAPException) SOAPEnvelope(javax.xml.soap.SOAPEnvelope)

Example 24 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class ClientHandler method handleInbound.

public boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleInbound");
    try {
        SOAPEnvelope soapEnvelope = (SOAPEnvelope) msgContext.getMessage().getSOAPPart().getEnvelope();
        String nsURI = soapEnvelope.getNamespaceURI();
        log.info("nsURI=" + nsURI);
        if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI)) {
            throw new RuntimeException("Wrong NS uri: " + nsURI);
        }
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
    ContentType contentType = getContentType(msgContext);
    if (contentType != null) {
        log.info("contentType=" + contentType);
        String startInfo = contentType.getParameter("start-info");
        if (!checkMtom) {
            if (startInfo != null) {
                throw new RuntimeException("Unexpected multipart/related message!");
            } else {
                return true;
            }
        }
        if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE)) {
            throw new RuntimeException("Wrong start info: " + startInfo);
        }
    } else {
        throw new RuntimeException("Missing content type");
    }
    return true;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ContentType(javax.mail.internet.ContentType) SOAPException(javax.xml.soap.SOAPException) SOAPEnvelope(javax.xml.soap.SOAPEnvelope)

Example 25 with SOAPEnvelope

use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.

the class JBWS1815TestCase method testProviderMessage.

@Test
@RunAsClient
public void testProviderMessage() throws Exception {
    SOAPMessage reqMsg = getRequestMessage();
    URL epURL = new URL(baseURL + "/jaxws-jbws1815/ProviderImpl");
    SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage resMsg = con.call(reqMsg, epURL);
    SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
    Detail detail = resEnv.getBody().getFault().getDetail();
    assertNotNull(detail);
    SOAPElement exception = (SOAPElement) detail.getDetailEntries().next();
    assertNotNull(exception);
    assertEquals("MyWSException", exception.getElementQName().getLocalPart());
    assertEquals("http://www.my-company.it/ws/my-test", exception.getElementQName().getNamespaceURI());
    SOAPElement message = (SOAPElement) exception.getChildElements().next();
    assertNotNull(message);
    assertEquals("message", message.getNodeName());
    assertEquals("This is a faked error", message.getValue());
}
Also used : SOAPElement(javax.xml.soap.SOAPElement) SOAPConnection(javax.xml.soap.SOAPConnection) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) Detail(javax.xml.soap.Detail) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

SOAPEnvelope (javax.xml.soap.SOAPEnvelope)59 SOAPMessage (javax.xml.soap.SOAPMessage)34 SOAPException (javax.xml.soap.SOAPException)31 SOAPBody (javax.xml.soap.SOAPBody)24 SOAPPart (javax.xml.soap.SOAPPart)24 SOAPElement (javax.xml.soap.SOAPElement)22 SOAPHeader (javax.xml.soap.SOAPHeader)16 Name (javax.xml.soap.Name)13 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)13 Iterator (java.util.Iterator)12 QName (javax.xml.namespace.QName)12 WebServiceException (javax.xml.ws.WebServiceException)10 ProtocolException (javax.xml.ws.ProtocolException)7 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)6 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)6 Detail (javax.xml.soap.Detail)5 MessageFactory (javax.xml.soap.MessageFactory)5 SOAPConnection (javax.xml.soap.SOAPConnection)5 SOAPFault (javax.xml.soap.SOAPFault)5 Test (org.junit.Test)5