Skip to Content
author's profile photo Former Member
Former Member

read Sap netweaver Gateway c# windows 8

Hi All,

I'm developper on sap and I want to create a Windows 8 application to read OData from sap netweaver Gateway.

I Have created an application consol on Windows seven that working fine and this application run into Windows 8.

Now I want to create a Windows 8 store application but I have changed the code due to the new Framework, but this doesn't work I have an exception "JavaScript Runtime Exceptions 0X80070005 Access is denied"

I had the web service throw the menu, and this generated a class.

using System;
using
System.Collections.Generic;
using System.IO;
using System.Linq;
using
Windows.Foundation;
using Windows.Foundation.Collections;
using
Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using
Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using
Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using
Windows.UI.Xaml.Navigation;
using System.Threading;
using
Windows.UI.Popups;

//begin jcol
using System.Net;
using
App6.ServiceReference1;
using System.Data.Services.Client;

// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238

namespace
App6
{
/// <summary>
/// Une page vide peut être utilisée seule
ou constituer une page de destination au sein d'un frame.
///
</summary>
public sealed partial class MainPage : Page
{
static
AsyncCallback callback;
static int requestCounter;
static
List<z_flight> tableau = new List<z_flight>();
string username =
"mysapusername";
string password =
"mysappassword";
ServiceReference1.Z_FLIGHT service;
public
MainPage()
{
this.InitializeComponent();

callback = new
AsyncCallback(callBacK);

//function to read my Odata service

string functionImportName = "z_flightCollection";

//URL of my service
string serviceUrl = "http://myserver:8000/sap/opu/odata/sap/Z_FLIGHT/";
service = new ServiceReference1.Z_FLIGHT(new Uri(serviceUrl));

// authentification from the service

service.Credentials = new NetworkCredential(username, password);

//flag
Interlocked.Increment(ref requestCounter);

string relativeUri = functionImportName;

//generate the url for invoque the service http://myserver:8000/sap/opu/odata/sap/Z_FLIGHT/http://myserver:8000/sap/opu/odata/sap/Z_FLIGHT/http://myserver:8000/sap/opu/odata/sap/Z_FLIGHT/z_flightCollection
Uri uri = new Uri(relativeUri, UriKind.Relative);

//the service is run as a thread
service.BeginExecute<z_flight>(uri, callback, service);

while (requestCounter >
0)
{
}
UpdateUI();
}


private void
UpdateUI()
{

foreach (z_flight flight in tableau)
{
ListViewItem
item = new ListViewItem();
item.Content = flight.airline + " " +
flight.airlineid + " " + flight.airportfr + " " + flight.airportto + " " +
flight.arrdate; ;
listview1.Items.Add(item);
}
}
public void
callBacK(IAsyncResult result)
{
// Decrement the request counter in a thread-safe manner.
Interlocked.Decrement(ref requestCounter);

//get the result
DataServiceQuery<z_flight> query = result as DataServiceQuery<z_flight>;

tableau = query.EndExecute(result).ToList<z_flight>();

}
}
}

Everything work fine but when I want the result I have an exception type "JavaScript Runtime Exceptions 0X80070005 Access is denied"

the exception is reading when I put an spy on result
DataServiceQuery<z_flight> query = result as DataServiceQuery<z_flight>;

But When I go the computer management in the Windows logs I have no error.

Can you help me?

Jonathan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2013 at 08:32 PM

    Hi Jonathan,

    not sure if you are aware of this blog. For the InnoJam 2012 at TechEd Madrid we worked on several Windows 8 / NetWeaver Gateway apps and created this blog to get people started.

    Maybe you find some useful information there.

    The "Access is denied" could be related to some same origin policy issues. Is your OData service running on a trusted site?

    Regards,

    Holger.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.