Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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?

share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.