webservice简单入门总结

本文介绍了Webservice的基础知识,包括其作用——解决异构系统间的通信问题。通过Myeclipse创建了一个基于XFire的Web工程,详细讲解了从添加依赖、配置接口和服务到发布验证的步骤。此外,还展示了如何创建Java客户端并调用Webservice方法,强调了客户端必须通过实例化来调用服务器的方法。最后提到了Webservice客户端不仅能调用服务,还可以调用序列化的实体对象。
摘要由CSDN通过智能技术生成

webservice简单运行原理:


webservice的作用:解决异构软件系统之间的通信。

基于Myeclipse开发webservice基于xfire的简单实现

1)创建一个web工程

    1:添加xfire的jar包


这个过程做了三个事情:

  1:添加进来了两个jar包


  2:创建了一个webservice文件夹


  3:在web.xml中添加了一个servlet



以上就是在服务器端做的三个事情

  我们在服务器端要用webservice 要面向接口编程

  所以我创建了一个接口和它的实现类


然后在services.xml配置我们的接口和实现类

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<!-- 名称 -->
<name>hello</name>
<!-- 接口的路径 -->
<serviceClass>cn.com.demo.hello.IHello</serviceClass>
<!-- 实现类的路径 -->
<implementationClass>cn.com.demo.hello.impl.HelloImpl</implementationClass>
<!-- 服务的生命周期 -->
<scope>application</scope>
</service>
</beans>

做完上述步骤之后就验证webservice是否发布成功

1)将写好的web工程加入到tomcat容器中

2)启动tomcat容器

3)通过浏览器访问web.xml中配置的servlet-ur

l

然后点击wsdl就会看到

<wsdl:definitions xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://hello.demo.com.cn" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" targetNamespace="http://hello.demo.com.cn">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://hello.demo.com.cn">
<xsd:element name="hello">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值