title: Parsing SOAP response using Javascript
body: <p>I'm developing a Meteor application that has to consume data from both a REST and SOAP APIs. For accessing the SOAP service I'm using the <a href="https://www.npmjs.com/package/soap" rel="nofollow noreferrer">soap</a> package, that works fine but I'm having trouble with the format of the returned data. Here's an example:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;attributes&quot;: {
      &quot;xsi:type&quot;: &quot;SOAP-ENC:Array&quot;,
      &quot;SOAP-ENC:arrayType&quot;: &quot;tns:course[1]&quot;
    },
    &quot;item&quot;: {
      &quot;attributes&quot;: {
        &quot;xsi:type&quot;: &quot;tns:course&quot;
      },
      &quot;id&quot;: {
        &quot;attributes&quot;: {
          &quot;xsi:type&quot;: &quot;xsd:int&quot;
        },
        &quot;$value&quot;: 1
      },
      &quot;code&quot;: {
        &quot;attributes&quot;: {
          &quot;xsi:type&quot;: &quot;xsd:string&quot;
        },
        &quot;$value&quot;: &quot;CDP001&quot;
      },
      // ..... More attributes
      &quot;number_students&quot;: {
        &quot;attributes&quot;: {
          &quot;xsi:type&quot;: &quot;xsd:int&quot;
        },
        &quot;$value&quot;: 1
      }
    }
  }
  </code></pre>
  <p>I've tried the same API call using PHP and its <code>SoapClient</code> and this is the returned data (printed using <code>var_dump</code>):</p>
  <pre><code>array(1) {
    [0]=&gt;
    object(stdClass)#2 (8) {
      [&quot;id&quot;]=&gt;
      int(1)
      [&quot;code&quot;]=&gt;
      string(6) &quot;CDP001&quot;
      [&quot;external_course_id&quot;]=&gt;
      NULL
      [&quot;title&quot;]=&gt;
      string(23) &quot;Curso Chamilo de prueba&quot;
      [&quot;language&quot;]=&gt;
      string(7) &quot;spanish&quot;
      [&quot;category_name&quot;]=&gt;
      string(9) &quot;PC Skills&quot;
      [&quot;visibility&quot;]=&gt;
      int(2)
      [&quot;number_students&quot;]=&gt;
      int(1)
    }
  }
  </code></pre>
  <p>As you can see, PHP's SoapClient takes care of parsing the response to provide an easily accessible object. My question is, do you know any Javascript package that could parse the response and return a more &quot;normal&quot; JSON object? I can build it myself, but perhaps there's already a solution out there.</p>
  <p>Many thanks,</p>