Use xfire to done your web services in java
来源:互联网 发布:如何缓解焦虑情绪 知乎 编辑:程序博客网 时间:2024/05/17 21:47
Use xfire to done your web services
Service:
First config, xfire-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- URLs to WebService mapping. Requests are forwarded through Springs' DispatcherServlet -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/BankInterface">
<ref bean="bank[j1] "/>
</entry>
//映射到URL的KEY
</map>
</property>
</bean>
<!-- Declare a parent bean with all properties common to both services -->
<bean id="bank" class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory">
<ref bean="xfire.serviceFactory"/>
</property>
<property name="xfire">
<ref bean="xfire"/>
</property>
<property name="serviceBean">
<ref bean="bankInterfaceService[j2] "/>
</property>
<property name="serviceClass">
<value>com.fch.fps.bs.bankinterface.BankInterface[j3] </value>
</property>
//映射SERVICE类
</bean>
</beans>
THEN,WEB.XML:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/com/fch/fps/bs/spring/applicationContext.xml
classpath:org/codehaus/xfire/spring/xfire.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>xfire</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xfire</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
这样启动服务,写 http://localhost:7001/配置工程名/ws/BankInterface 就可以看到,加上 ?WSDL 就可解析为XML
假如SERVICE有1方法“public void register()”,需要被CLIENT调用.
2. CLIENT
Just need few word like this:
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
Service ser=new ObjectServiceFactory().
Create(BankInterfaceService.class);
//xfire-servlet.xml中的接口 serviceBean
BankInterfaceService bankser=( BankInterfaceService)
new xfireproxyFactory.create(ser,url);
//this url must be http://localhost:7001/配置工程名/ws/BankInterface
Ok,now “bankser” can do whatever u want
Bankser.register();
[j1]The same as the “<bean id=”bank”. . . . . . . “
[j2]Spring 配置文件中注入的service
[j3]Service的接口
- Use xfire to done your web services in java
- How to use AspnetUpload™ in your web application
- How to Reference and Use JSTL in your Web Application
- Recommended Doctype Declarations to use in your Web document
- how to use MongoDB Java driver in your env
- XFire发布Web Services
- How to use Log4net in your project
- Use Weka in your Java code
- Use WEKA in your Java code
- HOW TO IMPLEMENT WEB SERVICES IN INDY
- How to use the Human WorkFlow Web Services
- 10 ways to use keywords in your communications module
- [Bootstrap] How to use bootstrap in your application?
- UE4 Material - How To Use Fresnel in your Materials
- How to use cocoa pod in your iOS project
- How to use user’s location in your app?
- How to use another indicator in your code?
- Use YSlow to know why your web Slow
- Tapestry+spring+hibernate基本架构
- w3c dom 编程入门书籍推荐下载
- SQL--JOIN之完全用法
- Asp.net(c#)实现多线程断点续传
- Scott Mitchell 的ASP.NET 2.0数据教程之二十六::排序自定义分页数据
- Use xfire to done your web services in java
- 微软,您的.net为中国程序员带来了什么?
- asp.net中获取数据连接的统计信息
- [吓着我可不管!]fw:标题:堪称世界上最丑的狗死了 连夺三冠吓退评委
- flash类单态模式的写法与疑问
- Java EE 5.0能取代Struts,Spring和Hibernate吗?
- 关于光盘统计发放方法思索
- Tapestry framework component -------propertyselection
- ASP.Net中如何使用ClientID