webservice接口怎么写( 二 )


commons-logging-1.0.4.jar
jaxrpc.jar
log4j-1.2.8.jar
mailapi.jar
saaj.jar
wsdl4j-1.5.1.jar
xmlsec-1.3.0.jar
5、测试发布的WEB应用
启动Tomcat服务,打开IE浏览器,访问mons-discovery-0.2.jar
commons-logging-1.0.4.jar
jaxrpc.jar
log4j-1.2.8.jar
mailapi.jar
saaj.jar
wsdl4j-1.5.1.jar
xmlsec-1.3.0.jar
5、测试发布的WEB应用
启动Tomcat服务,打开IE浏览器,访问.*;import java.util.vector; public class caservice{ public static string getservice(string user) { url url = null; try { url=new url("http://192.168.0.100:8080/ca3/services/casynrochnized"); } catch (malformedurlexception mue) { return mue.getmessage(); } // this is the main soap object call soapcall = new call(); // use soap encoding soapcall.setencodingstyleuri(constants.ns_uri_soap_enc); // this is the remote object we're asking for the price soapcall.settargetobjecturi("urn:xmethods-casynrochnized"); // this is the name of the method on the above object soapcall.setmethodname("getuser"); // we need to send the isbn number as an input parameter to the method vector soapparams = new vector(); // name, type, value, encoding style parameter isbnparam = new parameter("username", string.class, user, null); soapparams.addelement(isbnparam); soapcall.setparams(soapparams); try { // invoke the remote method on the object response soapresponse = soapcall.invoke(url,""); // check to see if there is an error, return "n/a" if (soapresponse.generatedfault()) { fault fault = soapresponse.getfault(); string f = fault.getfaultstring(); return f; } else { // read result parameter soapresult = soapresponse.getreturnvalue (); // get a string from the result return soapresult.getvalue().tostring(); } } catch (soapexception se) { return se.getmessage(); } }}3,使用wsdl2java把wsdl文件转成本地类,然后像本地类一样使用,即可 。