3
votes

I am using meteor's http package to connect to server which communicates through SOAP messages. Following is the code (without original url, namespaces, method names and parameters):

HTTP.call('POST', 'http://soap-service-url.com', {
    auth: 'user:password',
    headers: {
        SOAPTarget: 'http://soap-service-url.com',
        SOAPAction: 'http://required-namespace.com/methodName',
        'Content-Type': 'text/xml'
    },
    params: {
        parameter1: "parameterValue",
        parameter2: '<?xml version="1.0"?><some-xml-goes-here>',
    },
    content: '<?xml version="1.0" encoding="utf-8"?>' +
                 '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                                'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                                'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + 
                   '<soap:Body> ' +
                     '<m:methodName xmlns:m="http://required-namespace.com"> ' +
                        '<m:parameter1 xsi:type="xsd:string">parameterValue</m:parameter1>' +
                        '<m:parameter2 xsi:type="xsd:string"><![CDATA[<?xml version="1.0"?><some-xml-goes-here>]]></m:parameter2>' +
                     '</m:methodName> ' +
                   '</soap:Body> ' +
                 '</soap:Envelope>'

}, function (err, result) {
    if (err) {
        console.log('error occurred..');
        console.log(err);
        return;
    }
    console.log(result);
    console.log('----------------------');
});

When I am calling methods without parameters I can get the expected output. But when I am calling methods with parameters, I am getting unexpected output. As the parameters given in the content property are not passed, I have added params property, even then I am unable to receive the expected output. To test the issue, I have created a node js application and connected to the same server using node-soap module. I can pass the parameters through the args on client.myMethod(args, callback[, options]) and get the expected result. How to pass the parameters when using meteor's http package?

1

1 Answers

1
votes
  1. To answer your question above: build your content xml as string before the http.call with parameter1 and 2 values included in the content string.

  2. Your code example above helped me a lot as I could not get node-soap to work within Meteor; always get Error: Cannot parse response --Thank you --I know this is an old post and you probably found the answer by now.