cancel
Showing results for 
Search instead for 
Did you mean: 

How to call SAP RFC Web Service with .Net Connector v.2.0?

Former Member
0 Kudos

Hi all,

I'm Thai. I've problem to call the RFC Web Service with NCO 2.0.

This is some few in my source code of RFC Web Service.

//----


[WebMethod]

public YHRFC_VNDMAST_KOMTable

get_VendorMast(string p_VndCode)

{

// generate proxy to call RFC

RFC_VendorMast proxy1 = new RFC_VendorMast();

// create an SAP table but as it's an in parameter don't need to

// instantiate it for the rfc call

YHRFC_VNDMAST_KOMTable tblCust = new YHRFC_VNDMAST_KOMTable();

try

{

// Connect to SAP

proxy1.Connection = SAP.Connector.SAPConnectionPool.GetConnection(this.destination1.ConnectionString);

proxy1.Connection.Open() ;

// execute RFC

proxy1.Yhrfc_Vendormast_Kom(p_VndCode, ref tblCust);

}//end try

catch {

/* return an empty table */

tblCust = new YHRFC_VNDMAST_KOMTable();

YHRFC_VNDMAST_KOM row = new YHRFC_VNDMAST_KOM();

tblCust.Add(row);

} // end catch

// close connection

proxy1.Connection.Close();

// return function

return tblCust;

}

This is some source code in my b.aspx program.

-


Private Sub btn_CallWebService_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_CallWebService.Click

Dim p As New ws_itkom_sapwebservice.Service1

x = p.get_VendorMast(Me.tbx_Vnd.Text)

Me.DataGrid1.DataSource = x

Me.DataGrid1.DataBind() 'Error this line.

End Sub

When I run file b.aspx to call the Web Service Function name get_VendorMast it has error like this.

<u>DataGrid with id 'DataGrid1' could not automatically generate any columns from the selected data source</u>

Please help me. How I call and get data from the SAP RFC Web Service.

Anybody who know please explain me step-by-step please.

Thank you very much.

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

Web Service Proxies created with Microsoft's "Add Web Reference" Feature can usually never be used for DataBinding directly. This is because it creates public fields instead of properties. This is not a problem of NCo, but of Microsoft's tool and would also happen with any other Web Service.

BTW: You are doing a kind of "double remoting". This is not very efficient. It would be better either to use NCo directly to bind your VB UI to YHRFC_VNDMAST_KOMTable or skip NCo and use the WebService feature of WAS.