So this is how my field in my DocumentContent object is defined:

@XmlElement(name="Content", namespace="##default")
@XmlMimeType("application/octet-stream")
private DataHandler content;

Then in my JUnit I switched from loading a GIF (1x1 pixel) to a simple text
file with one word in it ("test"):

        DocumentContent documentContent = new DocumentContent();
        ResourceLoader resourceLoader = new DefaultResourceLoader();
        Resource resource =
resourceLoader.getResource("classpath:sample.txt");
        DataSource dataSource = null;
        try {
            dataSource = new FileDataSource(resource.getFile());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        DataHandler dataHandler = new DataHandler(dataSource);
        //
documentContent.setContent(documentResponse.getDocumentContent().getContent());
        documentContent.setContent(dataHandler);
        documentRequest.setDocumentContent(documentContent);

        documentResponse =
docMgmtServiceRemote.addDocument(documentRequest);

I use Spring's ResourceLoader to find the sample.txt file, then use it to
get the File and create a FileDataSource (which appears to be supported). 
Then I set that data source into the DataHandler constructor and submit my
web service request via a JaxwsProxyFactoryBean configuration:

<bean id="docMgmtServiceRemote" class="com.foo.DocMgmtBusinessService" 
factory-bean="docMgmtServiceProxyFactory" factory-method="create"
lazy-init="false"/>

<bean id="docMgmtServiceProxyFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean" lazy-init="true">
       <property name="properties">
            <map>
                <entry key="mtom-enabled"
value="${docMgmtBusinessService.mtom:true}"/> 
                <entry key="mtom-threshold"
value="${docMgmtBusinessService.threshold:9024}"/> 
            </map>
        </property>
        <property name="inInterceptors" ref="logInbound"/>
            <property name="outInterceptors">
                <list>
                    <ref bean="logOutbound"/>
                </list>
            </property>
</bean>

I can change the threshold value from 1-999999+ and I see same the message
output:

Apr 23, 2012 3:54:57 PM
org.apache.cxf.interceptor.AbstractLoggingInterceptor log
INFO: Outbound Message
---------------------------
ID: 2
Address: https://foo.com/DocMgmtBusinessService
Encoding: UTF-8
Content-Type: multipart/related; type="application/xop+xml";
boundary="uuid:ddf59d1f-d89b-4e90-86f4-5e4bdbecc16d";
start="<[email protected]>"; start-info="text/xml"
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: 
--uuid:ddf59d1f-d89b-4e90-86f4-5e4bdbecc16d
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Body><ns2:addDocument
xmlns:ns2="http://foo.com/hnfs/model/dms";><ns2:DocumentRequest><ns2:DocumentContent><ns2:Content><xop:Include
xmlns:xop="http://www.w3.org/2004/08/xop/include";
href="cid:[email protected]"/></ns2:Content></ns2:DocumentContent><ns2:Filename>sample.txt</ns2:Filename></ns2:DocumentRequest></ns2:addDocument></soap:Body></soap:Envelope>
--uuid:ddf59d1f-d89b-4e90-86f4-5e4bdbecc16d
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

test
--uuid:ddf59d1f-d89b-4e90-86f4-5e4bdbecc16d--

I would have expected that the xop:Include didn't exist and that I would see
the binary stream inline, but it is not the case.

Am I attaching the file incorrectly for the threshold to work (from the
information that I have provided)?

Am I setting the mtom-threshold property incorrectly? Or calling it
incorrectly?  Because even if I set the mtom-threshold to something textual
like "test", it doesn't fail saying this isn't a numeric value.

Thanks a ton!!!


--
View this message in context: 
http://cxf.547215.n5.nabble.com/Does-JaxWsProxyFactoryBean-JAXB-support-mtom-threshold-tp5655294p5660713.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to