activation.jar
axis-1.4.jar
commons-collections-3.1.jar
commons-discovery-0.2.jar
commons-io-1.3.1.jar
commons-logging.jar
jaxrpc.jar
mail.jar
saaj.jar
utility.jar
webserviceutils.jar
wsdl4j-1.5.1.jar
xercesImpl.jar
xmlsec.jar
2) create class that invokes and call the webservice in Client project
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
public class Client {
public static void main(String[] args) {
try {
String endpoint = "http://localhost:8080/DestinedProjectname/AddFunction.jws?sdlwsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(endpoint, "addtwonumbers"));
call.setTargetEndpointAddress(new java.net.URL(endpoint));
System.out.println("In the Try"+call);
Integer ret = (Integer) call.invoke(new Object[] {
new Integer(10), new Integer(11) });
System.out.println("addInt(5, 7) = " + ret);
} catch (Exception e) {
System.err.println("Execution failed. Exception: " + e);
e.printStackTrace(); }
}
}
3) Create Destined project to be webserviced
public class AddFunction {
public int addInt(int a, int b){
return (a+b);
}}
public class AddFunction {
public int addInt(int a, int b){
return (a+b);
}}
4)Copy the AddFunction Class and Rename with (.jws) extention
5)Right click onthe AddFunction class ->New->others->Webservices->wsdl
6) change the soap address in wsdl as below
"http://localhost:8080/serverProject/services/AddFunction"
No comments:
Post a Comment