The way around using rpc/encoded style in CXF - java

I know that CXF does not support the rpc/encoded WSDL style and I am looking for a solution to get the way around this. I have to do the implementation of rpc/encoded style web service, the problem is that the service has to be deployed in Apache Karaf 2.2.9 as an OSGi bundle which uses CXF 2.6.2 and there is no way I can implement the rpc/encoded ws.
What I am thinking is to create another web service, which will be running on a different container and would be generated with Axis 1.4. It would work as a wrapper for CXF web service which is deployed into Karaf.
I don't really like this solution, because there has to be another container involved. Maybe someone can suggest me the solution how to make this work without other container? (If it is possible at least).

Glen has a tutorial for that:
http://www.jroller.com/gmazza/entry/calling_rpc_encoded_web_services
but it really isn't that straight forward.

Related

Implement WS-Policy in a JAX-WS Web Service

I am developing a SOAP Web Service in Java with JAX-WS. I am using Eclipse Juno and Weblogic 12c. The web service is being developed in an EJB Project. I am using a top-down approach: from a WSDL that I have, I use JDK's wsimport tool (via command-line) to generate all the Java classes, I import them to the project and then I provide an implementation for the SEI.
The WSDL has a specification of a WS-Policy with a wsp:Policy tag, but the code generated from wsimport has no kind of information/annotation for this. As such, I suppose I've to write it myself.
From the search that I've made, it seems that either I've to use some Weblogic annotation or use some CXF/Axis/Metro feature. Is this true? Can't I use anything from JAX-WS? I read that CXF/Axis/Metro are all implementations of JAX-WS, but I don't have any idea if I'm using one of them, I think I am using JAX-WS reference implementation, but I don't know if this is true.
I also would like to keep an implementation independent from any application server (Weblogic, in this scenario). If I have to use CXF/Axis/Metro, how can I add their features to my EJB Project?
Firstly you can use Metro, Axis or any other third party library in your project to generate your client code. However if you want not to use third party libraries, you can generate the needed wsse headers on your own.
The followinf link described how to generate your desired headers in order to call wsse secured web services, you should just implement your own SOAPHandler :
http://www.javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client/

Restful Webservice Java, server side

I'm trying to develop a small server which would include one restful webservice.
I'd like to use JAX-RS for the webservice part, but every example I'm seeing is using a tomcat server, and I can't use any 'application' server (meaning I can create a server in my code, but can't run it from the outside).
Well anyway I was wondering if anyone had any sample to show, and any advice on which light library I could use to run such a simple server into my code (can't use any gpl /lgpl etc licence, so no jersey for example).
Thank you.
It's possible to embed Tomcat in your application, see here for an example: http://java.dzone.com/articles/embedded-tomcat-minimal
Another popular choice for an embedded servlet container is Jetty, they have a tutorial here.
Edit
The examples provided with Jersey can also be helpful, here's one for running using the Grizzly HTTP library: https://github.com/jersey/jersey/blob/master/examples/helloworld/src/main/java/org/glassfish/jersey/examples/helloworld/App.java
You can even use the HTTP server that's bundled with the JDK (probably not the way to go for a real application): https://github.com/jersey/jersey/blob/master/examples/helloworld-pure-jax-rs/src/main/java/org/glassfish/jersey/examples/helloworld/jaxrs/App.java
Have you checked out http://www.sparkjava.com/?
It's very light-weight and concise.
Building a server into code is nothing. See "Embedding Jetty", for one. There are plenty of other options with varying degrees of difficulty and capabilities, like the Simple Framework, Tomcat, Grizzly, Netty, and Vert.x, to name a few. Then, if you're not stuck with Java, the language, there's Ratpack for a lightweight REST server. Otherwise, running something like Jersey in an embedded server is quite simple. I do it every day in tests.

Using Jersey without an application server

I am looking to use Jersey without the need of installing an application server such as Tomcat or Glassfish. Ideally I would like to create a lightweight program that listens on a port and allows connections. I believe you can do this with Grizzly + Jersey but I am not sure how easy this is, because from my understanding Grizzly is used to write new http servers from scratch?
Restlet looked good in this regard because it included an internal http server but the documentation provided is extremely meager.
You can use a light-weight servlet container like jetty. you can bundle and ship this with your application. Also building and shipping jetty with your application is very easy.
I've deployed an app recently that uses embedded Jetty in Spring to launch Jersey, so this is 100% possible. Jersey, in fact, has a SpringServlet for easy delegating to a Spring context based REST implementation. If you have additional questions down this route, let me know. It wasn't the most straight forward, but I can talk you through some of it with the appropriate links.

Java Web Service for .NET 2.0 Client on Linux (Fedora)

I'm tasked with creating a Java Web Service for a .NET 2.0 client to consume.
What would your suggestions for the implementation be?
The solution doesn't need to be very heavyweight (don't need a full Java EE container I believe) but what do you think is the best solution for this? I have thought about using Glassfish v2 with JAX-WS annotations (#WebService), and JAXB XML Bindings(e.g. #XmlElement), which I assume the .NET client would be able to consume?
Has anyone tried this scenario?
Would Glassfish be overkill though, since I'm merely using the Web Service as a mechanism for .NET on Windows to communicate to the Linux box, the underlying application is extremely small.
Any suggestions are more than welcome :)
Thanks,
James
P.S. Other notes - would you use Axis/CXF instead of Glassfish? Would you use a servlet container such as Tomcat? etc.
I have used Axis2 and it works.
I had the same problem of making Data Exposing API (Web Service in my case) in Java.
I made the web service using Axis2 and Spring (to access database) and the WSDL created via Axis2 was easily consumed via ASP.NET Application via its Add Web Service Dialog Box and the corresponding Proxy Classes were created easily.

Consuming web services with jboss

Can someone point me a good step-by-step tutorial to consuming an already running web service in java?
PS: I tried creating the classes with wsconsume, but it cries with
[ERROR] rpc/encoded wsdls are not supported in JAXWS 2.0. (my web service is rpc/encoded)
If I can consume web services entirely by hand (using no wizards), and understand how is it working, then I'll be happy.
Thanks!
Update: I have found out that rpc web services are not consumed using jbossws, but jboss-jaxrpc, which implements the JAX-RPC specification. I've found a guide for JAX-RPC here, but I'm still looking for other guides that could help.
Apache CXF is the easiest way to get webservices running. Specifically look at the Simple Frontend. The simple front end uses reflection to convert the method/data types to a webservice. It doesn't get much easier than that.
CXF is pretty stable, but does not include all the WS specifications (WS-Eventing for example).
How about the JBossWS website? The details on the client side wsconsume tool are probally what you will look at first.
If you have the WSDL and XSD files, you can use the Axis web-services library to create Java classes that will interact with the services they describe. From the stand-point of this library, you are creating a client application.
You can also consume web services with Spring WS.

Categories