DZone
Java Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Generating a JAX-WS Webservice Client JAR From a WSDL

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.

Ahmet KURUKÖSE user avatar by
Ahmet KURUKÖSE
·
Jul. 03, 16 · Java Zone · Tutorial
Like (7)
Save
Tweet
45.68K 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.

Popular on DZone

  • Checklist for API Verification
  • Which JVM Version Is the Fastest?
  • How to Submit a Post to DZone
  • Datafaker: An Alternative to Using Production Data

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo