Local interface:
@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;
Local implementation class:
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 ("Call Login Authentication exception:" + E.getmessage ());
Loginauth.setretcode ("-1");
Loginauth.setretmessage ("Login Method authentication failed! ");
}
return Loginauth;
}
public void Setauthloginclient (Authloginclient authloginclient) {
This.authloginclient = authloginclient;
}
}
Client class:
@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 uppercase, all parameters cannot be encapsulated because object properties are obtained by geter and the resulting property is named 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 ">
<!--resource file configuration--
<bean id= "Propertiesbean"
class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name= "Locations" >
<list>
<!--do not need to load 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"/><!--default false-->
<property name= "supportunwrapped" value= "true"/><!--default 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"/><!--default false-->
<property name= "supportunwrapped" value= "true"/><!--default 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>
Returns the response class:
@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 client-side Full instance