DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Using SQS With JMS for Legacy Applications
  • Javac and Java Katas, Part 2: Module Path
  • Javac and Java Katas, Part 1: Class Path
  • Ways To Reduce JVM Docker Image Size

Trending

  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • Picture Perfect: Choosing Your Featured Image
  • A Walk-Through of the DZone Article Editor
  • DuckDB for Python Developers

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

Generating a JAX-WS Webservice Client JAR From a WSDL

This article highlights some hidden and important configuration steps for creating a WS client JAR file.

By 
Ahmet KURUKÖSE
·
Jul. 03, 16 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
50.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

It seems generating a JAR file to consume a JAX-WS Webservice is fairly easy. But if you don't pay attention to the following points, it may suddenly become a nightmare for you.

So in this article, I will try to highlight some hidden and important configuration steps for creating a WS client JAR file.

  • First things first, you should pay attention to which Java version (Java 6, Java 7, or Java 8) you are using for your project. If your Java project depends on Java 6, and if you then create a client with Java 7 or Java 8, then you will get an UnsupportedClassVersionError error.

  • Create a temporary directory: (/home/ahmet/tmp).

  • Create a directory named target in tmp folder: (/home/ahmet/tmp/target).

  • Save your wsdl to the tmp directory: (/home/ahmet/temp/service.wsdl).

  • Edit your wsdl file and change the URLs from real Webservice addresses to localhost, then save and close the wsdl file.

  • Create a directory named META-INF in tmp folder: (/home/ahmet/tmp/target/META-INF).

  • Put your wsdl in the META-INF folder also: (/home/ahmet/tmp/target/META-INF/service.wsdl).

  • Create a file called jax-ws-catalog.xml with the following content:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
   <system systemId="http://localhost/wsdl/service.wsdl"uri="service.wsdl"/>
</catalog>
  • Also, put this file to META-INF folder: (/home/ahmet/tmp/target/META-INF/jax-ws-catalog.xml).

  • Create a file called Jaxb-bindings.xml with the following content: 

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:version="2.1">
    <jaxb:globalBindings>
        <xjc:serializable uid="1"/>
    </jaxb:globalBindings>
</jaxb:bindings>
  • Put this file to tmp folder (/home/ahmet/tmp/Jaxb-bindings.xml).

  • Please be sure that your operationg system locale is not in Turkish. wsimport capitalizes the lowercase characters at some points that cause some weird characters in code.

  • Be sure that you are in the tmp folder and run the following command (/home/ahmet/tmp):

wsimport -d target -keep -p PACKAGENAME -b Jaxb-bindings.xml -wsdllocation http://localhost/wsdl/service.wsdl -catalog jax-ws-catalog.xml service.wsdl


  • Change your working directory to target (/home/ahmet/tmp/target) and run the following command:

jar cvf service.jar .
  • Your Jar file is ready to use :)

JAR (file format)

Opinions expressed by DZone contributors are their own.

Related

  • Using SQS With JMS for Legacy Applications
  • Javac and Java Katas, Part 2: Module Path
  • Javac and Java Katas, Part 1: Class Path
  • Ways To Reduce JVM Docker Image Size

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook