Generating JavaScript stubs from WSDL - javascript

I'm looking for a tool to generate a JavaScript stub from a WSDL.
Although I usually prefer to use REST services with JSON or XML, there are some tools I am currently integrating that works only using SOAP.
I already created a first version of the client in JavaScript but I'm parsing the SOAP envelope by hand and I doubt that my code can survive a service upgrade for example, seeing how complex the SOAP envelope specification is.
So is there any tool to automatically generate fully SOAP compliant stubs for JavaScript from the WSDL so I can be more confident on the future of my client code.
More: The web service I try to use is RPC encoded, not document literal.

Apache CXF has tools that generate JavaScript clients that talk soap.
Actually, any CXF service can have a javascript client autogenerated by doing a get to the URL with ?js appended. (just like ?wsld produces the wsdl) There are command line tools as well, but the dynamic generated stuff is kind of neat.

I had to do this myself in the past and I found this CodeProject article. I changed it up some, but it gave me a good foundation to implement everything I needed. One of the main features it already has is generating the SOAP client based off the WSDL. It also has built in caching of the WSDL for multiple calls.
This article also has a custom implementation of XmlHttpRequest for Ajax calls. This is the part that I didn't use. During that time, I think I was using Prototype javascript library and modified the code in this article to use it's Ajax functions instead. I just felt more comfortable using Prototype for the ajax calls, because it was widely used and had been tested on all the browsers.

It would probably be an overkill, but NetBeans has this feature.

Related

Javascript C++ binding?

I have some C++ code that I want to expose to client side of a web app. Ideally, I want to write Javascript wrapper objects for my C++ classes so that I can use them clientside.
Has this been done before?. Does anyone have a link to show how this may be achieved?
There is a library to convert C++ code to javascript, it might help:
emscripten
Libjspp C++ template based wrapper for embedding and extending Javascript engine spidermonkey 1 . 8 . 5 and more
SpiderMonkey? is Mozilla Project's Javascript/ECMAScript engine.
Libjspp allows C++ developers to embed SpiderMonkey? simply and easily into their applications. Libjspp allows to run multiple Javascript Engines within same process which suits one engine per thread para dime which is helpful in achieving true parallisim. Also Libjspp no way stops user from running multiple threads within engine.
http://code.google.com/p/libjspp/
I guess that RPC is what you want. You'll need to wrap your functions on the server side using some sort of framework. I've not yet used it, but this one looks promising.
On the client side you use proxy objects to dispatch the function calls. The communication is handled usually either via XML-RPC or JSON-RPC. I used this client side framework and was quite content but I'm sure you'll find many others.
This is an old topi, however, I was in the exact situation right now, and all of the solutions I found on the net complicated or outdated.
Recently, I ran across a library which supports V8 engine (including the new isolation API, which makes 90% of the libraries I found outdated) and provides great exposure and interaction API.
https://github.com/QuartzTechnologies/v8bridge
I hope that my solution will help anybody.
There's a relatively new library for doing this called nbind. Maybe that would suit you? It looks very good to me, and I'm just about to start using it.
I think you want a C++ JSON parser. You should be able to find one here http://www.json.org/. It may not do all you want because it just serializes and deserializes C++ objects without any behavior, but it should be good enough. See https://stackoverflow.com/questions/245973/whats-the-best-c-json-parser for some discussion.
If the C++ code has to be on the client, then there is no simple way to do this for a web app. A solution may involve coding plugins for the browsers you want to support, which may then be accessed from javascript code.
If, for example, you need this for a client application, that is another case. Such a thing has been done and involves linking your application to (or running from outside) with for example chromium library, or any other javascript execution engine. That way you can create bindings to C++ classes and use such objects from javascript and vice-versa. Note that this is also not a trivial solution and may be a big effort to implement (also requires additional resources).
You could for example wrap the C++ classes in PHP or Python, and then implement an API over HTTP to access the required functions.
Or if you insist on exposing the functions as JavaScript you could try using Node.js, and create an C++ add-on to wrap you classes. See the Node.js documentation here: http://nodejs.org/api/addons.html#addons_wrapping_c_objects
But either way, I don't think avoid creating some sort of API (HTTP SOAP, XML RPC) to access the functions on your server.
Though QML is not exactly Javascript, Qt is not plain C++, but what they do together seem just like what you need

Handle Web Server with multiple clients [duplicate]

I am looking for a simple and reliable Comet javascript library. I want to keep a persistent streaming of data from my server (via PHP script) to the client side. I tried building my own using the iframe technique, but there are lots of issues with safari which I experienced. I am just hoping someone else has created a simple library for it?
There is a jquery comet plugin
Probably the best version though is the Dojo library
I have a quick list of commands I used to get a jetty server with comet up and running here
It's not just the javascript library that you need, but a server-side implementation as well. Depending on your needs, you'll need to pick a proper implementation.
You mentioned PHP, which is typically difficult with long-held requests. Other options include having a separate server for your comet requests, or using a SaaS solution, such as WebSync OnDemand.
Depending on which option you pick for the server, you will have one or more javascript clients available. But you need to determine your server implementation first, then use the appropriate javascript implementation to match.
Have a look at http://www.ape-project.org/ Pretty quick setup process.
have you tried JSON-RPC. Apparently Dojo has good support for it, though I haven't tried it thoroughly
JSON-RPC
Dojo Documentation

Developing JavaScript APIs by using Third-Party Librarys

