How can I create mime-atachment text/xml
for my SOAPMessage
?
I have a function, which sends binary file of XML. But I don't know how can I do it.
How can I create mime-atachment text/xml
for my SOAPMessage
?
I have a function, which sends binary file of XML. But I don't know how can I do it.
Use a DataHandler/DataSource to push the binary data into the message on the client side.
On the server side, you need to create a DataContentHandler implementation and register it with the activation framework.
Step 1 - Adding the binary attachment
Implement a simple DataSource for getting the data:
Now use this code to add the attachment:
Step 2 - Setup the server side
[Note: this worked for me]
Create a DataContentHandler which handles the incoming attachment of type "application/binary".
Now, you can use this code to get the data of the attachment:
Finally, you need to register your DataContentHandler so that the activation framework will use it. There are a couple of ways (see MailcapCommandMap in the activation framework javadocs). What I did was to create a file called "mailcap" in the lib directory used by my "java" interpreter.
This file looks like this:
application/binary; BinaryDataHandler application/binary;; x-java-content-handler=BinaryDataHandler
This tells the activation framework to use your handler for the indicated MIME type.