I’m trying to obtain a correct XML response without escape characters but seems i’m not capable of.
I’m sending a POST request with an XML, it sends and receives correctly a response (also an XML), but there are escape characters even if I click on Raw response.
I’ve tried to change some header settings (Accept-Charset, Accept, Accept-enconding) to see if allowing UTF-8 makes some difference but it doesn’t.
This seems like an odd SOAP WebService, almost like it’s proxying XML payloads instead of representing an origin server. In any case, it looks like you’re doing everything correctly, as you’re getting a valid response. To get a cleaner-looking representation, one thing you can do is use the visualizer feature.
In the Tests tab of your request, include this code:
Thank you so much for your response, it was really helpful!
Now I understand that this is not “my” problem with the config, it is just that the response is odd.
Sadly it means that I cannot navigate through the XML tags as normal, because even if I convert it to a JSON format, the result presents as a whole block, not divided by tags (I’ve tried it).
So what I will do now is play with splits and arrays (ouch).
If you think there is a better way to do what I want please let me know.
Thank you so much again and have a nice day!
btw sorry for my english, I know it is not so good but I’m trying hehe
Gah! Don’t do splits! The xml2js library should work on the text string. You could use xml2js for both parts here, but I’m using cheerio to get scan through the top-level XML document, because I think it looks a little cleaner.
OMG @kevin.swiber you are my absolute savior!!
Sorry I didn’t understand you the first time, now it makes much more sense to me.
I’m able now to navigate through the whole XML with any problem
I tried by using script which you posted earlier in test tab but facing an error “There was an error in evaluating the test script: TypeError: Cannot read property ‘set’ of undefined”
Iam sending a response to soap api server using java
My source code looks like this
–In sbb iam building an xml to send the status
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.parse(new InputSource(new StringReader(sbb.toString())));
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
format.setIndent(2);
format.setOmitXMLDeclaration(false);
format.setLineWidth(Integer.MAX_VALUE);
Writer outxml = new StringWriter();
XMLSerializer serializer = new XMLSerializer(outxml, format);
serializer.serialize(doc);
response = outxml.toString();
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
This should be its own question, however it seems like your question is related to the API code which is probably better on a Java forum or StackOverflow.