Saturday, 10 January 2015

Invoking web-service to consume web methods(Basic Web-Services Part4)


1)Using SoapUI Tool  :- Create new project in tool then provide WSDL url and project name then click ok.


Now click on any methods on left hand side and then select any request to view output


2)Using Java Client :-  We need to write a java client to invoke the web-service

package com.krishna.webservice.basics;

import java.net.MalformedURLException;
import java.net.URL;

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

public class WebServiceClient {

public static void main(String args[]){

try {
URL url = new URL("http://127.0.0.1:9876/ws?wsdl");
QName qname = new QName("http://basics.webservice.krishna.com/","NewJoinesImplService");
Service service = Service.create(url, qname);
JoiningFormalities joiningFormalities= service.getPort(JoiningFormalities.class);
System.out.println("Message :-"+joiningFormalities.showWelcomeGreetings());
System.out.println("Role :-"+joiningFormalities.getEmployeeRole());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}


Output :- 


No comments:

Post a Comment

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...