如何使用SAP GateWay Service将数据从SAP获取到ASP.net

时间:2016-07-26 13:24:29

标签: asp.net service sap gateway

请帮助如何从SAP Gate way服务获取数据。 SAP团队给出了这个网址: - http://Gateway_host:Gateway_port/sap/opu/odata/sap/ API SRV / ApplicationPendingListSet?$ filter = UserID eq'XXXXX'和用户ID&密码。如何在asp.net中获取这些数据。

请帮忙。

1 个答案:

答案 0 :(得分:0)

字符串SAP_ODATA_URL = @“http://ApplicationURL”;                     string SAP_ODATA_QUERY =“MethodName?$ filter = Parameter eq'”+ extensionAttribute13 +“'”;                     string requestUrl = SAP_ODATA_URL + SAP_ODATA_QUERY;                     WebRequest request = WebRequest.Create(requestUrl);                     request.Method = WebRequestMethods.Http.Get;                     request.ContentType =“application / json; charset = utf-8”;                     request.Credentials = new NetworkCredential(“XXX”,“XXX”);                     WebResponse response = request.GetResponse();                     if(((HttpWebResponse)响应).StatusCode == HttpStatusCode.OK)                     {                         流receiveStream = response.GetResponseStream();                         StreamReader reader = new StreamReader(receiveStream);                         string responseFromServer = reader.ReadToEnd();                         XmlTextReader xmlReader = new XmlTextReader(new StringReader(responseFromServer));                         xmlReader.Read();                         DataSet ds = new DataSet();                         ds.ReadXml(xmlReader,XmlReadMode.Auto); }