You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by jaybytez <ja...@yahoo.com> on 2012/04/20 23:00:34 UTC
Does JaxWsProxyFactoryBean/JAXB support mtom-threshold?
I am using the latest JAXB and CXF 2.4.5 and am trying to test the
mtom-threshold by sending an image via a web service. It seems like no
matter what I set the mtom-threshold too...it doesn't change whether the
binary stream is added as an attachment or inline...it always adds as an
attachment.
Here is my configuration, I have bumped the mtom-threshold to significantly
large and small numbers and it makes no different for my 807 byte 1x1 pixel
gif.
Is there something I need to change in the configuration to see
mtom-threshold change how the stream is sent?
<bean id="serviceProxyFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean" lazy-init="true">
<property name="serviceClass" value="com.foo.BusinessService"/>
<property name="address"
value="${foo.url}/foo-svc-war/BusinessService"/>
<property name="properties">
<map>
<entry key="mtom-enabled">
<value type="java.lang.Boolean">true</value>
</entry>
<entry key="mtom-threshold" value="3000" />
</map>
</property>
<property name="inInterceptors" ref="logInbound"/>
<property name="outInterceptors">
<list>
<ref bean="logOutbound"/>
</list>
</property>
</bean>
--
View this message in context: http://cxf.547215.n5.nabble.com/Does-JaxWsProxyFactoryBean-JAXB-support-mtom-threshold-tp5655294p5655294.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Does JaxWsProxyFactoryBean/JAXB support mtom-threshold?
Posted by jaybytez <ja...@yahoo.com>.
Is there any JUnit test with the CXF source so I can see how the threshold
works. I still cannot get it to successfully inline the attachment based on
the threshold.
--
View this message in context: http://cxf.547215.n5.nabble.com/Does-JaxWsProxyFactoryBean-JAXB-support-mtom-threshold-tp5655294p5691571.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Does JaxWsProxyFactoryBean/JAXB support mtom-threshold?
Posted by jaybytez <ja...@yahoo.com>.
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="<ro...@cxf.apache.org>"; 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: <ro...@cxf.apache.org>
<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:b80749c5-ad48-4de1-a9f2-f2e7a899c2e4-1@healthnet.com"/></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: <b8...@healthnet.com>
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.
Re: Does JaxWsProxyFactoryBean/JAXB support mtom-threshold?
Posted by Daniel Kulp <dk...@apache.org>.
It SHOULD work. I'd likely need to see an example.
That said, it can also depend on how the image is set in the JAXB object.
Is it a byte[] or are you using DataHandler or Image or similar? In order
for the threshold to apply, it has to be a form where JAXB can actually
determine the length without consuming a stream. If you look in:
AttachmentUtil.createMtomAttachmentFromDH
you can see there is only a few types that we even try and compare the
threshold when the type is a DataHandler. You could try and add some more
types there and submit a patch.
Dan
On Friday, April 20, 2012 02:00:34 PM jaybytez wrote:
> I am using the latest JAXB and CXF 2.4.5 and am trying to test the
> mtom-threshold by sending an image via a web service. It seems like no
> matter what I set the mtom-threshold too...it doesn't change whether the
> binary stream is added as an attachment or inline...it always adds as an
> attachment.
>
> Here is my configuration, I have bumped the mtom-threshold to
> significantly large and small numbers and it makes no different for my
> 807 byte 1x1 pixel gif.
>
> Is there something I need to change in the configuration to see
> mtom-threshold change how the stream is sent?
>
> <bean id="serviceProxyFactory"
> class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean" lazy-init="true">
> <property name="serviceClass" value="com.foo.BusinessService"/>
> <property name="address"
> value="${foo.url}/foo-svc-war/BusinessService"/>
> <property name="properties">
> <map>
> <entry key="mtom-enabled">
> <value type="java.lang.Boolean">true</value>
> </entry>
> <entry key="mtom-threshold" value="3000" />
> </map>
> </property>
> <property name="inInterceptors" ref="logInbound"/>
> <property name="outInterceptors">
> <list>
> <ref bean="logOutbound"/>
> </list>
> </property>
> </bean>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Does-JaxWsProxyFactoryBean-JAXB-support-m
> tom-threshold-tp5655294p5655294.html Sent from the cxf-user mailing list
> archive at Nabble.com.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com