You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex Declent <de...@gmail.com> on 2011/11/23 13:51:42 UTC
Apache CXF+MTOM sending multiple attachments
I have developed a web-service which receives multiple attachments from
a remote web-service via an CXF JAXB client (the client is called from
the service), the attachment from the remote service are, one xml
document and an undefined number of pdf documents.
When I try to add the received attachments to my web-service response
the xml document is set and only n-1 data of the received pdf documents.
Logging:
---------------------------
ID: 8
Encoding: UTF-8
Content-Type: multipart/related; type="application/xop+xml";
boundary="uuid:aeb23655-314b-4365-822c-f56f674059d8";
start="<ro...@cxf.apache.org>"; start-info="text/xml"
Headers: {}
Payload:
--uuid:aeb23655-314b-4365-822c-f56f674059d8
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>...</soap:Envelope>
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-ID: <67...@example.org>
<?xml version="1.0" encoding="UTF-8"?><ns2:Response
xmlns:ns2="ns://example.org/types">...</ns2:Response>
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <67...@example.org>
%PDF-1.4
%????
3 0 obj <</Filter/FlateDecode/Length 1137>>stream....
%%EOF
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <67...@example.org>
--uuid:aeb23655-314b-4365-822c-f56f674059d8--
Source code:
response.setXmlStream(getXmlResponseSource());
for(int i=0; i < client.getResponse().getAttachments().size(); i++){
DataHandler dh =
client.getResponse().getAttachments().get(i).getPDFOutStream();
DataSource source = dh.getDataSource();
response.getPdfStream().add(new
DataHandler(source.getInputStream(), "application/pdf"))
}
I have no idea why the last pdf document is not set.
Alex
Re: Apache CXF+MTOM sending multiple attachments
Posted by Alex Declent <de...@gmail.com>.
After a lot of redesign now I got follewing exception:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME
type application/pdf
WARNING: Interceptor for has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not write attachments.
at
org.apache.cxf.interceptor.AttachmentOutInterceptor$AttachmentOutEndingInterceptor.handleMessage(AttachmentOutInterceptor.java:98)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at
org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH
for MIME type application/pdf
at
javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:877)
at javax.activation.DataHandler.writeTo(DataHandler.java:302)
at
org.apache.cxf.attachment.AttachmentSerializer.writeAttachments(AttachmentSerializer.java:234)
at
org.apache.cxf.interceptor.AttachmentOutInterceptor$AttachmentOutEndingInterceptor.handleMessage(AttachmentOutInterceptor.java:96)
... 32 more
Any ideas, Alex
Am 2011-11-23 22:25, schrieb Daniel Kulp:
> Any chance you can create a small sample test case showing the issue? Not
> really sure what would cause it.
>
> That said, if you aren't using CXF 2.4.3 or newer, definitely upgrade.
>
> Dan
>
>
> On Wednesday, November 23, 2011 1:51:42 PM Alex Declent wrote:
>> I have developed a web-service which receives multiple attachments from
>> a remote web-service via an CXF JAXB client (the client is called from
>> the service), the attachment from the remote service are, one xml
>> document and an undefined number of pdf documents.
>>
>> When I try to add the received attachments to my web-service response
>> the xml document is set and only n-1 data of the received pdf documents.
>>
>> Logging:
>>
>> ---------------------------
>> ID: 8
>> Encoding: UTF-8
>> Content-Type: multipart/related; type="application/xop+xml";
>> boundary="uuid:aeb23655-314b-4365-822c-f56f674059d8";
>> start="<ro...@cxf.apache.org>"; start-info="text/xml"
>> Headers: {}
>> Payload:
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> 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>...</soap:
>> Envelope> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/xml; charset=UTF-8
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>> <?xml version="1.0" encoding="UTF-8"?><ns2:Response
>> xmlns:ns2="ns://example.org/types">...</ns2:Response>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/pdf
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>> %PDF-1.4
>> %????
>> 3 0 obj<</Filter/FlateDecode/Length 1137>>stream....
>> %%EOF
>>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/pdf
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8--
>>
>> Source code:
>>
>> response.setXmlStream(getXmlResponseSource());
>> for(int i=0; i< client.getResponse().getAttachments().size(); i++){
>> DataHandler dh =
>> client.getResponse().getAttachments().get(i).getPDFOutStream();
>> DataSource source = dh.getDataSource();
>> response.getPdfStream().add(new
>> DataHandler(source.getInputStream(), "application/pdf"))
>> }
>>
>>
>> I have no idea why the last pdf document is not set.
>>
>> Alex
Re: Apache CXF+MTOM sending multiple attachments
Posted by Alex Declent <de...@gmail.com>.
Hi Daniel, thank you for your response,
I'm using CXF 2.5.0.
Now I have found out that when I debug the web-service with my IDE
everything work as it should,
but if I send the request to the service without debugging it ends up as
I already mentioned.
I can't produce a test case because the webservice is for an closed user
group (gouverment).
Alex
Am 2011-11-23 22:25, schrieb Daniel Kulp:
> Any chance you can create a small sample test case showing the issue? Not
> really sure what would cause it.
>
> That said, if you aren't using CXF 2.4.3 or newer, definitely upgrade.
>
> Dan
>
>
> On Wednesday, November 23, 2011 1:51:42 PM Alex Declent wrote:
>> I have developed a web-service which receives multiple attachments from
>> a remote web-service via an CXF JAXB client (the client is called from
>> the service), the attachment from the remote service are, one xml
>> document and an undefined number of pdf documents.
>>
>> When I try to add the received attachments to my web-service response
>> the xml document is set and only n-1 data of the received pdf documents.
>>
>> Logging:
>>
>> ---------------------------
>> ID: 8
>> Encoding: UTF-8
>> Content-Type: multipart/related; type="application/xop+xml";
>> boundary="uuid:aeb23655-314b-4365-822c-f56f674059d8";
>> start="<ro...@cxf.apache.org>"; start-info="text/xml"
>> Headers: {}
>> Payload:
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> 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>...</soap:
>> Envelope> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/xml; charset=UTF-8
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>> <?xml version="1.0" encoding="UTF-8"?><ns2:Response
>> xmlns:ns2="ns://example.org/types">...</ns2:Response>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/pdf
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>> %PDF-1.4
>> %????
>> 3 0 obj<</Filter/FlateDecode/Length 1137>>stream....
>> %%EOF
>>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8
>> Content-Type: application/pdf
>> Content-Transfer-Encoding: binary
>> Content-ID:<67...@example.org>
>>
>>
>> --uuid:aeb23655-314b-4365-822c-f56f674059d8--
>>
>> Source code:
>>
>> response.setXmlStream(getXmlResponseSource());
>> for(int i=0; i< client.getResponse().getAttachments().size(); i++){
>> DataHandler dh =
>> client.getResponse().getAttachments().get(i).getPDFOutStream();
>> DataSource source = dh.getDataSource();
>> response.getPdfStream().add(new
>> DataHandler(source.getInputStream(), "application/pdf"))
>> }
>>
>>
>> I have no idea why the last pdf document is not set.
>>
>> Alex
Re: Apache CXF+MTOM sending multiple attachments
Posted by Daniel Kulp <dk...@apache.org>.
Any chance you can create a small sample test case showing the issue? Not
really sure what would cause it.
That said, if you aren't using CXF 2.4.3 or newer, definitely upgrade.
Dan
On Wednesday, November 23, 2011 1:51:42 PM Alex Declent wrote:
> I have developed a web-service which receives multiple attachments from
> a remote web-service via an CXF JAXB client (the client is called from
> the service), the attachment from the remote service are, one xml
> document and an undefined number of pdf documents.
>
> When I try to add the received attachments to my web-service response
> the xml document is set and only n-1 data of the received pdf documents.
>
> Logging:
>
> ---------------------------
> ID: 8
> Encoding: UTF-8
> Content-Type: multipart/related; type="application/xop+xml";
> boundary="uuid:aeb23655-314b-4365-822c-f56f674059d8";
> start="<ro...@cxf.apache.org>"; start-info="text/xml"
> Headers: {}
> Payload:
> --uuid:aeb23655-314b-4365-822c-f56f674059d8
> 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>...</soap:
> Envelope> --uuid:aeb23655-314b-4365-822c-f56f674059d8
> Content-Type: application/xml; charset=UTF-8
> Content-Transfer-Encoding: binary
> Content-ID: <67...@example.org>
>
> <?xml version="1.0" encoding="UTF-8"?><ns2:Response
> xmlns:ns2="ns://example.org/types">...</ns2:Response>
> --uuid:aeb23655-314b-4365-822c-f56f674059d8
> Content-Type: application/pdf
> Content-Transfer-Encoding: binary
> Content-ID: <67...@example.org>
>
> %PDF-1.4
> %????
> 3 0 obj <</Filter/FlateDecode/Length 1137>>stream....
> %%EOF
>
> --uuid:aeb23655-314b-4365-822c-f56f674059d8
> Content-Type: application/pdf
> Content-Transfer-Encoding: binary
> Content-ID: <67...@example.org>
>
>
> --uuid:aeb23655-314b-4365-822c-f56f674059d8--
>
> Source code:
>
> response.setXmlStream(getXmlResponseSource());
> for(int i=0; i < client.getResponse().getAttachments().size(); i++){
> DataHandler dh =
> client.getResponse().getAttachments().get(i).getPDFOutStream();
> DataSource source = dh.getDataSource();
> response.getPdfStream().add(new
> DataHandler(source.getInputStream(), "application/pdf"))
> }
>
>
> I have no idea why the last pdf document is not set.
>
> Alex
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com