(如果机器上没有Java runtime environment 就会一直停留在Loading的画面=.= )
e. 启动项目,在textbox里面输入检索关键字,就可以看到这样的画面,调用成功^0^
上面是以Winform为例,下面简单说一下Web App和Web Service,还是有点差别的哟
【Web App】
Web app的不同之处在于
(1)在default.aspx中加入button,datagrid以及textbox后,在后台程序中加入如下代码:
private void Button1_Click(object sender, System.EventArgs e)
{
// Declare parameters here
SAPProxy1 proxy = new SAPProxy1();
SAPRFCIF.BRFCKNA1Table brfcknA1Table1 = new BRFCKNA1Table();
try
{
proxy.Connection = SAP.Connector.SAPLoginProvider.GetSAPConnection(this);
// Call methods here
proxy.Rfc_Customer_Get("", this.TextBox1.Text, ref brfcknA1Table1);
// Now update Data Bindings. On WinForms this will be automatic, on // WebForms call the following line
this.DataBind();
}
catch(Exception ex)
{
// If SAPLoginProvider.GetSAPConnection(this) cannot get a connection, // we might get an error.
// Normally this can be ignored as it will automatically will force a // relogon.
}
}
(2)需要新建一个SAPLogin1.aspx,这个也是装了SAP.net Connector以后,在新增项目的时候可以看到的一个aspx模板,然后在SAPLogin1.aspx.cs中添加如下代码
string systemNumber = "00";//这个也是要看SAP服务器设置的
private void Login_Click(object sender, System.EventArgs e)
{
// Bind data back
this.destination1.Username = this.user.Text;
this.destination1.Password = this.password.Text;
//设置sap服务器 start
this.destination1.AppServerHost="这个自己填哈";
this.destination1.SystemNumber= short.Parse(systemNumber);
;
//设置sap服务器 end
try
{
this.destination1.Client = short.Parse(this.client.Text);
}
catch(Exception)
{
this.destination1.Client = 0;
}
if (this.language.Text.Length > 0)
{
this.destination1.Language = this.language.Text;
}
try
{
SAP.Connector.SAPLoginProvider.OpenSAPConnection(this, destination1.ConnectionString, this.persist.Checked);
}
catch (System.Exception exception)
{
this.message.Text = exception.ToString();
}
}