Thursday, 13 April 2017

How to use node-soap given an example SOAP request

I was given documentation for a single SOAP api method in order to make a single request to. It looks like:

POST http://someurl HTTP/1.1
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://anotherurl"

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soapenv:Header>
      auth stuff
   </soapenv:Header>
   <soapenv:Body>
      <tem:APISpecificThing>
         <tem:SubThing>
            <foo:bar>42</foo:bar>
            <foo:Message>
               <foo:String>Hello World</foo:String>
               <foo:Baz>
                  <foo:PropertyOne>12345678</foo:PropertyOne>
               </foo:Baz>
               <foo:Tags />
            </hip:Message>
            <foo:ThingFlag>true</foo:ThingFlag>
         </tem:SubThing>
      </tem:APISpecificThing>
   </soapenv:Body>
</soapenv:Envelope>

It looks like the module to use is node-soap. I'm having trouble figuring out how to translate this into JS, however. When you set up a client, it looks like...

  var myService = {
      MyService: {
          MyPort: {
              MyFunction: function(args) {
                  return {
                      name: args.name
                  };
              },

I'm confused on how to interpret this API documentation. It looks like APISpecificThing would be "MyFunction", but then what about all the other properties? There's nothing in the documentation about what MyPort is. Or am I going about this all wrong?



via ahota

No comments:

Post a Comment