简体   繁体   中英

c# SAP NetWeaver Connection via OData

I have to make a connection in C# between my client program and the SAP NetWeaver programm, which I can do over OData. The problem is the URI of the OData-Service is always an other. So I can't use in Visual Studio the "Add Service Reference", that would be too static.

In my research I found this: http://blogs.msdn.com/b/astoriateam/archive/2011/10/14/introducing-the-odata-library.aspx But I didn't come along with this, I appreciate any help.

How can I handle a dynamic service endpoint from my application ?

Thanks Patrick

Problem solved, I thought a way too complicated. I can communicate via REST with the URI and will get the data I need. Example.

string uri = "http://services.odata.org/OData/OData.svc/Products" 
string odataQuery = "?$format=json"
var request = WebRequest.Create(uri+"/"+odataQuery);
request.Method = "GET";
var reader = new StreamReader(stream: request.GetResponse().GetResponseStream());
string neededData = reader.ReadToEnd(); //json format

Hope I could help someone who has the same problem.

Thanks Patrick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM