cancel
Showing results for 
Search instead for 
Did you mean: 

Problems creating web service using SAP .NET Connector

Former Member
0 Kudos
463

I’m trying to use the SAP .NET Connector in a web service project of a Visual Studio .NET solution. I followed the DNCWebServiceSample example provided with the Connector and created a web service that tests ok (XML renders with no errors in a browser window) but I keep running into problems calling the method from an aspx page. For DNCWebServiceSample, if I use

NameSpace.WebService.BRFCKNA1Table ReturnObject=new NameSpace.WebService.BRFCKNA1Table()

to define the table object on the calling page, I get a build error that "BRFCKNA1Table doesn’t exist in the namespace." And if I try just defining BRFCKNA1

NameSpace.WebService.BRFCKNA1 ReturnObject=new NameSpace.WebService.BRFCKNA1()

I get the error:

"Cannot implicitly convert type 'NameSpace.WebService.BRFCKNA1[]' to 'NameSpace.WebService.BRFCKNA1'"

What am I doing wrong? Unfortunately, I couldn’t find any sample code that shows you how to call the DNCWebServiceSample from an aspx page.

I’ve also tried to use the ToADODataTable method within the web service to convert the SAP tables to ADO tables and add the ADO tables to a DataSet. One RFC that I’m using returns 11 tables, so I thought this would be a good way to return all that data as a single DataSet. But I keep getting XMLSchemaException errors trying to

invoke the web method from an aspx page.

Either way, I want to set up a web service using the .NET connector for other applications to consume. Any help would be greatly appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The return type of the method is BRFCKNA1[] instead of BRFCKNA1. You should make the call like this:

NameSpace.WebService.RFCCustService proxy =

new NameSpace.WebService.RFCCustService();

...

NameSpace.WebService.BRFCKNA1[] retrunTable

= proxy.CustomerWebService(...);

...

Please also note that you don't need to new an instance for returnTable before the method call.

Regards,

Guangwei Li

Former Member
0 Kudos

Thanks! That got rid of the build error and data seems like it's being passed, but I can't bind the results to a DataGrid. Even though the webservice is returning BRFCKNA1Table, the calling page has a BRFCKNA1 object that won't bind to a DataGrid. What needs to be done to view the returned data on the calling page?

Former Member
0 Kudos

Hi,

The BRFCKNA1 class generated by VS when you adding Web Reference into your project is different from that one used in the original web service, and is no more bindable. Also the return type has been changed from class BRFCKNA1Table to an arry of BRFCKNA1.

You can make the class BRFCKNA1 bindable by manually making each public field to a public property:

- Turn on "Show all Files" button on the top of Solution Explorer.

- Navigate to Web References ->... Reference.cs

- Make each public field to a public property, for example, change field KUNNR as follows:

public string KUNNR

{

get

{

return _kunnr;

}

set

{

_kunnr = value;

}

}

private string _kunnr;

- Rebuild your application.

Of course, you can also use Response.Write display the return results without using a DataGrid at all.

Regards,

Guangwei Li

Former Member
0 Kudos

Works perfectly... thanks so much for your help!