这是我上边提到的那段代码,原帖地址在楼上,大家可以去看ASP.NET 代码 using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.Remoting; using System.Runtime.Serialization; using System.IO; namespace wmweb { /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Label messages2; protected System.Web.UI.WebControls.Label a1; protected System.Web.UI.WebControls.Label messages; public System.IO.BufferedStream MyBuff; [ StructLayout( LayoutKind.Sequential )] public class MobileData { public string RspBuf; public char[] SPId; /*账务通信交易回应类型:100-回应手机话费查询*/ public char[] SPPwd; /*回应请求的日期时间,格式为"YYYY-MM-DD HH:MI:SS"*/ public char[] Mobile; /*用户的手机号玛*/
} public class LibAcntSPClt {
[ DllImport( "AcntSPClt.dll" )]
public static extern bool MBSP_BindAcntSPSvr(string m_Addr, int m_Port); //public static extern int SMSend( char[] SPId, char[] Mobile,char[] Message, char[] FeeType, char[] FeeCode, char[] BusiTypeCode, char[] MsgFormat); [ DllImport( "AcntSPClt.dll" )] public static extern int MBSP_FeeQry(out string RspBuf, ref string SPId, ref string SPPwd, ref string Mobile); }
public void Page_Load(object sender, System.EventArgs e) { //MobileData st = new SystemTime(); string RspBuf="";; //MyBuff = new BufferedStream(RspBuf, 1024); string m_ParamV=""; string Mobile="13883390686"; string SPId="00005"; string SPPwd="123456"; string m_Addr="218.201.39.11"; int m_Port=10300; //LibAcntSPClt.MBSP_Get_Version(ref m_ParamV); //a1.Text=m_ParamV.ToString();
http://www.chinaaspx.com/Comm/Dotnetbbs/Showtopic.aspx?Forum_ID=5&id=29724&PPage=622&Page=1
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Runtime.Serialization;
using System.IO;
namespace wmweb
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label messages2;
protected System.Web.UI.WebControls.Label a1;
protected System.Web.UI.WebControls.Label messages;
public System.IO.BufferedStream MyBuff; [ StructLayout( LayoutKind.Sequential )]
public class MobileData
{
public string RspBuf;
public char[] SPId; /*账务通信交易回应类型:100-回应手机话费查询*/
public char[] SPPwd; /*回应请求的日期时间,格式为"YYYY-MM-DD HH:MI:SS"*/
public char[] Mobile; /*用户的手机号玛*/
} public class LibAcntSPClt
{
[ DllImport( "AcntSPClt.dll" )]
public static extern bool MBSP_BindAcntSPSvr(string m_Addr, int m_Port); //public static extern int SMSend( char[] SPId, char[] Mobile,char[] Message, char[] FeeType, char[] FeeCode, char[] BusiTypeCode, char[] MsgFormat);
[ DllImport( "AcntSPClt.dll" )]
public static extern int MBSP_FeeQry(out string RspBuf, ref string SPId, ref string SPPwd, ref string Mobile);
}
public void Page_Load(object sender, System.EventArgs e)
{ //MobileData st = new SystemTime();
string RspBuf="";;
//MyBuff = new BufferedStream(RspBuf, 1024);
string m_ParamV="";
string Mobile="13883390686";
string SPId="00005";
string SPPwd="123456";
string m_Addr="218.201.39.11";
int m_Port=10300;
//LibAcntSPClt.MBSP_Get_Version(ref m_ParamV);
//a1.Text=m_ParamV.ToString();
messages.Text=LibAcntSPClt.MBSP_BindAcntSPSvr(m_Addr, m_Port).ToString();
int a=LibAcntSPClt.MBSP_FeeQry(out RspBuf, ref SPId, ref SPPwd, ref Mobile);
messages2.Text=RspBuf.GetType().ToString();;
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
// from a DLL simpler. All files within this DLL are compiled with the ACNTSPCLT_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// ACNTSPCLT_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef ACNTSPCLT_EXPORTS
#define ACNTSPCLT_API extern "C" __declspec(dllexport)
#else
#define ACNTSPCLT_API extern "C" __declspec(dllimport)
#endif //////////////////////////////////////////////////////////////////////
// 参数说明:RspBuf为预先准备好的1024字节大小的缓冲区首地址 //
////////////////////////////////////////////////////////////////////// //查询账务通信SP客户端DLL的版本信息
ACNTSPCLT_API void MBSP_Get_Version(char * ParamV); //绑定账务通信SP接入服务器
ACNTSPCLT_API bool MBSP_BindAcntSPSvr(const char * SvrAddr, //服务器地址
unsigned int SvrPort);//服务器端口 //话费查询
//返回值 正数:通信成功,-1:参数错误,-2:连接错误,-3:收发错误,-4:IP错误,-5:无效请求
ACNTSPCLT_API int MBSP_FeeQry(char * RspBuf, //通信缓冲区
const char * SPId, //SP代号
const char * SPPwd, //SP密码
const char * Mobile); //用户手机号码
//冲正
//返回值 正数:通信成功,-1:参数错误,-2:连接错误,-3:收发错误,-4:IP错误,-5:无效请求
ACNTSPCLT_API int MBSP_Cancel(char * RspBuf, //通信缓冲区
const char * SPId, //SP代号
const char * SPPwd, //SP密码
const char * Mobile, //用户手机号码
float Amount, //交易金额
const char * BusiType, //业务代码
const char * SPJnl, //SP交易流水号
const char * RefJnl, //冲正相关流水号
int RefJnlType=0); //冲正相关流水号类型,0-远端流水,1-本地流水 //话费充值
//返回值 正数:通信成功,-1:参数错误,-2:连接错误,-3:收发错误,-4:IP错误,-5:无效请求
ACNTSPCLT_API int MBSP_FeeChg(char * RspBuf, //通信缓冲区
const char * SPId, //SP代号
const char * SPPwd, //SP密码
const char * Mobile, //用户手机号码
float Amount, //交易金额
const char * BusiType, //业务代码
const char * SPJnl); //SP交易流水号
********************************************************
//AcntSPDef.h
//
//////////////////////////////////////////////////////////////////////
// 账务通信SP接口Struct Define
// 结构体的每一个成员变量字符数组的最后1位为字符串结束符'\0'(ACII码的0)
// 结构体的成员变量内容长度不足时左对其右补'\0'(ACII码的0)
//////////////////////////////////////////////////////////////////////
//
//--话费查询请求
struct STMB_FeeQryRsp
{
char TransType[4]; /*账务通信交易回应类型:100-回应手机话费查询*/
char RspTime[20]; /*回应请求的日期时间,格式为"YYYY-MM-DD HH:MI:SS"*/
char SPId[6]; /*SP的ID号*/
char MobileNo[12]; /*用户的手机号玛*/
char RespCode[3]; /*处理结果代码:00-成功,其他-失败*/
char RespMsg[740]; /*描述处理结果的文本信息,查询成功时为计费中心传回的话费结构*/
}; //--冲正交易
struct STMB_CancelRsp
{
char TransType[4]; /*账务通信交易回应类型:103-回应冲正交易*/
char RspTime[20]; /*回应请求的日期时间,格式为"YYYY-MM-DD HH:MI:SS"*/
char SPId[6]; /*SP的ID号*/
char MobileNo[12]; /*用户的手机号玛*/
char JournalNo[21]; /*账务通信服务器的交易流水号*/
char SPJnl[21]; /*SP先前提交的交易流水号*/
char RefJnl[21]; /*冲正的相关流水号*/
char RespCode[3]; /*处理结果代码:00-成功,其他-失败*/
char RespMsg[101]; /*描述处理结果的文本信息*/
}; //--手机话费充值
struct STMB_FeeChgRsp
{
char TransType[4]; /*账务通信交易回应类型:104-回应手机话费费充值*/
char RspTime[20]; /*回应请求的日期时间,格式为"YYYY-MM-DD HH:MI:SS"*/
char SPId[6]; /*SP的ID号*/
char MobileNo[12]; /*用户的手机号玛*/
char JournalNo[21]; /*账务通信服务器的交易流水号*/
char SPJnl[21]; /*SP先前提交的交易流水号*/
char RespCode[3]; /*处理结果代码:00-成功,其他-失败*/
char RespMsg[101]; /*描述处理结果的文本信息*/
};
****************************************************
一、这只是一段代码,能用否谁也不知道。我也可以写个程序说能连移动和联通。
二、这段代码就算给全了也不见得就有用。这段只是连接用的函数,在其他的程序里面来调用这些函数。首先需要使用
//查询账务通信SP客户端DLL的版本信息
ACNTSPCLT_API void MBSP_Get_Version(char * ParamV); //绑定账务通信SP接入服务器
ACNTSPCLT_API bool MBSP_BindAcntSPSvr(const char * SvrAddr, //服务器地址
unsigned int SvrPort);//服务器端口
这两段函数,连与对方服务器建立连接。这个服务器和服务器端口各地可能都是不一样的。外面的人基本不会知道这些东西的。再说由于各地的移动或者联通自己的系统会有所区别,这两个函数是否通用也是未知的。你怎么可能去连别人。这个不是高手不高手的问题。三、即使你知道端口什么的,也不简单就能连进去。一般象通信公司,银行一类的地方,他们服务器所开端口并不是针对所有人(也就是所有IP的),他们一般只对自己的WEB服务器开放,你所有的请求的都是通过客户端发到WEB服务器,然后转发到内部服务器,检查后再处理数据库的。你看到的是自己在家的机器上操作,实际你的操作都是通过WEB服务器转发到内部服务器上的。而不是你这边直接操作。所以说你根本不用想这个了。就是移动,联通内部的人也不一定搞的定。除非是先把WEB服务器完全给控制了才有可能