Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Access web service on localhost from Android device

$
0
0

I'm attempting to make ajax calls from a android device to a web service that's hosted locally (i.e. localhost). However, receiving the following error:
Refused to connect to 'http://localhost:52437/MyServiceContract.svc/Read_Customer/11sj82' because it violates the following Content Security Policy directive: "connect-src
'self' http://localhost:52437/MyServiceContract.svc".

I've included the web service in a CSP directive via meta tag in the app but to no avail. Here's sample html tag:

<meta http-equiv="Content-Security-Policy" content="connect-src 'self' http://localhost:52437/MyContract.svc; script-src 'self' https://maps.googleapis.com; default-src 'self' https://ssl.gstatic.com data: gap: 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

I've tried to use ADB reverse socket whereby the port no. for localhost is added. Here's a sample of the adb command:

adb.exe reverse tcp:4000 tcp:4000

After doing so, I'm able to access and retrieve data from the web service via web browser on the  device.

In lieu of including the directives in the meta tag, I also tried using the config.xml but to no avail.

Lastly, I've been able to successfully access the web service from the simulator.


Any help is appreciated.


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>