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
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/
Can any one tell me how to public the wsdl file ie., that web service is created in java using eclipse.I am self learner to java/eclipse and web service too,so can any one please make me clear with steps.
Thanks for your time!...
Apache Axis has some cool tools that I frequently use - to generate a wsdl, use java2wsdl. It has a command line version, but also a Maven plugin (which I highly recommend) that will re-generate the wsdl for you automatically each time you package your web service.
What's more, the axis stuff also provides auto-generation of client stubs by which you can use your web service in consumer apps or services. Alternatively, JAX-WS tools can be used for this as well. In either case I would recommend automating the process with Maven.
If you package your wsdl with your app in this way (rather than letting a server do this for you automatically), you can be certain that your contract will look the same on any platform.
I have already generated the files using wsdl2Java and created the proxy client in JAVA.I am using Apache CXF framework and using Maven as Build Management tool. I can run the JAVA application and consume the service using JAVA. There is no problem with JAVA implementation.
The need is I need to invoke and request the same web service from PHP or JSP file and display the result in PHP or JSP file. I would like to use the present JAVA code. I don't know how to invoke the JAVA code from PHP or JSP page.
Please help me with the solutions.
You have created a web service, so your design should be centered around that. For Java programs (including JSP's) you can use the generated client classes to access the web service. For PHP I would recommend using one of the many SOAP client libraries to process and consume your WSDL. You might want to take a look at wsdl2php, NuSoap, or SoapClient.
Is there any excellent tool in JAVA to deal with webservice or wsdl?
Yes. There is a standardized API (JAX-WS) that is even integrated into the Java standard API (the javax.xml.ws packages) since Java 6, and multiple implementations thereof, such as Axis and CXF.
Read about wsimport utility, which generates client-support code from the WSDL document (or URL pointing at service endpoint).
If you are using Eclipse try Eclipse Web Tools Platform Project, it's good at my point of view and sufficient for me.
For IntelliJIDEA Web Services link
If you're a Spring user, I'd recommend the Spring web service module. It makes using WSDL, creating web services, and implementing clients easy.
I'm developing a web service client that needs to execute operation exposed on tomcat with axis2. The client has all the wsdl files that are needed. I can't import them statically with netbeans or eclipse because the client needs to discover the wsdl at runtime (this has been already done) and then execute them in an fixed order...
What should I do? My program is able to get those wsdl files but I don't know what to do with them... What should I use: jax-ws? jax-rpc?? Can you give me a link to a guide or something else??
Thank you in advance
Depending on your stack you can write webservice clients using a variety of tools/framework/libraries. Such as Spring-WS, Apache CXF or JAX-WS RI. Take a look at some and you'll get a feeling how to consume webservices.
What client platform/implementation and webservice rumtime do you intend to use on the client? For example if it is JAVA, you can use the RAD tooling from IBM or wsdl2java AXIS ant task to generate the java stubs. If it is MS platform, you can use Visual Studio tooling from MS to generate csharp stubs from the WSDL. Then you populate the objects to create the SOAP xml message format that your webservice provider expects.
You might look into Dynamic Clients with Apache CXF, looks like it can do exactly what you're looking for.