Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-6096

WP8 Project - XHRHelper.HandleCommand failing with 'System.InvalidOperationException

    XMLWordPrintableJSON

    Details

      Description

      I need jquery/ajax to ping SAP-Server.

      I get the following exceptions:
      System.InvalidOperationException occured of type "System.ni.dll"
      Exception of Type System.InvalidOperationException in Microsoft.Phone.Interop.ni.dll

      In these cases I received a 404 error.
      Value of commandSt was changed during debugging.
      commandStr: "XHRLOCAL/Http://sapfd1.flexus.net:8030/sap/public/ping?=1362547834285"
      or
      commandStr: "XHRLOCAL/Http://sapfd1.flexus.net:8030/sap/public/ping"

      Part of JavaScript
      function checkPublicPing() {
      		var successful = false;
              var publicPingPath = "sap/public/ping";
              var serverURI = "http://sapfd1.flexus.net:8030";
      
      		$.ajax({
      			async : false,
      			url : serverURI + publicPingPath,
      			cache : false
      		}).fail(function(error) {
      			successful = false;
      		}).done(function(data, textStatus, xhr) {
      			successful = true;
      		});
      		return successful;
      	}
      
      Part of cordovalib/XHRHelper.cs
       public bool HandleCommand(string commandStr)
              {
      //commandStr: "XHRLOCAL/Http:/sapfd1.flexus.net:8030/sap/public/ping?_=1362547834285"
      
                  if (commandStr.IndexOf("XHRLOCAL") == 0)
                  {
                      string url = commandStr.Replace("XHRLOCAL/", "");
      // url: {Http:/sapfd1.flexus.net:8030/sap/public/ping?_=1362547834285}
      
                      Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);
      // uri: {Http:/sapfd1.flexus.net:8030/sap/public/ping?_=1362547834285}
      
                      using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                      {
                          if (isoFile.FileExists(uri.AbsolutePath))
                          {
      //uri.AbsolutePath: InvalidOperationException Typ "Sytem.ni.dll"
      
                              using (TextReader reader = new StreamReader(isoFile.OpenFile(uri.AbsolutePath, FileMode.Open, FileAccess.Read)))
                              {
                                  string text = reader.ReadToEnd();
                                  Browser.InvokeScript("__onXHRLocalCallback", new string[] { "200", text });
                                  return true;
                              }
                          }
                      }
      

      Please advise.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                purplecabbage Jesse MacFadyen
                Reporter:
                domainturk68 Mehmet Zahid Aydin
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: