1.下载apache公司的axis包.将lib拷贝到工程中
2.将axis包中的web.xml相关配置拷贝到自己的web.xml中
3.在WEB-INF下建立server-config.wsdd
如:
xmlns:handler="http://xml.apache.org/axis/wsdd/providers/handler"
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="defaultClientConfig" xsi:type="deployment">
type="java:org.apache.axis.handlers.JWSHandler" regenerateElement="false">
type="java:org.apache.axis.handlers.JWSHandler" regenerateElement="false">
type="java:org.apache.axis.handlers.http.URLMapper" regenerateElement="false"/>
type="java:org.apache.axis.transport.local.LocalResponder" regenerateElement="false"/>
type="java:org.apache.axis.handlers.SimpleAuthenticationHandler" regenerateElement="false"/>
value="org.apache.axis.transport.http.QSListHandler" regenerateElement="false"/>
value="org.apache.axis.transport.http.QSMethodHandler" regenerateElement="false"/>
value="org.apache.axis.transport.http.QSWSDLHandler" regenerateElement="false"/>
type="java:org.apache.axis.handlers.http.HTTPAuthHandler" regenerateElement="false"/>
provider="java:RPC" style="rpc" use="encoded" validate="true">
value="com.xkk.webservice.service.example.impl.SayHello" regenerateElement="false"/>
http://impl.example.service.webservice.xkk.com
保存wsdd
然后部署到服务器中.
4.打开以下网址
http://localhost:8080/你的工程名/servlet/AxisServlet
从以下网址中获得 SayHello.wsdl文件
http://localhost:8080/testSimpleAxisService/services/SayHello?wsdl
5.新建客户端工程
将SayHello.wsdl放到工程根目录下.
执行控制台命令.生成客户端调用web程序
如:
set Axis_Lib=H:/place/Webroot/WEB-INF/lib
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
set Output_Path=H:/place/testAxisCustomer/src
set Package=com.test
%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package% server-config.wsdl pause
也可以用eclispe配置参数执行控制台程序
将其放入指定包下
6.执行web客户端调用程序 import java.rmi.remoteexception; import javax.xml.rpc.ServiceException; import com.xxx.webservice.guest.sayHello.SayHelloServiceLocator; import com.xxx.webservice.guest.sayHello.SayHelloSoapBindingStub; public class TestMain { private static SayHelloSoapBindingStub binding; static { SayHelloServiceLocator bssl=new SayHelloServiceLocator(); //web服务的服务端的地址 bssl.setSayHelloEndpointAddress("http://localhost:8080/你的web工程服务端/services/SayHello"); try { binding = (SayHelloSoapBindingStub)bssl.getSayHello(); } catch (ServiceException e) { // Todo Auto-generated catch block e.printstacktrace(); } binding.setTimeout(6000); } public String sayHello() throws remoteexception { return binding.toSayHello("小王21212"); } public static void main(String[] args) { TestMain testMain = new TestMain(); try { System.out.println(testMain.sayHello()); } catch (remoteexception e) { // Todo Auto-generated catch block e.printstacktrace(); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。