求助OA系统实现共享人员表
同时启动2个一样OA系统(这两个系统数据库和代码必须独立)怎样要实现的是这2个系统共享人员表,(即,第一个OA系统新建了人员在第二个OA系统中可以突显出来
[最优解释]
用webservice实现
[其他解释]
不会啊,可以给我一个例子吗
[其他解释]
1、有个接口
2、有个实现类
3、配置文件中配置
接口代码
import javax.jws.WebService;
@WebService
public interface ServerWebService {
public String sayHello(String userName);
}
实现类代码
import javax.jws.WebService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.gacinfo.server.service.ServerWebService;
@Service
@Transactional
@WebService(endpointInterface = "cn.aa.bb.ServerWebService ")//参数是Service的路径
public class ServerWebServiceImpl implements ServerWebService {
@Override
public String sayHello(String userName) {
return "hello," + userName;
}
}
[其他解释]
3、配置文件applicationContext-webservice.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="aegisBean"
class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
<bean id="jaxws-and-aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="dataBinding" ref="aegisBean" />
</bean>
<!-- ServerWebService接口-->
<jaxws:endpoint id="uploadws" implementor="#serverWebServiceImpl" address="/ServerWebService">
<jaxws:serviceFactory>
<ref bean='jaxws-and-aegis-service-factory' />
</jaxws:serviceFactory>
</jaxws:endpoint>
</beans>
[其他解释]
1、2、3是服务器端的代码和配置
以下是是客户端的
4、把服务器端的接口拷贝到客户端--接口的路径可以改变。
5、调用和测试代码
6、客户端配置文件
5、调用和测试代码
import org.springframework.context.support.ClassPathXmlApplicationContext;
import cn.aa.bb.ServerWebService;
public final class CommonWebService {
private static ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath*:spring/applicationContext*" });
public CommonWebService() {
}
public static String sayHello(String userName) {
ServerWebService client = (ServerWebService) context.getBean("client");
String result = null;
try {
result = client.sayHello(userName);
} catch (Exception e) {
e.printStackTrace();
}
if (!("".equals(result)