1

I am invoking java webservice method from javascript. The method has a return type as string but when I invoke it through javascript the response is not just a string but in xml format as below:

<ns:getNameResponse xmlns:ns="helloService">
<ns:return>hello</ns:return>
</ns:getNameResponse>

What i expect is javascript should have received just "Hello" as response. Is something wrong the way java script is written or this is the only way output is received. (might be silly question but I am new to this stuff)

If this is the correct response, is there any way i can retrieve the "hello" string from xml response in javascript?

1 Answer 1

0

This is expected from a SOAP web service as the payload to and from is XML. You are probably used to calling this from Java which does all the serialization automatically.

You will have to convert that XML into something useful. It's not automatic, but there are several libraries available that you can use.

If you have control over the service, then you should be able to create a way to return JSON instead of XML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.