You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2013/07/26 03:02:54 UTC

[jira] [Commented] (CXF-5156) AbstractSoapInterceptor sub class not able to get hold of SOAP body from message content when it is invalid xml

    [ https://issues.apache.org/jira/browse/CXF-5156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720316#comment-13720316 ] 

Freeman Fang commented on CXF-5156:
-----------------------------------

Hi,

First of all, you really shouldn't use jira to post your questions, you should use cxf users mailling list instead.

Back to this quesiton, use code like
{code}
public void handleMessage(Message message) throws Fault {
     InputStream is = message.getContent(InputStream.class);
        if (is != null) {
            CachedOutputStream bos = new CachedOutputStream();
            try {
                IOUtils.copy(is, bos);

                bos.flush();
                is.close();
                message.setContent(InputStream.class, bos.getInputStream());
                bos.close();
                String soapMessage = new String(bos.getBytes());//this soap message is what you want
                
            } catch (IOException e) {
                throw new Fault(e);
            }
        }
{code}

should work for you no matter the incoming soap message is valid or not.

Freeman
                
> AbstractSoapInterceptor sub class not able to get hold of SOAP body from message content when it is invalid xml
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-5156
>                 URL: https://issues.apache.org/jira/browse/CXF-5156
>             Project: CXF
>          Issue Type: Bug
>            Reporter: Balaji Sengeni
>
> I have a inbound interceptor in service to get the soap message from message 
>    SOAPMessage sm = message.getContent(SOAPMessage.class)
>         ByteArrayOutputStream out = new ByteArrayOutputStream();
>         try {
>             sm.writeTo(out);
>         } catch (SOAPException e) {
>             e.printStackTrace();
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         String strMsg = new String(out.toByteArray());
>  and save 'strMsg' to database[whether it is invalid / xsd validation failed / success message..]
> But for invalid xml (or) XSD validation failure, <SOAP-ENV:Body/> is empty.
>  Phase is :
>         super(Phase.PRE_PROTOCOL);
> Please let me know, if any further information required.
> Regards,
>  Balaji 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira