Wednesday, 17 December 2008

JAXWS - Create Web Service Client

i) install SOAP UI Plugin for Eclipise
http://www.soapui.org/eclipse/update/site.xml

ii) Create a new project for the HelloSeriveClient (Java Project)

iii) Select the project and Right Click->Soap UI->Add SOAPUI Nature, SOAP UI WebService item will be added

iv) Select SOAP UI perspective
Right click on Projects->hellowworlclient->Add WSDL from URL, enter the deployed service URL: http://localhost:8080/HelloService/Hello?wsdl. This will import the wsdl and you will see HelloPortBinding

v)Select HelloPortBinding and Right Click->GenerateCode->JAX-WS Artifacts
Enter the appropriate info in the JAX-WS Artifacts window

vi) Click Tools and enter the location of JAX-WS Wsimport.bat file.
* if you are using Java6 create the wsimport.bat file (only wsimport.exe file is available in Java 6, but soapUI plugin expects wsimport.bat file)
@echo off
setlocal
call wsimport.exe %1 %2 %3 %4 %5 %6 %7 %8 %9"
endlocal

vii) Click OK

viii) Then click Generate on JAX-WS Artifacts window, it will display dialog box the operation was successful. Switch back to Java Perspective, then refresh the src folder and you can see the wsimport generated classes.

ix) Now you implement HelloServiceClient code.

package test;

import mypackage.Hello;
import mypackage.HelloService;

public class TestHelloService {

/**
* @param args
*/
public static void main(String[] args) {
// Create Service
HelloService service = new HelloService();
//create proxy
Hello proxy = service.getHelloPort();
//invoke
System.out.println(proxy.sayHello("srini"));
}

}

2 comments:

  1. https://www.blogger.com/comment.g?blogID=38586079&postID=3077577394420501762&page=1&token=1468397529735&isPopup=true

    ReplyDelete