I currently want to make my project accessible not only via back-end code (C#, Python, PHP, etc.), so I decided to write an easy and simple JS API, every developer can easily integrate within their website / project.
Since the whole thing is a service driven system, most of the stuff runs via RPC encoded as JSON.
My problem is, that if I want to make this API I got the following two options:
Writting raw RPC functions from ground up
Using jQuery as third-party library
The big problem with option number 2, which is by far the best option, is that I have to say "dear developer, you need to use jQuery to access my API", which is striking me, since I do not want to dictate what ppl should or should not use by restricting their opportunities.
Is there a way implementing jQuery's RPC stuff without breaking any other potential JS framework the final developer will use?
if you're worried about the conflict between jquery and other libraries, use jQuery.noConflict() and it solves your problem!
more info at : http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Is CouchDB an example of Server Side Javascript?

I looking at using Javascript server side and took a look at persevere/pintura but for a novice like me, I need more documentation and tutorials and CouchDB seems to have a lot of that but is it used as a server side js tool?
Kind Regards
Yes (seconding what #Pointy said above). The JavaScript in CouchDB does run server-side. :)
Beyond that, though, JavaScript in CouchDB can do far more than just map/reduce queries. It's also used for document validation, update handling (for processing XML POSTed to CouchDB for example), as well as HTML or other markup output from either a single JSON document (using _show) or from the results of a map/reduce query (using _list).
CouchDB does not, however, offer filesystem access or TCP/IP listeners as Node.js does. Right now, the JavaScript is focused on the "shipping and handling" for the database contents (things like validation, formatting, and querying).
If you're interested in looking into options for handling things that CouchDB doesn't do "internally" (image processing, sending e-mails, etc), you might checkout my reply about CouchApp architecture options.
CouchApp's are definitely a viable option for web apps. Coupling those with replication, it's hard to beat.
http://nodejs.org/ is a great example for server-side javascript. If you don't want to write your complete webapp on NodeJS you can trigger it via the node command.
CouchDB is a database with an interresting feature, it allows you to interact via a RestFull api making it ideally suited to access over the web, either in javascript or other client environments. If you are looking for a server-side javascript development environment, try Servoy. It allows full featured server-side application development in javascript including easy database access to all major databases.
Short Answer: Yes.
Longer Answer:
There is a Javascript Engine shipped with CouchDB, which is SpiderMonkey
(the very first engine, open source, written by Brendan Eich, creator of javascript)
CouchDB's View function is JavaScript function running server side that acts as the Map half of a map/reduce operation to construct view.
Then there is client side javascript API, which can be used to communicate with the REST layer to fetch/update documents, which is also where jQuery is used by CouchDB.
More on CouchDB's both server-side & client side javascript capability:
The default engine is capable of doing many features, while package availability is limited compared to Node.js. Kan.so can be considered "NPM for CouchDB, where some packages are server side.
For example, there are frameworks like duality that try to make use of both server side & client side javascript capability to reuse code for rendering with couchDB.
More on the engine:
(The selection of spider Monkey over v8 is because for couchDB's use case the map reduce is not v8 designed for. Also include packaging, multi-threading and also historical reason v8 did not exist that time when spiderMoney is chosen) see [the mailing list] and tweet2
There is even project to port the whole CouchDB to Node.js (i.e. instead of Erlang), Chesterfield
I am glad if someone can add how Erlang talk with the javscript engine.
Thanks for everyone's answer, this is an important thing to make clear for people like me messing up couchDB with some Node.js packages
No, CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript. CouchDB also offers incremental replication with bi-directional conflict detection and resolution.
http://couchdb.apache.org/
CommonJS can be used for server side JavaScript, see here: http://www.commonjs.org/
NodeJS is another: http://nodejs.org/

What is strophe and how to use it with JQuery?

Can somebody explain what strophe is?
I believe it has something to do with XMPP?
How can I incorporate it into a site using Jquery?
Strophe is not a Jabber Client, and its not an XMPP client. Its a library that allows you to easily write either of these. You could (with great difficulty) write a Jabber/XMPP Client from scratch using Javascript or Jquery, but this would be very difficult imagine generating and sending XML like this:
<body xmlns='http://jabber.org/protocol/httpbind' sid='e4fcc09444a61059e88296a106e86e1ff1454f9b' wait='60' requests='2' inactivity='30' maxpause='120' polling='2' ver='1.8' from='localhost' secure='true' authid='1027072784' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' xmpp:version='1.0'><stream:features xmlns:stream='http://etherx.jabber.org/streams'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
Strophe is a library of Javascript functions that makes the process of writing an XMPP client easier. It has methods to allow you to connect to a server, to send a message to a user, to add a contact - and it knows about the XML that needs to be sent to the server to carry out these actions. It basically does all the difficult stuff - the XML generating, sending, connecting and communicating stuff for you. Which makes your life a whole lot easier.
Strophe is a XMPP client, written in Javascript. More specifically, it is a Javascript library that lets you write real-time web applications that have full XMPP capabilities. It is "real-time" because is uses a "Comet-like" technique known as "BOSH" http://xmpp.org/extensions/xep-0124.html.
Once you learn the basics of Strophe, using it with jQuery will "just work" as there is no conflicting code, named functions, or dependencies.
The API documentation for the library can be found here -> str<>phe API
It's a javascript library that's separate to jQuery but obviously you can call any javascript library from any other so I don't believe you'll have any requirement for a specific jQuery integration.
Strophe already uses jQuery. In fact, the Strophe builder APIs borrow the $() syntax from jQuery. Take a look at the echobot example that comes with the source. Definitely check out the Strophe Google group (http://groups.google.com/group/strophe), where you would find Jack Moffitt (creator of Strophe) promptly answers questions himself.

Categories

Resources