¿Cómo puedo saber si un servicio web devuelve datos en formato XML o JSON?

If its a third party web service, how will I know if it returns data in XML or JSON format? I guess if its created in .NET, then I just look at the WSDL provided for the web service?

¿Es eso correcto?

preguntado el 03 de julio de 12 a las 04:07

2 Respuestas

You can always look at the HTTP headers in the response, in particular the content type. There's no guarantee they are correct, but the presence of "application/json" or "application/xml" should give you a clue.

However, knowing that the response is XML or JSON isn't going to help you much. If you don't know what the web service returns, and it returns <akhegc snt="jsg"/>, then knowing this is XML doesn't actually help you make sense of it.

Respondido 03 Jul 12, 08:07

If it has a wsdl and it adheres to the standard ( http://www.w3.org/TR/wsdl ) it will emit XML.

Respondido 03 Jul 12, 04:07

And how would I know if it is JSON? - loco99

as a rule of thumb: if it has a wsdl it will be xml. Otherwise you have to test it. - gergely szilagyi

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.