I have one query regarding wsgen and WSServlet.
wsgen tool is used to parse an existing web service implementation class and generates JAX-WS portable artifacts for web service deployment.
Also if I am deploying my JAX-WS webservice on tomcat, I can make use of WSServletContextListener and WSServlet to deploy my webservice (I am using sun-metro implementation).
So my confusion do both are doing the same work, or one have advantage over other in some specific scenarios?
Please suggest.
Related
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/
Normally I go for top-bottom service creation(e.g. write wsdl, then generate a service based on it)
now I need to generate a service in a bottom-up - what would be the best tool for it?
I have an old guide which describes generation of ws using Sun Java Studio Enterprise - it does not exist anymore as I may see... so what is the substitution?
I use Apache CXF for creating and using web services. It's really easy to use and I have never had any big problems with it.
You can use Java API for XML Web Services (JAX-WS) for create Web Services. JAX-WS uses annotations to simplify the development and deployment of web service clients and endpoints. JAX-WS can be used in Java SE starting with version 6.
There is several JAX-WS implementations:
Apache Axis2/Java
Apache CXF
Metro
You can follow the JAX-WS Five Minute Tutorial of Mohammad Juma. And, why not, Deploy JAX-WS Web Services On Tomcat.
For NetBeans and Glassfish, you can see Getting Started with JAX-WS Web Services. On eclipse, you can see Step by Step tutorial to create a JAX-WS with Eclipse, CXF and Glassfish V3.
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.
Will I be able to connect to a JAX-RPC web service using a JAX-WS (wsimport) generated client stub? What are the effects of consuming a JAX-RPC web service using a JAX-WS client? Are there any advantages and disadvantages?
The tool wsimport works on a WSDL file which is an XML document describing the web service.
The tool wsimport does not care to the style of the service (RPC/DOCUMENT) as described in the WSDL.
If the WSDL has RPC-style, it will generate the client stubs for consuming RPC-style web services and similarly for document-style.
JAX-WS (which provides wsimport) provides (or rather capable of generating ) both the style (RPC/Document) of web services and both work equally well with respective types of service end points.
Here is an example of using wsimport for generating JAX-RPC client.
Hope this helps.
I am normally used to using JSON/REST. I have been given access to a web service with WSDL file that I need to use to read data. I have no idea where to start
What is the quickest easiest way to get JAVA code up and running that can query this web "service"?
You can use libraries like Apache AXIS or Apache CXF, which include a WSDL2Java program you can run to parse the WSDL definition file and generate classes that let you invoke the web service.
Pick your framework (popular ones include Axis2, Spring-WS, Jax-WS). 2. Use the tool that comes with your framework to create Java proxies (for example, for Axis2, you'll use wsdl2java). 3. Write code that uses the generated proxies to actually call your web service.
I recommend Sun's JAX-WS (now built-in to Java 6). Google it (I can only post one link, below).
Some links...
Main site:
jax-ws.dev.java.net/
JAX-WS is under the Glassfish Metro project, but you don't need Glassfish to use it (we don't). However this is a good resource:
metro.dev.java.net/guide/
For starting with WSDL, see specifically:
https://metro.dev.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html