I am using RestTemplate to execute an URL. The url takes an input parameter which is in XML format.
I have a XML like this which is stored as a String in xmlData variable and I need to pass this String to my url in client_data variable -
<?xml version="1.0"?>
<ClientData
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://www.google.com model.xsd"
xmlns="http://www.google.com">
<client id="100">
<clock>
<for>
<etc>val(tery) = 1</etc>
<while><![CDATA[val(tery) < 20]]></while>
</for>
</clock>
</model>
</ClientData>
Below is the code I have -
String xmlData = getXMLData(); // this will return me above XML data as it is in String format
String url = generateURL(xmlData);
// but this line is returning me bad request always in exception
String response = restTemplate.getForObject(url, String.class);
Below is how my url is looking like after generating it and RestTemplate internally does the URL encoding as per my understanding then why I am still seeing the bad request?
http://localhost:8080/test_tmp?client_data=<?xml version="1.0"?>
<ClientData
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://www.google.com model.xsd"
xmlns="http://www.google.com">
<client id="100">
<clock>
<for>
<etc>val(tery) = 1</etc>
<while><![CDATA[val(tery) < 20]]></while>
</for>
</clock>
</model>
</ClientData>
If I url encode the XML string manually and hit the url through the browser then it works fine. What wrong I am doing here?
No comments:
Post a Comment