I am using spring restTemplate to access the rest webservice, I am able to access the rest webservice with GET request, like I am able to receive the xml responce and able to parse to java.util.List with my bean class. But I am not able to get responce from POST request, as I guess still i am not much clear how to pass parameter while placing POST request. Can anyone please share the links with good examples of POST request using restTemplate. i searched on net but didn't got any useful stuff.
Below is scenario, plz let me know your suggestions, which will help out me a lot...
URL which i need to hit where webservice is hosted
I need to pass the request, for testing I am using curl and passing my request object as below
if i use curl, i get below response.
<?xml version="1.0" encoding="utf-16"?>
below is my spring xml file code snippet
<?xml version="1.0" encoding="UTF-8"?>
<customer balance="1.0" custId="Cust-Id0" custName="CustName0"></customer>
<customer balance="5.0" custId="Cust-Id2" custName="CustName2"></customer>
<customer balance="8.0" custId="Cust-Id4" custName="CustName4"></customer>
here is curl call from command prompt which generate test-respose.txt with above mentioned xml responce.
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<bean id="messageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<property name="marshaller" ref="xstreamMarshaller" />
<property name="unmarshaller" ref="xstreamMarshaller" />
<bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
Can any one helpout with basic code snippet, how can I use restTemplate to place POST request for above scenario, and to get the responce in java.util.List<Customer>
curl -X POST -d @GetAllCustomersRequest.xml -H "Content-Type:text/xml" http://localhost:8080/customer-ws/Customer/Utils/getAllCustomers > test-respose.txt
Thanks for your time and any suggestion, plz let me know if any more information required....