Sunday, July 8, 2012

Developing Bottom-Up JAX-WS (Client)

Create a new Java project and copy the Service Endpoint Interface (SEI) Java class file from the server implementation.
Then create the following Client implementation:
package com.jadobo.ws;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

public class TestMain {

    private static final QName SERVICE_NAME 
        = new QName("http://ws.jadobo.com/", "HelloWorldService");

    public static void main(String args[]) throws Exception {
     
     URL wsdl = new URL("http://localhost:9000/helloWorld?wsdl");
        Service service = Service.create(wsdl, SERVICE_NAME);
        
        HelloWorld hw = service.getPort(HelloWorld.class);
        System.out.println(hw.sayHi("World"));
    }
}

Sample console output after Client execution:
INFO: Dynamically creating request wrapper Class com.jadobo.ws.jaxws.SayHi
INFO: Dynamically creating response wrapper bean Class com.jadobo.ws.jaxws.SayHiResponse
Hello: World

2 comments:

  1. You guys out there are performing a great job.
    tulsa web design

    ReplyDelete
  2. Java development more secured and used in to prepared high performance software. ERP software development especially developed in java, because it has had fewer chances of errors and bugs.

    ReplyDelete