1. 程式人生 > >給java工程新增hession

給java工程新增hession

服務端:

1.增加pom依賴

2.web.xml新增

	<servlet>
	    <servlet-name>remoting</servlet-name>
	    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	    <load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
	    <servlet-name>remoting</servlet-name>
	    <url-pattern>/remoting/*</url-pattern>
	</servlet-mapping>

3.增加remoting-servlet.xml檔案

內容:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
	  http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
	  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
	   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
	default-lazy-init="true">
	<bean name="/MallGoodsService"
		class="org.springframework.remoting.caucho.HessianServiceExporter">
		<property name="service" ref="mallExtBiz" />
		<property name="serviceInterface"
			value="com.lvy.mall.intf.MallExtBiz" />
	</bean>
</beans>
4.增加xxx-ws-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  default-lazy-init="true">

  <bean id="mallGoodsService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
    <property name="serviceUrl" value="${empty.server}/remoting/MallGoodsService" />
    <property name="serviceInterface" value="com.lvy.mall.intf.MallExtBiz" />
    <property name="readTimeout" value="30000"/>
  </bean>

</beans>
5.把客戶端給客戶,客戶配置好empty.server就行了