lula / ngx-soap

Simple SOAP client for Angular
MIT License
66 stars 61 forks source link

TypeError ​ columnNumber: 1470096 ​ fileName: "http://localhost:4200/main.271bafc3e06f10db73e0.js" ​ lineNumber: 1 ​ message: "l.emit is not a function" #29

Closed efgiese closed 6 years ago

efgiese commented 6 years ago

Hi, first of all i want to thank you for your great work!

Now i ran into errors using the ngx-soap.

Running the app in testmode (ng serve) everything is fine. The client is created and i can communicate with the printer (i use it for communication with a soap printer). If i compile my app for production, i ran into errors. On any communication with the printer i got this error (see header). If i disable "optimization" in angular.json for "build", then i can communicate with the printer and it is working again. I only get some errors about source-maps. If i disable "buildOptimizer" everything is fine without any errors. Can this be fixed?

I use @angular/cli: 6.1.4 and @angular/core: 6.1.0 See this wsdl: services.wsdl.xml.txt

PS: Your Demo-App has the same issue! ng serve --proxy-config proxy.conf.json runs fine ng serve --proxy-config proxy.conf.json --prod has that error!

lula commented 6 years ago

Hello @efgiese!

It could be related to this, Build Optimizer does not support es2015 code, I think.

To make short the long story, I wanted the code from node-soap to be changed as little as possible, so I'm afraid some code might not be compliant with angular builder. I might change the code of the client though in order to make it working, but in return I would have more difficulties when the lib needs to be upgraded with a new node-soap version. That said, I see the main.js bundle of the non-optimized build of demo app larger 10 times more than the optimize build... so I believe it would make sense to make the code compliant with angular build optimization. I'll work on it in the next days. At least, for the time being, there is a workaround.

Anyway, thank you for using this lib and pointing out this issue!

lula commented 6 years ago

The issue is related to Client inheritance of EventEmitter from events lib. I've not digged in deeper, yet.

See commit 9a06f6a

Only four events are emitted: message, xml request, response and error. Response and error, are completely useless as they're already provided in the form of http response/error. I'm wondering whether it might have sense to have these events or not. Should these events be really fundamental or widely used, I would have no choice but the to do the changes. But I really think (hope 😊) they aren't. I cannot find any real use for them: I just wiped them out 😎. For now.

Do you see any possible damage on this approach? What do you think about it?

Thanks!

efgiese commented 6 years ago

Hi, i don' t use the Events, because the Printer don' t use them. I haven' t tested the lib with other wsdl' s, so i can' t say what' s going on with those wsdl' s.

I think, you should try it and see, i' ve it fixes the Problem.

lula commented 6 years ago

Hello, 0.5.0-beta.7 is out. Just tested with a sample project from scratch: ng serve --prod works as expected. Please let me know if it works for you.

efgiese commented 6 years ago

Hi, thank you very much. For me it' s working...

Bye

lula commented 6 years ago

Glad to hear it worked. Cheers