Expose a web service (wsdl) as a webform - java

Just wanted to ask if anyone knows of a reliable & easy way to expose a webservice (wsdl) as a webform to end-users.
Our team develops a lot of software for external contacts, which often involve creating a web service and exposing it as both a wsdl and a website. We'd like to automate this last step as much as possible (especially for the mindless data-pumping projects) so we can concentrate on developing web services instead of websites.
I recently came across Enunciate, but have not found the time yet to play with it in detail. I was wondering if anyone has any experience with it (or with any similar projects) what your findings are, and what direction you would advice us to take with this.
Best regards,
Tim
Update2:
Turns out what I need is perfectly described in this Enunciate module: http://jira.codehaus.org/browse/ENUNCIATE-23. The only problem is that it's not implemented... (yet?)
Anyone have any experience in creating your own modules, or knows of an existing solution that provides the same functionality?

I'm not sure how much weight my response carries (since I'm the lead developer of Enunciate) but I'd like to encourage you to try it out. I know a lot of happy Enunciate users.
Even if you decide not to use it, I'd like to hear about your experience and why you decided against it.

I've found that using the Metro libraries to provide the web service engine, a web page is produced when accessing the end point with a GET which allows you to easily get the WSDL if you need it.
I do not know if that is what you mean with a "web site" but it is a nice default way to work.

Related

How to create Web Services in Java (with Eclipse)

I am really really having hard time to create simple "Hello World" Web Service in Java. If you exclude several mobile Android mobile apps I have done, I am pretty new to Java environment.
First I tried Axis2 and that simply doesn't work out of the box. Fresh installation of Eclipse, Tomcat 6.0 and Axis2. Tried sample test app and it failed miserably. You can read about it here. My conclusion is that Axis2 simply doesn't work (maybe it used to work). I will try to go back to install older versions, maybe one will magically start working. I have to modify some old project at work that was using Axis2, so that's why I have to stick with it. I would hate to have to migrate to some other tool.
Then I ran on Oracle article Getting Started with JAX-RPC and I was thinking, cool, let's try that. Well, I just managed to get pissed off. After getting half way through the article and trying to write some simple test web service I realized that their code examples are poorly written. Missing brackets, wrong references, missing explanations, etc...
First of all, an interface should extend not implement. Am I right?
public interface SunRegPort implements java.rmi.Remote {
Also, this doesn't exist:
import java.xml.rpc.server.ServiceLifecycle;
But this does:
import javax.xml.rpc.server.ServiceLifecycle;
Well, I don't feel competent to criticize too much (cause of my level of knowledge about this subject of course), but after all I am suspicious that this article is complete JUNK and therefore I am not able to follow it.
Please somebody tell me that I am wrong and if anybody has some advice or link to some How-To page that talks about web services, I would appreciate.
Thanks.
The terminology Web Services is pretty vague. In Java, the modern and reasonably easy way to do this is by annotating classes.
I would recommend that first, you decide whether you want to implement:
SOAP Web Services -> look at JAX-WS
REST Web Services -> look at JAX-RS
Once you have chosen the "type" of Web Services, choose the library that implements the specification.
The Wikipedia entries list a few of these implementations. Apache CXF (complete but a beast), Jersey (popular) and Restlet are very common choices. I personally like the JBoss implementations as well for JAX-WS.
For JAX-WS with Apache CXF, here is a quick start tutorial that looks pretty good (untested)
For JAX-RS with Jersey, try this
Unless you have strong reasons to do otherwise (for instance you need to call an existing system), use REST which is simpler and leaner.
I would recommend you to check out the CXF project by apache. It's quite easy to use and should help you to set up a webservice.
There is a nice guide to Hello world set up.
http://cxf.apache.org/docs/a-simple-jax-ws-service.html
If you're still interested in giving Tomcat a shot, here is a tutorial on youtube of making a very basic "Hello world" example using Eclipse. It leaves a lot to learn; but it looks like it will at least get you started.
FYI, the version of Eclipse used is slightly outdated. So some of the menu options may not be exactly the same:
http://www.youtube.com/watch?v=EOkN5IPoJVs
Also, the meaning of "Web Service" can be subjective. So, to be specific; this just shows you how to get a basic HTTP endpoint started on your local machine.
If you are not tied to Eclipse, give NetBeans a shot. I think it's much better for Web Services in Java.
Web Services are most widely implemented examples of Service Oriented Architecture (SOA). A service contract is defined with the help of SOAP and Web Service Definition Language (WSDL) and that is published for other applications to use.
In this article we will see how we can create web service and web service client in java.
http://www.opencodez.com/java/how-to-build-and-deploy-web-service-and-client-in-java.htm

Suggestion : Java server implementation for web application

I know this question might be repeated many times but would really appreciate any suggestions. I am working on developing a web application in java (server side). The client is developed in javascript and html5 (another guy) and i want to make the developement independent. I have been using java for quite long but have no experience in web development. After endlessly going thorugh many forums and articles i am so confused.
The web app is pretty simple one with options for user to login and upload some data and access those later.
I started with basic sevlets and JDBC APIs. The web application is not very complex one
Currently i have servlets for each resource to handle post and get call on them.
The suggestion i am looking for is do i need to use some framework to make it better. There are so many like springs, playframework, wicket etc.
Any link to sample web applications developed just usin servlets apis will also do a great deal to me
Thanks in advance for the suggestions
I don't think you need any framework. As you said your app was pretty simple one. A java Framework could make a complex app organized. But would make a simple app complex.
However, if in the future, you want to extend your app further more. you might need a framework. The most famous web frameworks in java are SSH(spring, struts, hibernate), you can find a lot of materials easily, so I won't dive into the detail here. SSH frameworks are not easy, avoid using them if you app is not complex enough.

Guidance Creating a "Basic" Java Web App

I have limited exposure in creating a Java web app from scratch, and was hoping that some of you folks could help provide me with some insight.
Basically the flow of the application is as follows:
1.) User logs in (Authentication + session handling)
2.) Requests containing XML are passed to the server
3.) Responses are in XML format also and parsed by the client side
Are there any type of frameworks I can use to help me out with adhering to the "best practices" for what I want to accomplish? I'm comfortable with being able to handle the XML/DB interactions, however I'm not too comfortable with the auth and session handling.
So far I've gotten to the point where I'm using Jetty as a servlet container, and coded basic functions to handle hitting the DB. I'm sort of lost on properly implementing the rest.
I was thinking about using SOAP but it seems like overkill?
Any advice would be greatly appreciated. My apologies if this is a silly question to ask, but after searching for hours.
thanks!
-bp
This is a very broad question, so I'll just give a partial answer. As far as using SOAP, its main practical advantage is for interoperability.
However, it would also be easier as a developer than creating something from scratch: both Axis2 and the Java Web Services Development Pack come with very easy to use code generators (the latter made easier w/ Netbeans or Eclipse). You would basically mark up the code you want to expose as a web service by using annotations (examples abound on the web) and then run it through a code generator and run it. This will produce both the client and the server code. Do some research on Axis2 and Java WSDP.
Implementing security with this solution is trickier. But using headers you can exchange encoded login information.
Using a web framework might actually be overkill if all you need is a webservice as opposed to a human-accessible app through a browser.
EDIT: I should add that the web services solution above, as an added bonus, handles all of the xml for you, although implementing security headers will require some knowledge of SOAP and maybe security standards. It's probably best to make these high-level decisions and ask more specific questions here as you go along.

