本地接口:

@Override
    public Response formsubGet(String accountContent, char inputContent,
            String opEntrustWay, String opStation, String sysName,String sdkType,String comsFunc,String password,
            char passwordType) {
        return this.formsubPost(accountContent, inputContent, opEntrustWay, opStation,sysName,sdkType,comsFunc, password, passwordType);
    }

@Override
    public Response formsubPost(String accountContent, char inputContent,
            String opEntrustWay, String opStation, String sysName, String sdkType,String comsFunc,String password,
            char passwordType) {
        Response loginAuth = null;

本地实现类:
public class AuthLoginServerImpl implements AuthLoginServer
{
    private static final Logger logger = Logger.getLogger(AuthLoginServerImpl.class);
    
    private AuthLoginClient authLoginClient;

@Override
    public Response formsubGet(String accountContent, char inputContent,
            String opEntrustWay, String opStation, String sysName,String sdkType,String comsFunc,String password,
            char passwordType) {
        return this.formsubPost(accountContent, inputContent, opEntrustWay, opStation,sysName,sdkType,comsFunc, password, passwordType);
    }

@Override
    public Response formsubPost(String accountContent, char inputContent,
            String opEntrustWay, String opStation, String sysName, String sdkType,String comsFunc,String password,
            char passwordType) {
        Response loginAuth = null;
        try {
            loginAuth = authLoginClient.login(accountContent, inputContent, opEntrustWay, opStation, sysName,sdkType,comsFunc,password, passwordType);
        } catch (Exception e) {
             logger.info("调用login认证异常:"+ e.getMessage());
             loginAuth.setRetCode("-1");
             loginAuth.setRetMessage("login方法认证失败!");
        }
        return loginAuth;
    }

public void setAuthLoginClient(AuthLoginClient authLoginClient) {
        this.authLoginClient = authLoginClient;
    }
    
}

客户端类:
@Path("/mds")
@Produces("application/json;charset=UTF-8")
public interface AuthLoginClient
{
    @POST
    @Consumes({ MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8",
            MediaType.MULTIPART_FORM_DATA + ";charset=UTF-8" })
    @Path("/formsub.json")
    /*
     * F_OP_SRC首字母大写,无法将所有参数进行封装处理,因为对象属性是通过geter获取,结果得到的属性名为f_OP_SRC
     */
    public Response login(@FormParam("AccountContent") String accountContent, @FormParam("InputContent") char inputContent,
            @FormParam("OpEntrustWay") String opEntrustWay, @FormParam("OpStation") String opStation,
            @FormParam("sys_name") String sysName, @FormParam("sdk_type") String sdkType,
            @FormParam("coms_func") String comsFunc,@FormParam("Password") String password,
            @FormParam("PasswordType") char passwordType);
}

xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd">
    
    <!-- 资源文件配置 -->
    <bean id="propertiesBean"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <!-- 不需要加载log4j.properties -->
                <value>classpath:global.properties</value>
            </list>
        </property>
        <property name="fileEncoding">
            <value>UTF-8</value>
        </property>
    </bean>

<jaxrs:client id="authComClient"
        serviceClass="com.citics.esb.rest.client.AuthComClient"
        address="${url}">
        <jaxrs:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxrs:features>
        <jaxrs:providers>
            <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
                <property name="dropRootElement" value="true" /><!--默认false-->
                <property name="supportUnwrapped" value="true" /><!--默认false-->
            </bean>
        </jaxrs:providers>
    </jaxrs:client>
    
    
    <jaxrs:server id="cutIdtiByPassServer" address="/identifications/jsonapi">
        <jaxrs:serviceBeans>
            <bean class="com.citics.esb.rest.server.impl.AuthComServerImpl">
                <property name="authComClient" ref="authComClient"></property>
            </bean>
        </jaxrs:serviceBeans>
        <jaxrs:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxrs:features>
        <jaxrs:providers>
            <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
                <property name="ignoreNamespaces" value="true" />
                <property name="dropRootElement" value="false" />
            </bean>
        </jaxrs:providers>
    </jaxrs:server>

<jaxrs:client id="authLoginClient"
        serviceClass="com.citics.esb.rest.client.AuthLoginClient"
        address="${loginUrl}">
        <jaxrs:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxrs:features>
        <jaxrs:providers>
            <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
                <property name="dropRootElement" value="true" /><!--默认false-->
                <property name="supportUnwrapped" value="true" /><!--默认false-->
            </bean>
        </jaxrs:providers>
    </jaxrs:client>
    
    <jaxrs:server id="formsubServer" address="/mds">
        <jaxrs:serviceBeans>
            <bean class="com.citics.esb.rest.server.impl.AuthLoginServerImpl">
                <property name="authLoginClient" ref="authLoginClient"></property>
            </bean>
        </jaxrs:serviceBeans>
        <jaxrs:features>
            <bean class="org.apache.cxf.feature.LoggingFeature" />
        </jaxrs:features>
        <jaxrs:providers>
            <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
                <property name="ignoreNamespaces" value="true" />
                <property name="dropRootElement" value="false" />
            </bean>
        </jaxrs:providers>
    </jaxrs:server>
    
</beans>
返回的Response类:
@XmlRootElement(name = "Response")
@XmlAccessorType(XmlAccessType.NONE)
public class Response
{
    @XmlElement(name = "RET_CODE")
    private String retCode;
    
    @XmlElement(name = "RET_MESSAGE")
    private String retMessage;
    
    @XmlElement(name = "RESULTSET")
    private ResultSet resultSet;
    
    
    public String getRetCode()
    {
        return retCode;
    }
    
    
    public void setRetCode(String retCode)
    {
        this.retCode = retCode;
    }
    
    
    public String getRetMessage()
    {
        return retMessage;
    }
    
    
    public void setRetMessage(String retMessage)
    {
        this.retMessage = retMessage;
    }
    
    
    public ResultSet getResultSet()
    {
        return resultSet;
    }
    
    
    public void setResultSet(ResultSet resultSet)
    {
        this.resultSet = resultSet;
    }
    
}

@XmlAccessorType(XmlAccessType.FIELD)
public class ResultSet
{
    @XmlElement(name = "Account")
    private String account;
    
    @XmlElement(name = "BranchNo ")
    private String branchNo ;
    
    @XmlElement(name = "ClientID ")
    private String clientID ;
    
    @XmlElement(name = "SysnodeId")
    private int sysnodeId;
    
    public String getAccount() {
        return account;
    }
    public void setAccount(String account) {
        this.account = account;
    }
    public String getBranchNo() {
        return branchNo;
    }
    public void setBranchNo(String branchNo) {
        this.branchNo = branchNo;
    }
    public String getClientID() {
        return clientID;
    }
    public void setClientID(String clientID) {
        this.clientID = clientID;
    }
    public int getSysnodeId() {
        return sysnodeId;
    }
    public void setSysnodeId(int sysnodeId) {
        this.sysnodeId = sysnodeId;
    }
}

jax-rs的客户端完整实例的更多相关文章

  1. JAX-RS 2.0 REST客户端编程实例

    JAX-RS 2.0 REST客户端编程实例 2014/01/28 | 分类: 基础技术, 教程 | 0 条评论 | 标签: JAX-RS, RESTFUL 分享到:3 本文由 ImportNew - ...

  2. python测试mysql写入性能完整实例

    这篇文章主要介绍了python测试mysql写入性能完整实例,具有一定借鉴价值,需要的朋友可以参考下 本文主要研究的是python测试mysql写入性能,分享了一则完整代码,具体介绍如下. 测试环境: ...

  3. Netty实现SSL双向验证完整实例

    Netty实现SSL双向验证完整实例 博客分类: netty nettyssl自签证书  一.证书准备 要使用ssl双向验证,就必须先要生成服务端和客户端的证书,并相互添加信任,具体流程如下(本人调试 ...

  4. 【转】Android Https服务器端和客户端简单实例

    转载地址:http://blog.csdn.net/gf771115/article/details/7827233 AndroidHttps服务器端和客户端简单实例 工具介绍 Eclipse3.7 ...

  5. C# 调用第三方DLL完整实例

    C# 调用第三方DLL完整实例 分类: C/C++ 以下代码为本人在实际项目中编写的调用第三方DLL接口程序的完整代码. public class ExecuteDLL : Form { ...//忽 ...

  6. (转)多个mapreduce工作相互依赖处理方法完整实例(JobControl)

    多个mapreduce工作相互依赖处理方法完整实例(JobControl) 原文地址:http://mntms.iteye.com/blog/2096456?utm_source=tuicool&am ...

  7. 利用Div+CSS(嵌套+盒模型)布局页面完整实例流程

    Div+CSS(嵌套+盒模型)布局页面完整实例流程: <!DOCTYPE html><html> <head>  <meta charset="UT ...

  8. 微信小程序发送短信验证码完整实例

    微信小程序注册完整实例,发送短信验证码,带60秒倒计时功能,无需服务器端.效果图: 代码: index.wxml <!--index.wxml--> <view class=&quo ...

  9. Hadoop HDFS的shell(命令行客户端)操作实例

    HDFS的shell(命令行客户端)操作实例 3.2 常用命令参数介绍 -help 功能:输出这个命令参数手册 -ls                  功能:显示目录信息 示例: hadoop fs ...

随机推荐

  1. UVa 11426

    首先我们了解一下欧拉函数phi[x],phi[x]表示的是不超过x且和x互素的整数个数 phi[x]=n*(1-1/p1)*(1-1/p2)....(1-1/pn); 计算欧拉函数的代码为 int e ...

  2. nmon安装(转)

    安装说明安装环境:CentOS-6.3安装方式:源码编译安装软件:nmon_linux_14i.tar.gz下载地址:nmon:http://nmon.sourceforge.net/pm ... n ...

  3. 常见编程语言对REPL支持情况小结[转]

    文章转载自http://www.nowamagic.net/librarys/veda/detail/2462 最近跟一个朋友聊起编程语言的一些特性,他有个言论让我略有所思:“不能REPL的都是渣”. ...

  4. bug记录_document.defaultview.getcomputedstyle()

    页面中使用document.defaultview.getcomputedstyle()在火狐下取不到值. 原本方法现在$(document).ready()中,换到window.onload里就可以 ...

  5. Python之列表&元组&字典

    今天学习了Python的基本数据类型,做以下笔记,以备查用. 一.列表 列表的常用方法: 1.append()方法 def append(self, p_object): # real signatu ...

  6. html5 让IE6,7支持HTML5语义化标签的文件

    https://github.com/aFarkas/html5shiv/blob/master/src/html5shiv.js   只要应用这个js就行了

  7. Openjudge-计算概论(A)-第二个重复出现的数

    描述: 给定一个正整数数组(元素的值都大于零),输出数组中第二个重复出现的正整数,如果没有,则输出字符串"NOT EXIST". 输入第一行为整数m,表示有m组数据.其后每组数据分 ...

  8. mysql数据库的优化技术

    表的设计合理化(遵从3NF)<3范式> 1NF:表的列具有原子性,不可再分解(列的信息不能分解,只要是关系型的数据库就自动满足1NF) 2NF:表中的记录是唯一的,就满足2NF(通常我们设 ...

  9. window.showModalDialog()的简单用法

    //创建一个显示html内容的模态对话框: vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]) //创建一个 ...

  10. k近邻模型

    k近邻模型主要包含三个基本要素:距离度量.k值的选择.分类决策规则 模型: k近邻法中,当训练集.距离度量.k值及分类决策规则确定后,对于一个新的输入实例,它所属的类唯一确定,这相当于根据上述要素将特 ...