java通过soap进行socket长连接
在开发一套系统的java API的时候
要用socket的长连接通过wsdl和认证服务器进行交互
用axis2反转成java文件
服务器支持长连接
写一个java类调用wsdl中的接口
如下代码:
public class Ikey{
//wsdl翻转后的一个接口名字
private static UserService service;
public static int ikeyAuth(String strNum, String strPwd)
throws java.lang.Exception {
try{
TtokenAuthReq Req = (TtokenAuthReq) getTestObject(TtokenAuthReq.class);
// 串号
Req.setMsAuthName(strNum);
// 密码
Req.setMsAuthPasswd(strPwd);
// 空字段
Req.setMsReserve1("");
// 空字段
Req.setMsReserve2("");
Req.setUi32LocalSid(0);
Req.setUi32ResId(0);
UserAuthServiceStub.TtokenAuthRes Res = service.tokenAuth(Req);
System.out.println("*******************************");
System.out.println("此为 认证 返回结果");
System.out.println(Res.getI32Ret());
System.out.println(Res.getSzRet());
System.out.println("*******************************");
}catch(Exception e){
System.out.println(e.getMessage());
}
return 0;
}
public static void setendpoint(String endpoint) throws java.lang.Exception {
Ikey ikey = new Ikey();
ikey.logger.setLevel(Level.WARN);
ikey.allowAccess = false;
service = new UserService (endpoint);
}
public static org.apache.axis2.databinding.ADBBean getTestObject(
java.lang.Class type) throws java.lang.Exception {
return (org.apache.axis2.databinding.ADBBean) type.newInstance();
}
}
在main()中
{
Ikey ikey = new Ikey();
ikey.setendpoint("http://认证服务器的ip:端口号");
ikey.ikeyAuth("串号","密码");
}
是可以验证成功的
如何把上面的代码修改成支持长连接和短连接呢?
希望各位大侠帮小弟一把
小弟感激不尽