Javatpoint Logo

91-9990449935

 0120-4256464

Javatpoint Logo

JAX-WS Example Document Style

Like RPC style, we can create JAX-WS example in document style. To do so, you need to change only one line in service interface.

You need to use Style.DOCUMENT for @SOAPBinding annotation in place of Style.RPC. Let's have a quick look at this:

File: HelloWorld.java

Now Let's see the full example of JAX-WS in document style.

There are created 4 files for hello world JAX-WS document style example:

  1. HelloWorld.java
  2. HelloWorldImpl.java
  3. Publisher.java
  4. HelloWorldClient.java

The first 3 files are created for server side and 1 application for client side.


JAX-WS Server Code

File: HelloWorld.java

File: HelloWorldImpl.java

File: Publisher.java

If you run the publisher class, it may generate following error:

Wrapper class com.javatpoint.GetHelloWorldAsString is not found. 
Have you run APT to generate them?

To solve the problem, go to bin directory of your current project in command prompt and run the following command:

wsgen -keep -cp . com.javatpoint.HelloWorldImpl

Now, it will generator 2 files:

  • SayHello
  • SayHelloResponse

Paste these files in com.javatpoint directory and then run the publisher class.

How to view generated WSDL

After running the publisher code, you can see the generated WSDL file by visiting the URL:


JAX-WS Client Code

File: HelloWorldClient.java

Output:

Hello World JAX-WS javatpoint document

Click me to download JAX-WS server example Document style (eclipse)
Click me to download JAX-WS client example Document style (eclipse)
Next TopicJAX-RS Tutorial




Latest 4 Tutorials on JavaTpoint