andrewmcgivery / angular-soap

An angular port of a Javascript SOAP Client into a factory that has a similar syntax to $http.
114 stars 84 forks source link

Parameters not going to server..... #50

Closed duncanhan closed 7 years ago

duncanhan commented 7 years ago

I add the parameters to my post but on the server I do not receive them...

.factory("testService", ['$soap',function($soap){

return {
    GetCategoriesUsedByApp: function(app_id){
        return $soap.post(base_url,"GetLoanAmounts", {msisdn: app_id});
    }
}

}])

on server I get msisdn = null

Please help

duncanhan commented 7 years ago

I fixed this by viewing the xml request which is built at around line 166 in soapclient.js, I and formatting it to what my server expected. All parameters are now submitted.

var sr = "<?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" + "<" + method + " xmlns=\"" + ns + "\">" + parameters.toXml() + "</" + method + ">/soap:Body/soap:Envelope";

Which resolved to <?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

256742020253
/soap:Body

/soap:Envelope

yet my server was expecting

// Expected <?xml version="1.0" encoding="UTF-8"?>

256742020253 /ns2:GetLoanAmounts /S:Body /S:Envelope