Using Wicket in conjunction with Wordpress

I have a Java-application using Wicket for the frontend. Now I want gradually switch over to WordPress-frontend. First off, the startpage is going to be in WordPress. Is there a good way to use Wicket in conunction with WordPress? Wicket is so tightly coupled with the Java, I was unsure of how to do it.
If anyone can give me some best practices or tips, or links to people who have gone through similar scenarios i'd be very grateful.
To start with, what you are looking to do is likely impossible in the same runtime container. There are ways to run PHP in Java (Quercus comes to mind), but some applications are not well suited for this.
If you want to run in multiple containers, you may be able to fake this out at the browser level with iframes, but you will need Wordpress plugins that can orchestrate setting iframe destinations to your current Tomcat container running Wicket.
It would be helpful to understand why you are doing this. Wordpress has an excellent product, and this isn't to discourage you from going that direction. But if you are just trying to gain CMS functionality, you may want to check out Brix, which is a Java Content Repository backend for Wicket.

Which Java web development framework for an AJAX application?

I read through a few threads (simple web framework, java web development, etc). Very informative. However I have not seen a focus on the AJAX side of things. For the app I am trying to create, most of the client side will be written in Google GWT, and JSON will be used to communicate with the server side. In that case, all templating is pretty much useless.
For my purposes, which framework would be the simplest to setup and easiest to learn?
Thanks.
To clarify, I want a server side framework. GWT is great for client side, but I need something to generate json responses on the server side.
None at all, most likely: GWT is framework enough, given that's what you're using. The only reason I can think of to add anything else might be if there was some special effect you absolutely craved (but if you've chosen to go GWT, my recommendation would be to give up on such special effects),
Ajax/JS by nature functions mostly on client side and you want to use it but want to run it on server side? Are you sure you're not trying to hammer a square block into a round hole?
Reading through your question it seems to me what you're really asking is for a way to abstract a layer which provides JSON for your client side UI. Most web frameworks such as GWT deliberately abstract this part away but still include it in their inner workings: it would indeed be rather stupid for an Ajax web framework not to support data transfer between the view layer and the rest of the system!
However, if you really want to create your own custom component for serving JSON, then I suggest you take a good look at Servlets and mix that with any of the gazillion available JSON libraries listed at JSON.org.
And if you still really, really want to run your client side view logic on server, Vaadin could do the trick for you. In practice Vaadin really runs GWT on the server side and just serves static stuff generated by the server side GWT but from what I've understood the difference has been abstracted away.
A huge word of warning though, for me it sounds like you really want to reinvent the wheel here while you shouldn't. You really should reconsider your architecture and/or deepen your knowledge of GWT and web frameworks in general, the "framework" part usually hints that it's not just the V from MVC Model 2 but at least V and with M bindings.
I've had pretty good luck with the Dojo Toolkit. Make sure to download the full toolkit (Dojo, Dijit and Dojox) which you'll find at the downloads page.
Their 'Hello World' tutorial is pretty useful for getting started.
You could could give IceFaces a try. It's a Ajax framework based on faces technology. Works really great and magically, also comes with a good documentation and tutorial.
You should look at one of the REST based frameworks, like Jersey, Restlets, or RESTEasy.
The main reason is that these frameworks make binding and working with JSON easy. Most of the other systems are designed for HTTP POST encoded data, which is not JSON.

Categories