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

Error Uncaught TypeError: Cannot read property 'constructor' of null angular.soap.js:16 #17

Open sirlantj opened 9 years ago

sirlantj commented 9 years ago

It is giving this error and not know it can be

Uncaught TypeError: Cannot read property 'constructor' of null soapCallback @ angular.soap.js:16 SOAPClient._onSendSoapRequest @ soapclient.js:214 xmlHttp.onreadystatechange @ soapclient.js:187

flaviu-toader commented 8 years ago

@sirlantj I am getting the same error. Did you find a workaround in the meantime?

flaviu-toader commented 8 years ago

@sirlantj Just found the reason why this fails, at least for me: soapclient.js is expecting the response of the request to have a certain naming convention. Eg. for a method called "login" the response should be inside a "loginResponse" tag.

Hope this helps!

nicolas-saubi commented 8 years ago

Facing the same problem here... Calling : var base_url = "[server]/foo/HaveCompteFoo"; // (with wsdl at : [server]/foo/HaveCompteFoo?wsdl) [...] return $soap.post(base_url,"haveCompte", {"param1":"", "param2":"", "param3": "", "param4": ""});

and my soap response is this form (seeing from SOAP-UI software):

<env:Body> <ns2:haveCompteResponse xmlns:ns2="server"> <return> <param1>false</param1> <param2/> <param3/> <param4/> </return> </ns2:haveCompteResponse> </env:Body>

Dont' know why it's not working...

nicolas-saubi commented 8 years ago

Ok found a solution. Don't really know SOAP but it seems the request send is not formatted the good way for our WS. Problem is with the targetNamespace from the method called.

Generated xml was something like : <methodname xmlns="url">[...]</methodname> When it should be for our WS : <uniqueprefix:methodname xmlns:uniqueprefix="url">[...]</uniqueprefix:methodname>

So I changed soapclient.js at line 157ish to include this :

// get namespace var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value; // get namespace prefix ns_prefix = 'ns' + Math.ceil((Math.random(1)*10000)); // build SOAP request 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/\"&gt;" + "<soap:Body>" + "<" + ns_prefix + ":" + method + " xmlns:" + ns_prefix + "=\"" + ns + "\">" + parameters.toXml() + "</" + ns_prefix + ":" + method + "></soap:Body></soap:Envelope>";

Hope it helps...

ChandniGondhiya commented 8 years ago

I too facing same error like @sirlantj.

my wsdl service is located at (url) - http://abcd:9000/WSDL_Web_Service/service_DashBoard.WSDL

SOAPAction:http://dataflux.com/methodname

Ideally, the wsdl service method does not have any input parameters, and returns blank response when run from Data Management Studio. The wsdl is created with the help of that studio.

Before trying suggestions from @nicolassaubi

<?xml version="1.0" encoding="utf-8"?>soap:Body/soap:Body/soap:Envelope

After implementing @nicolassaubi suggesstions:

<?xml version="1.0" encoding="utf-8"?>soap:Body/ns376:methodname/soap:Body/soap:Envelope

With both the above scenario, I am getting same error as @sirlantj.. Can anybody please throw more light on this.

Thanks...

sirlantj commented 8 years ago

did not work any solution and convinced the staff to use api rest

ChandniGondhiya commented 8 years ago

Thanks @sirlantj for quick repsonse.!

noolee commented 7 years ago

I had the same issue. Changing the "Result" to "Respose" in line 204 resolve the problem.