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
Over 2 million developers have joined DZone.
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

  • Catching Data Perimeter Drift Before It Reaches Production
  • Building Enterprise-Grade Real-Time IoT Dashboards with Vue 3, MQTT, and Kafka
  • Your AI Agent Tests Are Passing, But Your Agent Is Still Broken
  • Key Takeaways From Integrating a RAG Application With LangSmith

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 user avatar
Ahmet KURUKÖSE
·
Jul. 03, 16 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
50.1K Views

Join the DZone community and get the full member experience.

Join For Free

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

The likes didn't load as expected. Please refresh the page and try again.

  • 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