Can't formulate the response object for SOAP Node.js

Viewed 2707

I'm writing a SOAP Node.js webservice using node-soap and I can't figure out how to formulate the response correctly.

I'm integrating a webapp with QuickBooks 2013 using the Web Connector. The client will make the request to authenticate and I can log the arguments passed so i know that it is being called, but I can't get the the response correct.

The documentation says it is expecting an array of strings as the response. The relevant parts of the WSDL look like:

  <s:element name="authenticateResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="authenticateResult" type="tns:ArrayOfString" />
      </s:sequence>
    </s:complexType>
  </s:element>

  <s:complexType name="ArrayOfString">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
    </s:sequence>
  </s:complexType>

 <wsdl:message name="authenticateSoapOut">
    <wsdl:part name="parameters" element="tns:authenticateResponse" />
</wsdl:message>

<wsdl:operation name="authenticate">
  <wsdl:input message="tns:authenticateSoapIn" />
  <wsdl:output message="tns:authenticateSoapOut" />
</wsdl:operation>

 <wsdl:operation name="authenticate">
  <soap:operation soapAction="http://developer.intuit.com/authenticate" style="document" />
  <wsdl:input>
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output>
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>

I have tried many different ways of configuring the response object but keep getting errors from the client (QuickBooks Web Connector)

The JavaScript I have is :

    var myService = {
          'QBWebConnectorSvc': {
              'QBWebConnectorSvcSoap': {
                  authenticate: function(args) {

                           //i have tried many variations of nesting arrays/objects etc.
                    var toReturn = {
                        "ArrayOfString":[guid()," "," "," "]
                    };
                    return toReturn;
                  }
              }
          }
      }

     var xml = require('fs').readFileSync('qbwc.wsdl', 'utf8'),
          server = http.createServer(function(request,response) {
              response.end("404: Not Found: "+request.url)
          });

    server.listen(8000);

    soap.listen(server, '/wsdl', myService, xml);

Somehow I need to build the "ArrayOfString" but I have no idea how to do it; I am new to the whole soap thing.

1 Answers
Related