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

Daniel James Matthews commented on AXIOM-357:
---------------------------------------------

Andreas, the following method can be added to 
org.apache.axiom.om.util.CopyUtilsTest.java in 
axiom\modules\axiom-tests\src\test\java\org\apache\axiom\om\util...

public void testSoap11fault() throws Exception {
        
copyAndCheck(createEnvelope(getTestResource("soap/soap11/soap11fault.xml")), 
true);
    }

This will show the bug.

A possible fix for the bug is to update the copySOAPFaultCode method in 
CopyUtils.java as follows...

private static void copySOAPFaultCode(SOAPFactory factory, 
                                          SOAPFault targetFault, 
                                          SOAPFaultCode sourceCode) {
        SOAPFaultCode targetCode = factory.createSOAPFaultCode(targetFault);
        copyTagData(sourceCode, targetCode);

        
if(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(factory.getSoapVersionURI()))
 {
                targetCode.setText(sourceCode.getText());
        } else {
                // Create the Value
            SOAPFaultValue sourceValue = sourceCode.getValue();            
            if(sourceValue != null) {
                SOAPFaultValue targetValue = 
factory.createSOAPFaultValue(targetCode);
                copyTagData(sourceValue, targetValue);
                
                // There should only be a text node for the value, but in case 
there is more
                Iterator i = sourceValue.getChildren();
                while (i.hasNext()) {
                    OMNode node = (OMNode) i.next();
                    copy(factory, targetValue, node);
                }
            }
        }

        // Now get process the SubCode
        SOAPFaultSubCode sourceSubCode = sourceCode.getSubCode();
        if (sourceSubCode != null) {
            copySOAPFaultSubCode(factory, targetCode, sourceSubCode);
        }
    }


> org.apache.axiom.om.util.CopyUtils throws NPE when used to copy a 
> SOAPEnvelope containing a SOAP 1.1 SOAPFault
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIOM-357
>                 URL: https://issues.apache.org/jira/browse/AXIOM-357
>             Project: Axiom
>          Issue Type: Bug
>         Environment: All
>            Reporter: Daniel James Matthews
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> NPE when using CopyUtils.copy on a SOAPEnvelope containing a SOAP 1.1 
> SOAPFault.
> This is because the copySOAPFaultCode method assumes that the SOAPFaultCode 
> has a Value child element, but that's only true for SOAP 1.2.
> In SOAP 1.1 the SOAPFault contains a text element, not a Value element.
> I have a patch available where I copy the text or Value based on the 
> namespace of the SOAPFactory.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to