File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Apache CXF with MTOM enabled WCF Service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Apache CXF with MTOM enabled WCF Service" Watch "Apache CXF with MTOM enabled WCF Service" New topic
Author

Apache CXF with MTOM enabled WCF Service

Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Hi!

I have to call a Microsoft WebService from a Java Client. Client-side I'm using Apache CXF (because it's simple to use SSO over Ntlm ... that's a requirement, so please don't tell me to use Axis 2 or other frameworks ... evaluated moste of them ; - ). There're no problems using simple methods without attachements.

Now we have to store binary data (protocols) via the service into a database (yeah, I know we could do that directly ...). We decided to use MTOM because it seems to be covered on both sides. But it seems it's not that easy.

First of all the WSDL2Java generator doesn't generate the correct Code (with DataHandler), but a simple byte[] array. It seems that for the generator the element not only needs to be type="xs:base64Binary" but also xmime:expectedContentTypes="application/octet-stream". I have absolutely no idea how to reach this form WCF side (MSDN doesn't offer that much info for unexperienced users like me).

So I decided to adapt the generated classes and add the annotation (@XmlMimeType("application/octet-stream")) and DataSource manually (instead of the byte[] array). Also I set the key "mtom-enabled" to "true" for the endpoint. So the message is really multipart. Sadly I get only a Http status code 400 from the service:



According to the description in MSDN the "multipart/related", "application/xop+xml" and "application/soap+xml" should be correct. So the only possible failure (in my opinion) must be something with the boundary. Does anyone know how to configure the boundary settings ... is there a possibility?

Btw. it's interesting that if I disable MTOM on the client side (and the message isn't multipart anymore) I don't get a 400 error but a Http OK (200):



The configrutation on the client-side atm is hardcoded (simplified):



The zipped protocol is set this way:



Any suggestion / advise / help is welcome!

Link:

http://cwiki.apache.org/CXF20DOC/mtom.html
http://cwiki.apache.org/CXF20DOC/mtom-attachments.html
http://www.jboss.org/jbossws/user-guide/en/html/1.0.4/en/html/mtom-xop.html

http://msdn2.microsoft.com/en-us/library/aa738574.aspx


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
Hi again!

I got rid of the HTTP-Code 400 (Bad Request). There was a nasty bug in the CXF version I was using (2.0.4):

http://www.mail-archive.com/cxf-issues@incubator.apache.org/msg06319.html

With the new version 2.1 I get (correctly) a 200 (OK). But the attachement cannot be interpreted on the .NET Service side. The service says that it received zero bytes.

bye, Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apache CXF with MTOM enabled WCF Service