WebService calls: Simulator vs. Real

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
h_kos
Posts: 11
Joined: Wed Oct 28, 2015 11:30 pm

WebService calls: Simulator vs. Real

Postby h_kos » Fri Nov 06, 2015 1:22 am

I have an application that pulls data from a web-service. This works as intended in the simulator. The app shows a list of some 20 patients.

The problem:
It only works fine in the simulator!

Testing the app after deployment going to the app's url in the IE brings up some errors (e.g. "Nullable does not contain a value" - maybe house-made error, I need to check), but catching them will show at least the page with the relavant information.
Chrome does not show anything!

When I run the app on a mobile device (browsing to the app's URL), the page comes up but is completely empty: This is the case for Android and IOS (same result as using Chrome).

If I start the application in the simulator and select the option "Final Version (pure JavaScript/HTML)" and select "Click to run in the browser...", the app's page is empty too (can only run in Chrome because of use of IsolatedStorage, which IE does not support when starting the app from file index.html): same result as running on mobile device.

Interesting to see is the following:
Having Fiddler run in the background, I can see that the request is sent via http-verb OPTIONS, resulting in no correct response for the app. The OPTIONS verb is only sent when using Chrome, IE sends POST!

I assume (but I don't know how to check at the moment) that the Android's browser (and I guess IOS' too) will also send the OPTION verb and not the POST like IE does.

The CORS settings in global.asax and web.config were made.

So I am really a little bit confused...
Did you experience same problems?
Any advices, tips, tricks I can use?

It is very important for us to make this demo-app runnable on mobile-devices...So....can you hear me crying :| ?

Harry

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: WebService calls: Simulator vs. Real

Postby JS-Support @Userware » Fri Nov 06, 2015 9:53 am

Dear Harry,

A few points that I hope will help:
  • In the current Beta, nullable types are not yet supported in WCF, as indicated in the last bullet point of the following URL:
    http://cshtml5.com/links/wcf-limitations-and-tutorials.aspx#soap-limitations
    Can you please verify that you are not using any?
  • In Chrome, please have a look at the console output window to see if there are any error messages. To do so, go to the Developer Tools (Ctrl+Shift+I) and click "Console". If you see any errors, please post them here.
  • Still in Chrome, if you wish to debug exceptions, please follow the steps described at: Tips for debugging JavaScript errors with Chrome
  • You can test apps with IsolatedStorage under IE by doing this: run the simulator, click the "Final version" tab, and then click "Test on mobile devices". A URL will appear. It can be used anywhere, not just on mobile devices. Copy/paste that URL into IE to run your app in IE with full support for IsolatedStorage.

JS-Support

h_kos
Posts: 11
Joined: Wed Oct 28, 2015 11:30 pm

Re: WebService calls: Simulator vs. Real

Postby h_kos » Tue Nov 17, 2015 12:43 am

Ok, nullables I understand...

I attach three Images:
Chrome_request_headers.jpg showing the headers that are sent via the webservice, the second one (chrome_request_console.jpg) is the console output.

As I can see in the headers, the information provided by the debugging console makes sense, but I do not know why these headers are set twice (which seems to cause the error)?

This I added to my web.config (for CORS):

Code: Select all

<system.webServer>   
     <httpProtocol>
        <customHeaders>
         <add name="Access-Control-Allow-Origin" value="*" />
         <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, SOAPAction, Content-Length" />
         <add name="Access-Control-Allow-Methods" value="POST,PUT,GET,DELETE,OPTIONS" />
        </customHeaders>
      </httpProtocol>



and this is my global.asax file:

Code: Select all

protected void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

            if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
            {
                //These headers are handling the "pre-flight" OPTIONS call sent by the browser
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, SOAPAction");
                HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
                HttpContext.Current.Response.End();
            }
        }




IE shows no anomalies in its debugging-information.
Hope this helps.

Harry

By the way: you guys do a good job!
Attachments
Chrome_request_headers.jpg
Chrome_request_headers.jpg (100.05 KiB) Viewed 7118 times
chrome_exception_at.jpg
chrome_exception_at.jpg (134.62 KiB) Viewed 7118 times
Chrome_request_console.jpg
Chrome_request_console.jpg (61.53 KiB) Viewed 7118 times

xidea
Posts: 33
Joined: Thu Jun 30, 2016 7:04 pm

Re: WebService calls: Simulator vs. Real

Postby xidea » Mon Jul 11, 2016 4:44 am

Hi,

I'm getting same issue.

The problem seems to reside (for me) in an error in instancing the XmlSerializer in the javascript code.

Have you solved, and if so, how?

Thanks

Flavio


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 28 guests