Thursday, December 10, 2009

Send XML data over web service

Occasionally I am being asked a common question, "How to send XML data over web service?". In Java (in fact in any programming language) XML is just a string (sequence of characters). So sending XML as request parameter or receiving it in response is just like handling any other string data.

For the following XML data from web service client and server-

XML from client

XML from server
<greeting>Hello! vinod</greeting>

This is the web service (JAX-WS) request and response-
<?xml version="1.0" ?>
<S:Envelope xmlns:S="">
        <ns2:xmlData xmlns:ns2="">

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="">
        <ns2:xmlDataResponse xmlns:ns2="">
            <return>&lt;greeting>Hello! vinod&lt;/greeting></return>

The above example clearly shows that JAX-WS runtime handles XML strings pretty well. The source code available here includes an example of sending bigger XML data.


Unknown said...

Hi vinod,

i am using atomika with tomcat+springs,

in xa i am getting an error

com.atomikos.datasource.ResourceException: XA resource 'dataSource11':
resume for XID '636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D30303030313030303037:636F6D2E61746F6D696B6F732E737072696E672E6A6462632E746D31'
raised 0: unknown at com.atomikos.datasource.xa.XAResourceTransaction.resume(XAResourceTra

in my test server i am getting the issue 3 to 4 time a day.

i research on the issue in net some on told thatif we add

com.atomikos.icatch.serial_jta_transactions = false;

addove line in this error wont repeat but i am getting the same error after writing that code in jta.props file.

please give me any solution.



beanicatch said...

Hi Vinod,

I am not able to download the code though the provided link. Instead it is serving me which I believe is not the correct file .

Vinod Singh said...


That contains code for sending XML data as well.