we currently have a problem with supporting a legacy API offered via SOAP-RPC. The current service is exposed via a PHP extension and now we would like to offer it via Java. Switching to a Java implementation would mean a SOAP-WS service since we could not find a way to expose SOAP-RPC in Java.
The facts:
Our Java application runs as a servlet in Tomcat
document style "rpc" is not supported in Apache CXF, leads to arrays described differently
Apache CXF only supports JAX-B and not JAX-RPC.
Is there any way / tutorial to explain the writing of a SOAP-RPC service with current technology like Spring-WS or Apache CXF?
Related
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I read somewhere in the internet that JAX-WS is a SOAP implementation and JAX-RS a Rest implementation. Is this true? Are JAX-WS and JAX-RS implementations or specifications?
Thanks in advance.
They are specifications that define APIs.
JSR 224: Java API for XML-Based Web Services (JAX-WS) 2.0 http://jcp.org/en/jsr/detail?id=224
JSR 311: JAX-RS: The JavaTM API for RESTful Web Services http://jcp.org/en/jsr/detail?id=311
The APIs (interfaces, classes, and exceptions) they define require implementations.
The reference implementation (RI) for JAX-WS is included in Java SE. The JAX-WS RI is created as part of the Metro project (http://metro.java.net/). Metro includes enhancements and features beyond what the JAX-WS RI supports. In the SOAP world there are optional features like WS-Security that a web service stack can support. Metro supports those while the JAX-WS RI does not.
Since the JAX-WS is included in Java SE, yes you can make JAX-WS (SOAP) web services without a server. This is because there is a very basic HTTP server included in Java SE. You use the Endpont class to publish a service. This is really meant more for testing than anything else. The real reason JAX-WS is included in Java SE is to make it easier to be a SOAP service client. To truly run a JAX-WS web service you need a server such as GlassFish, JBoss, or WebLogic. There is some ability to add a JAX-WS implementation to Tomcat but only a true Java EE Application Server includes a complete implementation out of the box.
The reference implementation (RI) for JAX-RS is named Jersey (http://jersey.java.net/). JAX-RS is not included in Java SE. You must download an implementation. Once you download it you could use it without a server but again, it is really meant more for use in a server. One reason you download Jersey is to get the Jersey Client API to write clients (which is not a part of the current JAX-RS specification). Like with a JAX-WS implementation, you can add Jersey to Tomcat or a full Java EE Application Server will include a JAX-RS implementation.
JAX-WS and JAX-RS are both libraries (APIs) for doing communication in various ways in Java.
As you mentioned, JAX-WS is a library that can be used to do SOAP communication in Java, and JAX-RS lets you do REST communication in Java.
JAX-WS is a set of Java interfaces, classes, and annotations introduced in JSR 224:
The JAX-RPC 2.0 specification extends the existing JAX-RPC 1.0 specification with new features, including some or all of the following: direct support for JAXB 2.0-based data binding, support for the latest W3C and WS-I standards (e.g. SOAP 1.2, WSDL 1.2), standardized metadata for Java<->WSDL mapping, ease-of-development features, support for easier evolution of Web services, an improved handler framework, support for asynchronous RPC and non-HTTP transports.
It's an API and requires a runtime implementation, provided by, for example, Apache Axis2.
JAX-RS is an API for RESTful client/server communications introduced in JSR 311:
This API will enable developers to rapidly build Web applications in Java that are characteristic of the best designed parts of the Web. This JSR will develop an API for providing REST(Representational State Transfer - See reference to Roy Fielding's dissertation in section 3.1) support in the Java Platform. Lightweight, RESTful approaches are emerging as a popular alternative to SOAP-based technologies for deployment of services on the internet. Currently, building RESTful Web services using the Java Platform is significantly more complex than building SOAP-based services and requires using low-level APIs like Servlets or the dynamic JAX-WS APIs. Correct implementation requires a high level of HTTP knowledge on the developer's part.
Again, it requires an implementation, provided by, for example, Jersey.
I am trying to call a web service from java. I am using JBoss as the client application server. The Web server is written in jax-ws and is running in some other server (which i dont know).
My requirement is to call the web service from my application running in JBoss. After doing enough search, I found that, jax-ws is a Standard and now included in jdk. Metro is a reference implementation of jax-ws and is provided in the Glassfish App server.
My Question is: -
Is there any other jax-ws implementation present in the market?
Just like each container provides its own implementation of Servlet API, do all of them provide implementation of Jax-ws?
Do I need to copy the Metro api to my Jboss application?
Where does JBossWS comes into play here?
A sample code provided by the Web Service host specifies that, the client needs to have to add a authentication token to the SOAPHeader, and in the sample code they have used com.sun.xml.ws package.
When I used MessageFactory to create a new SOAPMessage, will it use the Metro RI or JbossWS?
If Metro is glassfish's implementation of Jax-ws, then will it run in other app servers?
Added to that, my application exposes another Web service also (although it uses Axis 1).
I am getting a bit confused regarding this.
Can someone help me with some details regarding jax-ws, Metro, JbossWS. And where do each of them stand.
JBossWS is the Web-Service stack provided by the JBoss Application Server, and yes, it is also an implementation of the JAX-WS standard. As far as I know, JBossWS is based on Apache CXF.
Glassfish uses another implemetation of JAX-WS, Metro.
In order to communicate with a remote WebService (the implementation is not important, as long as it uses standards), you can simply use JAX-WS api and any Application Server which provides an implementation for it. JBoss does, so you have just to write your client following the JAX-WS api (and it should run on both JBoss and Glassfish or any other JAX-WS compliant container).
About the authentication, you should provide some more information, since there are a lot of options in the standards here.
I am new to web services and below I am sharing my understanding so far by reading on net:
Apache Axis and Apache CXF - are web services frameworks used to develop Java web services.
JAX-RS - Java API to develop Restful web services.
JAX-WS - Java API to develop SOAP web services.
Is the above correct? Or if you want to add something to it.
In my project, I am going to use web services with Spring framework.I am told that project will have both SOAP and RESTful web services.I am very much new to this.
Can somebody please guide me in this regard by sharing some valuable information or any good link which will make me understand better?
Your statements are correct, but it's not clear whether you've understood one crucial fact: CXF and Axis are both implementations of the JAX-WS standard. CXF additionally implements JAX-RS, and there are some libraries that only implement JAX-RS, such as Jersey (Oracle's reference implementation) and RESTEasy from JBoss.
For your project, the big question is whether you will only consume those webservices, or also publish them. If you need to publish a webservice, you'll have to include the entire implementation library and learn to use it. If you only consume the services, you'll just need some generated client and data binding classes.
Another question is whether your RESTful services will talk XML or JSON (SOAP always uses XML), as you'll need a parser or binding framework for JSON (JAX-B for XML is included in recent JDKs).
I am in the process of writing a JSON based web service. The service will accept two types of requests: commands (e.g. createOrder) and queries (e.g. getOrders). Each request needs to send user credentials (username/password) for authentication (perhaps in HTTP headers). The service needs to be implemented in Java.
Which frameworks would you recommend for this use case? The very basic stack that I am thinking of is servlets backed by a JSON framework like Jackson. Are they any other frameworks that you would recommend and why? There is no need or desire to make the service RESTful, however smooth integration with Java EE 6 or Spring would be a plus.
Thanks in advance for your time.
Can I then interest you in RESTful Web Services (which is a JAX-RS API)? A library that implements JAX-RS is Jersey, Apache CXF, which is suited to allow JSON Web Service.
A related StackOverflow Post which shows REST clients that conforms to JAX-RS.
You should take a look at spring mvc and read this blog post which cover using spring mvc for restful WS.
Play! Framework would definitely fit your bill. It is not servlet-based but fulfills all of your requirements. Plus development with Play is very fast, you can get a prototype up and running in no time.
I personally use Apache CXF, with JAX-RS and jackson libraries. They are easy to implement and integration is dead easy. JAX-RS is a java standard, Jackson library is fast and handles circular references and Apache CXF needs only a couple of lines of configuration to setup and start running. Go for it!
An Open-Source Services Framework From Apache
-CXF has been designed to provide a pluggable architecture that supports not only XML but also non-XML type bindings, such as JSON and CORBA, in combination with any type of transport.
-Java EE integration: deploy services in Java EE application servers such as Apache Geronimo, JOnAS, Redhat JBoss, OC4J, Oracle WebLogic, and IBM WebSphere
-Standalone Java client/server
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.