加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

webService创建服务器与客户端

发布时间:2020-12-16 22:53:35 所属栏目:安全 来源:网络整理
导读:一。创建服务器 ? ?(1)建立接口与实现类 ? ?(2)引入XFire的jar包. ? Core comm-loggin jdom spring-1.2.6 wsdl4j xbean-2.2.0 xbean-spring xfire-all xfire-spring ? ?(3)在META-INF/xfire/services.xml中配置服务. beans xmlns="http://xfire.codehaus.org
一。创建服务器 ? ?(1)建立接口与实现类 ? ?(2)引入XFire的jar包. ? Core comm-loggin jdom spring-1.2.6 wsdl4j xbean-2.2.0 xbean-spring xfire-all xfire-spring ? ?(3)在META-INF/xfire/services.xml中配置服务. <beans xmlns="http://xfire.codehaus.org/config/1.0"> <service> <name>服务名</name> <namespace>命名空间</namespace> ? <serviceClass> 接口全路径 </serviceClass> <implementationClass> 实现类全路径 </implementationClass> </service> </beans> 例如: <beans xmlns="http://xfire.codehaus.org/config/1.0"> <service> <name>allresfood</name> <namespace>www.qing.com.cn/res/allresfood</namespace> ? <serviceClass> com.qing.web.service.biz.ResfoodWebServiceBiz </serviceClass> <implementationClass> com.qing.biz.impl.ResfoodWebServiceBizImpl </implementationClass> </service> </beans> (4)在web中加xfile的配置文件 <!--xfile基于servlet--> <servlet> <servlet-name>XFireServlet</servlet-name> <servlet-class> org.codehaus.xfire.transport.http.XFireConfigurableServlet </servlet-class> </servlet> <!--以两种形式执行xfire--> <servlet-mapping> <servlet-name>XFireServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>XFireServlet</servlet-name> <url-pattern>/servlet/XFireServlet/*</url-pattern> </servlet-mapping> ? ?(5)访问测试这个服务发布是否成功: ?http://localhost:8080/项目名/services ? ? ? ? 注意wsdl最后的地址: <wsdlsoap:address location="http://localhost:8080/项目名/services/服务名?wsdl"/> 二。创建客户端 ? ? ?(1)导出服务器端的接口jar文件. 右击项目名-export-java-JAR file? ? ? ?(2)引入XFire的jar包. ? xfire-core commons-httpclient commons-loggin jdom-1.0 wsdl4j xfire-all xfire-core 记得引入导出服务器端的接口的jar文件 ? ? ?(3)创建servlet调用服务. ? ? ? ? ? ? ?Service servicemodel=new ObjectServiceFactory().create(接口名.class); ? ? ? ? XFire xfire=XFireFactory.newInstance().getXFire(); ? ? ? ? XFireProxyFactory factory=new XFireProxyFactory(xfire); ? ? ? ?? ? ? ? ? String url="服务地址"; ? ? ? ?? ? ? ? ? 接口名 i=null; ? ? ? ?? ? ? ? ? i=(接口名)factory.create(servicemodel,?url); ? ? ? ?? ? ? ? ? //调用方法

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读