动态链接库的方法如下:__declspec(dllexport) ret __stdcall rLachTran(const char *pc_trancode,
const char *pc_clicode,
const char *pc_orgcode,
const char *pc_ttycode,
const int i_brandid,
const char *pc_reqstamp,
const int i_reqseqno,
const char *pc_svrip,
const unsigned short us_svrport,
const char *pc_reqmsg,
char *pc_resmsg);
我需要发送一条短信随机码出去,而我的JNi类如下:package com.JNative;
package com.JNative;
import java.io.UnsupportedEncodingException;
import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;
import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;
public class Dll_Nat {
/**
* @param args
*/
public static void main(String[] args) throws NativeException ,IllegalAccessException{
// TODO Auto-generated method stub
Dll_Nat uc = new Dll_Nat();
String ret = null;
String result = uc.getNate("0023MBL_ZDtech_00001",
"0023MBL_SH_SVR00-01-02-03-04-05","ORGCODE",
"ttycode",0,"2008-08-25 15:51:55.025000", 1,
"218.201.33.11",50002,
"900001;00-01-02-03-04-05;1388*******~123435", ret);
System.out.println("转换成功的字节数为:"+result);
}
static JNative n = null;
static Pointer pointer;
public final int getNate(String trancode,
String clicode,
String orgcode,
String ttycode,
int brandid,
String reqstamp,
int reqseqno,
String svrip,
int svrport,
String reqmsg,
String resmsg) throws NativeException ,IllegalAccessException{
try{
n = new JNative("SwtThinClient.dll","rLachTran");
n.setRetVal(Type.INT);
int i =0 ;
n.setParameter(i++,trancode);
n.setParameter(i++,clicode);
n.setParameter(i++, orgcode);
n.setParameter(i++, ttycode);
n.setParameter(i++, brandid);
n.setParameter(i++, reqstamp);
n.setParameter(i++, reqseqno);
n.setParameter(i++, svrip);
n.setParameter(i++, svrport);
n.setParameter(i++, reqmsg);
n.setParameter(i++, resmsg);
n.invoke();
System.out.println(n.getRetVal());
return Integer.parseInt(n.getRetVal());
}catch(NativeException Ne){
System.out.println("NativeException: "+Ne.getMessage());
return -999;
}catch(IllegalAccessException Nen){
System.out.println("IllegalAccessException: "+Nen.getMessage());
return -888;
}
finally{
if (n != null)
n.dispose();
}
}
}
系统总是提示:不能链接服务器,而且C方法中的编码是ASCII编码,该问题需要如何处理?请大家指教。
具体系统提示如下:
[SwtThinClient.c][76][2008-08-26 13:19:06.118000] -> 提示:rLachTran调用开始
[SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 错误:连接服务器[218.201.33.11]失败,i_commtimeout_g[59990],WSAERRNO[10049]
[SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 错误:连接服务器[218.201.33.11]失败,i_commtimeout_g[59990],WSAERRNO[10049]
[SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 错误:连接服务器[218.201.33.11]失败,i_commtimeout_g[59990],WSAERRNO[10049]
3COME考试频道为您精心整理,希望对您有所帮助,更多信息在http://www.reader8.com/exam/