angular-soap icon indicating copy to clipboard operation
angular-soap copied to clipboard

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

Open sirlantj opened this issue 9 years ago • 8 comments

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

sirlantj avatar Oct 19 '15 18:10 sirlantj

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

flaviu-toader avatar Jan 10 '16 11:01 flaviu-toader

@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!

flaviu-toader avatar Jan 10 '16 11:01 flaviu-toader

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...

nsaubi-swi avatar Jan 21 '16 10:01 nsaubi-swi

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

Hope it helps...

nsaubi-swi avatar Jan 21 '16 15:01 nsaubi-swi

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

soap:Body/soap:Body/soap:Envelope

After implementing @nicolassaubi suggesstions:

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...

ChandniGondhiya avatar May 30 '16 05:05 ChandniGondhiya

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

sirlantj avatar May 30 '16 14:05 sirlantj

Thanks @sirlantj for quick repsonse.!

ChandniGondhiya avatar May 31 '16 04:05 ChandniGondhiya

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

noolee avatar May 23 '17 08:05 noolee