Generating JAX-WS clients for JAX-RPC and JAX-WS Web services

JAX-WS has simplified the development of Web Service clients when compared to JAX-RPC. Both technologies have a tool for importing a WSDL to generate client side artifacts. JAX-RPC’s tool is wscompile, JAX-WS’ tool is wsimport. The biggest advantage of JAX-WS clients over JAX-RPC clients is portability. JAX-WS generates 100% portable artifacts, while JAX-RPC generated artifacts are not all portable. Also, since JAX-WS is included in Java SE 6, client applications are much smaller.

The wsimport tool generates JAX-WS portable artifacts, such as:

  • Service Endpoint Interface (SEI)
  • Service
  • Exception class mapped from wsdl:fault (if any)
  • Async Reponse Bean derived from response wsdl:message (if any)
  • JAXB generated value types (mapped java classes from schema types)

Will I be able to connect to a JAX-RPC web service using a JAX-WS (wsimport) generated client stub?

The tool wsimport works on a WSDL file which is an XML document describing the web service.

  1. The tool wsimport does not care to the style of the service (RPC/DOCUMENT) as described in the WSDL.
  2. If the WSDL has RPC-style, it will generate the client stubs for consuming RPC-style web services and similarly for document-style.
  3. JAX-WS (which provides wsimport) provides (or rather capable of generating ) both styles (RPC/Document) of web services and both work equally well with respective types of service end points.

Java 7 support the JAX-WS 2.2.4, which has introduced a new (since JAX-WS RI 2.2.2) -clientjar option of wsimport tool, which automatically downloads the wsdls and schemas and packages all the generated client-side artifacts into a jar file, so just by including the generate jar file by this new option in the classpath, there is no need to fetch the wsdls from the end point each time a service instance is created, thus saving on network overhead.

JAX-WS Web Service with JDeveloper on Weblogic 12c

JDeveloperJAX-WS

JAX-WS Web Service client on Eclipse platform

cd C:\Users\emiltom\workspace1\WSClient
C:\jdk1.7.0\bin\wsimport -s src -d bin http://192.168.56.1:7001/Application1-Project2-context-root/WS1Port?WSDL

[WARNING] Ignoring SOAP port “WS1Port”: it uses non-standard SOAP 1.2 binding.
You must specify the “-extension” option to use this binding.

C:\jdk1.7.0\bin\wsimport -extension -s src -d bin http://192.168.56.1:7001/Application1-Project2-context-root/WS1Port?WSDL

EclipseClientJAX-WS

 

JAX-RPC Web Service with JDeveloper on Weblogic 12c

JDeveloperJAX-RPC

WLSRPC

 

JAX-WS Web Service client on Eclipse platform

cd C:\Users\emiltom\workspace1\WSClient1
C:\jdk1.7.0\bin\wsimport -s src -d bin http://192.168.56.1:7001/Application1-Project3-context-root/WSRPCPort?WSDL

EclipseClientForRPC

Oglasi
Ovaj unos je objavljen u Nekategorizirano. Bookmarkirajte stalnu vezu.

Komentiraj

Popunite niže tražene podatke ili kliknite na neku od ikona za prijavu:

WordPress.com Logo

Ovaj komentar pišete koristeći vaš WordPress.com račun. Odjava / Izmijeni )

Twitter picture

Ovaj komentar pišete koristeći vaš Twitter račun. Odjava / Izmijeni )

Facebook slika

Ovaj komentar pišete koristeći vaš Facebook račun. Odjava / Izmijeni )

Google+ photo

Ovaj komentar pišete koristeći vaš Google+ račun. Odjava / Izmijeni )

Spajanje na %s