I have started working on web application using jquery touch. My web services is written in soap and I want to call from my application. Can you suggest me how should I move ahead. Is it possible to call from ajax?
2 Answers
While many people thinks that managing the complexity of SOAP in a JavaScript environment would be counter-productive, it could nevertheless be done, in particular if you are familiar with SOAP web-services and want to avoid the need to learn another middle-layer framework; a library that I would suggest is Apache-CXF support for JavaScript.
The CXF JavaScript client library is indeed a code generator which (with some limitations), in its easiest form, wsdl2js, gets a wsdl file and generates JavaScript
- contructors - for an service
- methods - for any service operation, and
- objects - for any web service complex element/type
which can be directly called in your scripting. Other available tools generate the javascript code starting with the Java code server-side implementation (java2js), or on-the-fly (dynamic javascript).
Pros:
- leverage a component of a widely used library for web-services implementation (CXF)
- avoid another layer in the middle
- easy to use (run the tools against the wsdl, load the generated sources)
Downsides:
- client knows nothings about WS urls and ports; you need the URL at which the ws ranswers and thats'it
- as a code generator, the JavaScript client generator is parallel to JAXB or JAX-WS. It defines a mapping from an abstract model of a web service to JavaScript objects. Unlike JAXB and JAX-WS, there is no committee that has standardized a 'JavaScript binding.' The CXF binding may not be to everyone's tastes.
- Soap 1.1 only
- No Authentication support

- 18,864
- 6
- 70
- 95
-
Interesting library, didn't realize someone had actually written a code generation library for javascript. Do you have any practical experience on how well that works? – OlliM Sep 18 '12 at 15:13
-
1I used cxf many times and in different flavours for implementing web-services in java; my experience with wsdl2js is limited to running the simple example they provide. – guido Sep 18 '12 at 16:06
Using soap from the browser is technically possible, but a very bad idea. You'll spend all your time fighting to get the soap protocol to work correctly and you'll miss all the benefits of soap.
A much better approach would be to build a back end for your new web application using the framework of your choice, eg. J2EE, .Net or any other. All those platforms have nice soap libraries that will do the work for you. Then you will either generate the html pages on server (old school web site) or use a static page and expose the data as a JSON rest API (modern single page app).
In summary: soap is good for communicating between servers, terrible for communication with the browser.

- 7,023
- 1
- 36
- 47
-
thanks for your answer,I am developing mobile app using phone gap and in my project I need to hit soap api to get the data. Did You get why I need some js soap wrapper. – Invincible Sep 12 '12 at 04:59
-
Ok, then you basically have 2 options: create a server for you app that handles the soap communication and provides a nice api for you app or actually do the soap handling in js. I would recommend the server, as it would provide a stable api that you control, but that is not always possible. – OlliM Sep 12 '12 at 11:22
-
For doing the work client-side, this question could provide some answers http://stackoverflow.com/questions/124269/simplest-soap-example-using-javascript – OlliM Sep 12 '12 at 11:23