Search in sources :

Example 41 with SOAPMessageContext

use of javax.xml.ws.handler.soap.SOAPMessageContext in project jbossws-cxf by jbossws.

the class SOAP11ClientHandler method getContentType.

protected ContentType getContentType(MessageContext msgContext) {
    ContentType contentType = null;
    try {
        // Metro does not process this header into the message
        @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
        List<String> ctype = (headers == null) ? null : headers.get("Content-Type");
        if (ctype == null) {
            // Cxf stores it in lower case
            ctype = (headers == null) ? null : headers.get("content-type");
        }
        log.info("ctype=" + ctype);
        if (ctype == null) {
            // Native has already processed this header into the message
            SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
            MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
            String[] ct = mimeHeaders.getHeader("Content-Type");
            log.info("ct=" + ct);
            if (ct != null) {
                contentType = new ContentType(ct[0]);
            }
        } else {
            contentType = new ContentType(ctype.get(0));
        }
    } catch (ParseException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessage(javax.xml.soap.SOAPMessage) MimeHeaders(javax.xml.soap.MimeHeaders) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) List(java.util.List) ParseException(javax.mail.internet.ParseException) Map(java.util.Map)

Example 42 with SOAPMessageContext

use of javax.xml.ws.handler.soap.SOAPMessageContext in project jbossws-cxf by jbossws.

the class SOAP11ServerHandler method getContentType.

protected ContentType getContentType(MessageContext msgContext) {
    ContentType contentType = null;
    try {
        // Metro does not process this header into the message
        @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
        List<String> ctype = (headers == null) ? null : headers.get("Content-Type");
        if (ctype == null) {
            // Cxf stores it in lower case
            ctype = (headers == null) ? null : headers.get("content-type");
        }
        log.info("ctype=" + ctype);
        if (ctype == null) {
            // Native has already processed this header into the message
            SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
            MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
            String[] ct = mimeHeaders.getHeader("Content-Type");
            log.info("ct=" + ct);
            if (ct != null) {
                contentType = new ContentType(ct[0]);
            }
        } else {
            contentType = new ContentType(ctype.get(0));
        }
    } catch (ParseException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessage(javax.xml.soap.SOAPMessage) MimeHeaders(javax.xml.soap.MimeHeaders) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) List(java.util.List) ParseException(javax.mail.internet.ParseException) Map(java.util.Map)

Example 43 with SOAPMessageContext

use of javax.xml.ws.handler.soap.SOAPMessageContext in project jbossws-cxf by jbossws.

the class SOAP12ClientHandler method getContentType.

protected ContentType getContentType(MessageContext msgContext) {
    ContentType contentType = null;
    try {
        // Metro does not process this header into the message
        @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
        List<String> ctype = (headers == null) ? null : headers.get("Content-Type");
        if (ctype == null) {
            // Cxf stores it in lower case
            ctype = (headers == null) ? null : headers.get("content-type");
        }
        log.info("ctype=" + ctype);
        if (ctype == null) {
            // Native has already processed this header into the message
            SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
            MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
            String[] ct = mimeHeaders.getHeader("Content-Type");
            log.info("ct=" + ct);
            if (ct != null) {
                contentType = new ContentType(ct[0]);
            }
        } else {
            contentType = new ContentType(ctype.get(0));
        }
    } catch (ParseException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessage(javax.xml.soap.SOAPMessage) MimeHeaders(javax.xml.soap.MimeHeaders) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) List(java.util.List) ParseException(javax.mail.internet.ParseException) Map(java.util.Map)

Example 44 with SOAPMessageContext

use of javax.xml.ws.handler.soap.SOAPMessageContext in project jbossws-cxf by jbossws.

the class SOAP12ServerHandler method getContentType.

protected ContentType getContentType(SOAPMessageContext msgContext) {
    ContentType contentType = null;
    try {
        // Metro does not process this header into the message
        @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
        List<String> ctype = (headers == null) ? null : headers.get("Content-Type");
        if (ctype == null) {
            // Cxf stores it in lower case
            ctype = (headers == null) ? null : headers.get("content-type");
        }
        log.info("ctype=" + ctype);
        if (ctype == null) {
            // Native has already processed this header into the message
            SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
            MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
            String[] ct = mimeHeaders.getHeader("Content-Type");
            log.info("ct=" + ct);
            if (ct != null) {
                contentType = new ContentType(ct[0]);
            }
        } else {
            contentType = new ContentType(ctype.get(0));
        }
    } catch (ParseException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
Also used : ContentType(javax.mail.internet.ContentType) WebServiceException(javax.xml.ws.WebServiceException) SOAPMessage(javax.xml.soap.SOAPMessage) MimeHeaders(javax.xml.soap.MimeHeaders) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) List(java.util.List) ParseException(javax.mail.internet.ParseException) Map(java.util.Map)

Example 45 with SOAPMessageContext

use of javax.xml.ws.handler.soap.SOAPMessageContext in project jbossws-cxf by jbossws.

the class SOAP12ServerHandler 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_2_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_2_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)

Aggregations

SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)45 SOAPMessage (javax.xml.soap.SOAPMessage)33 WebServiceException (javax.xml.ws.WebServiceException)24 SOAPException (javax.xml.soap.SOAPException)22 SOAPElement (javax.xml.soap.SOAPElement)18 Test (org.junit.Test)13 SOAPBody (javax.xml.soap.SOAPBody)12 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)10 QName (javax.xml.namespace.QName)7 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)7 IOException (java.io.IOException)6 List (java.util.List)6 Set (java.util.Set)6 ContentType (javax.mail.internet.ContentType)6 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)6 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)6 Handler (javax.xml.ws.handler.Handler)6 MessageContext (javax.xml.ws.handler.MessageContext)6 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)6 ArrayList (java.util.ArrayList)5