`
mizhao1984
  • 浏览: 88662 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

web端应用OSGi中cxf发布的webservice接口

阅读更多

1.引用所需jar包:

cxf-2.2.7.jar
spring-2.0.6.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.5.jar

 

2。编写spring配置文件(applicationContext.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:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.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="testLoginService" class="com.oohla.client.test.TestLoginService" init-method="testMethod">
        <property name="loginService" ref="loginService"></property>
    </bean>
    <!-- 创建登陆接口 -->
    <bean id="loginService" class="com.oohla.sso.user.LoginService"
          factory-bean="proxyLoginService" 
          factory-method="create"/>
    <!-- 登陆接口工厂 -->
    <bean id="proxyLoginService" class="org.apache.cxf.frontend.ClientProxyFactoryBean">
        <property name="serviceClass" value="com.oohla.sso.user.LoginService"/>
        <property name="address" value="http://uni-plat.oohla.com:19000/api/v1/sso/user/LoginService"/>
    </bean>
</beans>

 

3。引入接口所需java类:

4。编写测试方法:

public class TestLoginService {
 
 private LoginService loginService;

 public void setLoginService(LoginService loginService) {
  this.loginService = loginService;
 }
 
 public void testMethod(){
  try {
   AppLoginReturnInfo returnInfo = loginService.appLogin("mizhao","111111","http://www.baidu.com");
   System.out.println(returnInfo.getRedirectUrl());
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }

}

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics