Willem Salembier created CXF-8938:
-------------------------------------

             Summary: CXF forces XOP for SwA SOAP services
                 Key: CXF-8938
                 URL: https://issues.apache.org/jira/browse/CXF-8938
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 3.6.2
            Reporter: Willem Salembier
         Attachments: swaref.zip

CXF seems to force xop:Include tags for web services that don't require or 
activate MTOM, but use SwA attachments.

The goal of this type is to send the document as a mime part attachment, but 
the digest of the file should just be a base64 encoded string in the SOAP body.

{code}
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="Attachment" type="swaref:swaRef"/>
                        <xsd:element name="Digest" type="xsd:base64Binary"/>
                    </xsd:sequence>
                </xsd:complexType>
{code}

CXF generates the following including a {{xop:Include}} tag for the Digest.

{code}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
        <soap:Body>
                <ns2:SecureDocument xmlns:ns2="http://playground.be/sample/v1";>
                        
<Attachment>5e0b9189-8ba0-4159-a4cd-3bac838cd...@apache.org</Attachment>
                        <Digest>
                                <xop:Include 
xmlns:xop="http://www.w3.org/2004/08/xop/include"; 
href="cid:136ebfc9-72d9-4887-8548-267a24678228-1@cxf.apache.org"/>
                        </Digest>
                </ns2:SecureDocument>
        </soap:Body>
</soap:Envelope>
{code}

This behavior seems to come from 
{{org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller}} which forces that 
any attachment list (even when it is empty) activates XOP. 

{code}
    public JAXBAttachmentMarshaller(Collection<Attachment> attachments, Integer 
mtomThreshold) {
        super();
        if (mtomThreshold != null) {
            threshold = mtomThreshold.intValue();
        }
        atts = attachments;
        isXop = attachments != null;
    }
{code}

XOP shouldn't be the default.

In {{cxf.xml}}, I tried disabling MTOM, but I cannot get rid of the XOP tags. I 
didn't find a way to retrieve and customize the {{JAXBAttachmentMarshaller}} 
instance neither.

{code}
    <jaxws:client name="{http://playground.be/sample/v1}SampleSOAP11"; 
createdFromAPI="true" address="http://localhost:8080";>
        <jaxws:properties>
            <entry key="mtom-enabled" value="false"/>
        </jaxws:properties>
    </jaxws:client>
{code}

This is my reproducer:   [^swaref.zip] 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to