0

I have a web service which I need to use to populate content in my Ionic-framework app but unfortunately the service does not provide a JSON interaction, only SOAP/XML. How can I continue building in Ionic and use this service? (Ionic itself is proving to be difficult for me to learn, sorry.)

Matt W
  • 11,753
  • 25
  • 118
  • 215
  • I have read this post but it does not really answer the question, I feel http://stackoverflow.com/questions/124269/simplest-soap-example – Matt W Jul 01 '14 at 09:04
  • 1
    what you should be asking is how does one call a soap web service from Angularjs. – Aaron Saunders Jul 02 '14 at 03:03

1 Answers1

0

Since your service is not providing JSON response you can go for x2js library.

This library provides XML to JSON (JavaScript Objects) and vice versa javascript conversion functions. The library is very small and doesn't require any other additional libraries. (As the documentation states).

You can go for : .xml_str2json - Convert XML specified as string to JSON

var x2js = new X2JS();

function convertXml2JSon() {
    $("#jsonArea").val(JSON.stringify(x2js.xml_str2json($("#xmlArea").val())));
}

function convertJSon2XML() {
    $("#xmlArea").val(x2js.json2xml_str($.parseJSON($("#jsonArea").val())));
}

$("#xmlArea").val("<root><child><textNode>First &amp; Child</textNode></child><child>    <textNode>Second Child</textNode></child><testAttrs attr1='attr1Value'/></root>");

convertXml2JSon();
convertJSon2XML();
$("#convertToJsonBtn").click(convertXml2JSon);
$("#convertToXmlBtn").click(convertJSon2XML);

Demo : http://jsfiddle.net/abdmob/gtLBx/15/

Arjun Upadhyay
  • 334
  • 2
  • 5