JAVA技巧:JNative調(diào)用動(dòng)態(tài)鏈接庫問題(SOS)

字號(hào):

動(dòng)態(tài)鏈接庫的方法如下:__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);
    我需要發(fā)送一條短信隨機(jī)碼出去,而我的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("轉(zhuǎn)換成功的字節(jié)數(shù)為:"+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();
    }
    }
    }
    系統(tǒng)總是提示:不能鏈接服務(wù)器,而且C方法中的編碼是ASCII編碼,該問題需要如何處理?請大家指教。
    具體系統(tǒng)提示如下:
    [SwtThinClient.c][76][2008-08-26 13:19:06.118000] -> 提示:rLachTran調(diào)用開始
    [SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 錯(cuò)誤:連接服務(wù)器[218.201.33.11]失敗,i_commtimeout_g[59990],WSAERRNO[10049]
    [SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 錯(cuò)誤:連接服務(wù)器[218.201.33.11]失敗,i_commtimeout_g[59990],WSAERRNO[10049]
    [SwtThinClient.c][138][2008-08-26 13:19:06.128000] -> 錯(cuò)誤:連接服務(wù)器[218.201.33.11]失敗,i_commtimeout_g[59990],WSAERRNO[10049]