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>