When you use axis to access a Web service, you need to introduce the following packages (10):
Axis-ant.jar,
Axis.jar,
Commons-discovery-0.2.jar,
Commons-logging-1.0.4.jar,
Jaxrpc.jar,
Log4j-1.2.8.jar,
Saaj.jar,
Wsdl4j-1.5.1.jar,
Activation-1.1.jar and Mail-1.4.jar.
Here is an example of a Java code:
1 Packagedemo;2 ImportJavax.xml.namespace.QName;3 ImportOrg.apache.axis.client.Call;4 ImportOrg.apache.axis.client.Service;5 6 Public classCallforservice {7 Public StaticString keywordurl= "interface Address";8 9 Ten Public Static voidMain (string[] args)throwsException { OneGetkeyword ("Enter the parameters you want to pass"); A } - - //Web Service Interface Access the Public StaticString Getkeyword (String s)throwsexception{ - //reading configuration Files -Service service =NewService ();//Calling Interface -Call call =(call) Service.createcall (); +Call.settargetendpointaddress (NewJava.net.URL (Keywordurl)); -Call.setoperationname (NewQName ("http://tempuri.org/", "interface Method name"));//Calling Interface +string ret = (string) Call.invoke (NewObject[] {s});//Passing Parameters ASYSTEM.OUT.PRINTLN ("returned parameter:" +ret); at returnret; - } -}
Java access to web Service via axis