My rest service url's are not working in page load and any other events. - Forum - Mobile - Progress Community

My rest service url's are not working in page load and any other events.

 Forum

My rest service url's are not working in page load and any other events.

This question is answered

My rest service url's are not working in page load and any other events. Here is my sample url I am using " http://sofuture.com/tiservices/tracefamily/AuthService.svc/Version/tracefamily/iphone".

While click on test button it is giving response, but calling from page load events in opendege mobile screens it is not working.

Please do this needful help.

Thanks

 Ram

Verified Answer
  • Nothing I change seems to make any difference.  It must be something to do with running in the browser, because if I deploy the app to my phone, it works on there.  I give up!

All Replies
  • Hi Ram,

    One possible problem I can think of is the CORS (Cross Origin Region Support). Can you please enable CORS filters in the webserver (where the application is hosted).

    Also, can you please check for the respective problem (or information) in the browser through 'Firebug' or 'Web Inspector'

    Hope this helps.

    Thanks and Regards,

    Anil Kumar.

  • But I am using .net rest services here, how can i achieve this.

  • It may help for you to explain our environment more fully.

    The answers to this thread are saying that this looks like a CORS issue.  CORS (or Cross-Origin Resource Sharing) is a common issue (see Wikipedia) where modern browsers have added 'security' features to prevent security intrusion attacks via web pages.  The short summary is that if the 'main' page in a web app comes from one URL, then the JavaScript run on that page can't point to resources loaded from another URL  (You can't unintensionally have a page at one ORIGIN getting resources CROSS-reference RESOURCES from another URL/a second "ORIGIN").

    There are three ways to solve this:

    1. You can disable the CORS checks in your browser, but while that may work for one client, it does not help you build a web application that anyone can use.

    2. You can add a proxy (pass-through) on the application web server that takes all the requests and then on the server side calls the REST service as a server-server interaction.

    3. MOST COMMONLY, you can tell the Web Server serviing up the web application to inform the browser that it is OK to go to particular known cross-origin resources.    (This is what the previous post was suggesting).

    It would be useful to know:

    - where (what web server) is serving up the Web Application (the HTML and JavaScript files that compose the main app)....  I am assuming that this is a Tomcat running in your PDSOE environment.

    - where the REST services are running (normally, for OE Services, these deploy the .paar file on the same server, but you are talking about  -- I assume these are your .net REST services.

  • There are lots of hits on Google for ".net rest service CORS"

    This provides a few suggestions:

    stackoverflow.com/.../cross-origin-resource-sharing-for-c-sharp-wcf-restful-web-service-hosted-as-wind

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • I am added CORS filter to my .net rest services. Still I am unable to get response from mobile events.

  • We might need to debug the request flow. Were you able to fire a successful request to your REST Service from a external client.

    To narrow down the problem, can you please try calling your REST Service with and without a Mobile Application and see what you get in your tomcat access logs.

    Regards,

    Irfan

  • When i debug using firebug it is showing an error  "Blocked loading mixed active content "202.63.113.99/.../getdata" "

    Please give some suggestions how to solve this error.

  • Ram,

    I just wrote a simple sample with the same data-source you had (sofuture.com/.../iphone) and it did not work for me either.  The reason it did not work for me was because of CORS.

    After that, I went into my Chrome icon and edited and added a parameter:

    "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security

    That disabled Chrome's CORS check and I run it again.  It worked on the second time ...

    Do you have Chrome, can you add that parameter to your Chrome and test it again? If it works, it will confirm that you have a CORS issue.  Another way to confirm is by right clicking on your Mobile App (on the Chrome Browser), select "Inspect Element" and look at errors on the Console Tab.

    Hope this helps you,

    Ricardo Perdigao

  • WRT: "I am added CORS filter to my .net rest services. Still I am unable to get response from mobile events."

    You should be doing this on the Tomcat serving up the OpenEdge pieces.    Did you enable it on the .NET side?

  • Bill,

    His data is coming from a .NET REST Service and he is most likely running this on the cloud - mobile.progress.com (completely independent from OE Tomcat & backend).  

    So, to me, it makes sense that he is authorizing another origin on his .Net Rest Service.  For that, he should be doing something like this:

    www.asp.net/.../enabling-cross-origin-requests-in-web-api

    The challenge here is identifying the correct domain that is making the request (so you can authorize it) ... I think it should be mobile.progress.com, but I don't know for sure.

    Hope this helps,

    Ricardo

  • For it work from the OE Mobile Cloud development, the origin he should authorize is "project.mobile.progress.com/".  On production, he will need to authorize his domain name.

  • Hi Ricardo,

              You are correct, I am calling  my .net rest service from mobile.progress.com mobile page events.

  • I was able to bypass the first CORS issue by using jsonp (see picture above).  But than I hit another issue.  Progress OE Mobile Website uses https and your service is on http. You cannot mix and match http and https because of CORS.  Either the request and response are http or https. It would not be a problem on production, but it is one for your Development environment. 

    I will ask Edsel Garcia to check this thread out ... He is the God on all things REST. 

  • Hi Ricardo Perdiga,

                        Any updates from  Edsel Garcia about this thread.

  • Hi

    This espn url is working fine." api.espn.com/.../sports ,I am able get data from this url. So what's wrong in my .net rest servcie url " sofuture.com/.../iphone"