Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are correct that this is a cross-origin problem. There are several ways of handling this:</p> <ol> <li><p>You can turn your web service into JSONP as long as the data that needs to go to the web service is not terribly large. The data coming from the service can be as large as you like though. By not terribly large, it must be about 2k characters or less - you can calculate the amount of data that can be sent in one JSONP request by knowing that it is sent as part of the get request from the src attribute of the script tag.</p> <p>Here's a good SO answer on JSONP with which you may already be familiar: </p> <p><a href="https://stackoverflow.com/questions/2067472/what-is-jsonp-all-about">What is JSONP all about?</a></p> <p><strong>UPDATE</strong> </p> <p>Here's an example of doing JSONP in VB.NET:</p> <p><a href="http://www.sattsoft.com/tutorials/contents/1/14/cross-domain-call-using-ajax-jquery-jsonp-and-vb-net-web-service.html" rel="nofollow noreferrer">http://www.sattsoft.com/tutorials/contents/1/14/cross-domain-call-using-ajax-jquery-jsonp-and-vb-net-web-service.html</a></p></li> <li><p>You can create a sub-domain of www.wunderweddings.com, call it perhaps "api.www.wunderweddings.com" and use DNS to point that subdomain to the right place using either an A or CNAME record. Then you would embed a tiny (invisible) iframe into your client-side page that would point to this new api host (be sure to specify the src as "//api.www.underweddings.com" so as to match http/s of the containing page), and use javascript within the iframe to promote its document.domain to www.wunderweddings.com which you may do through script injection but its easier to just have that page on the server provide the script to do it, then you can communicate freely between the iframe which points to your api and the page containing the iframe which is at www.wunderweddings.com. So code inside the iframe would go access the web service for you, get the data, promote its document.domain, and notify the containing page. </p></li> <li><p>If you know postMessage is always available on your clients (probably not though) you can do the above without changing the document.domain.</p></li> <li><p>Points 2 and 3 above probably sound like a hassle! Especially if you intend to expand the web services you offer and/or the number of domains accessing that service. If so, I would very highly recommend utlizing EasyXDM, it is a wonderful and quite powerful library for doing client-side cross-domain RPC: </p> <p><a href="http://easyxdm.net/wp/" rel="nofollow noreferrer">http://easyxdm.net/wp/</a></p> <p>EasyXDM provides fallbacks from postMessage if it isn't available such as communication through the hash or the name attribute, among a few other things.</p></li> <li><p>You can fix the crossdomain.xml. Now here's where I'm a little rusty but I'll give you my best guess:</p></li> </ol> <p><strong>UPDATE</strong></p> <p>You want your crossdomain.xml to like this:</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;cross-domain-policy&gt; &lt;allow-access-from domain="*" /&gt; &lt;allow-access-from domain="*.wunderweddings.com" /&gt; &lt;/cross-domain-policy&gt; </code></pre> <p>The first child of the "&lt;cross-domain-policy&gt;", that is "&lt;allow-access-from domain="<em>" /&gt;" will make it completely unrestricted whereas "&lt;allow-access-from domain="</em>.wunderweddings.com" /&gt;" will make it so only wunderweddings.com and subdomains will be allowed to do a crossdomain call by the browser. You don't need both "allow-access-from" tags, but at least one of them.</p> <p>I'm not sure why that configuration stuff is in there, it shouldn't be. I completely failed noticing that the first time around, that is almost certainly your problem. Also make sure that crossdomain.xml is being served from the other server, the one with the web service.</p> <p>So just to clarify, that crossdomain.xml should not have that extra XML at the bottom, the &lt;onfiguration&gt;...&lt;/configuration&gt; tags and everything inside of it, all of that is leaking in from someplace and shouldn't be inside crossdomain.xml</p> <hr> <p><strong>FINAL UPDATE</strong></p> <p>For those reading this answer who have a similar problem, Floran discovered the problem with the invalid character:</p> <p>this had to be added to the top of the page: </p> <pre><code>&lt;asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"&gt; &lt;Services&gt; &lt;asp:ServiceReference Path="geolocation.asmx" /&gt; &lt;/Services&gt; &lt;/asp:ScriptManagerProxy&gt; </code></pre> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COSuggestion 1, 4 and 5 seem interesting: Suggestion 1: how do I convert my webservice to JSONP? I see a lot of example where a piece of AJAX code is added to a page, but I don't have that AJAX call currently since I believe it's all handled by the default .NET control cascading dropdown...should I override/replace that? I find it weird that my requirement is not possible out-of-the-box. Suggestion 4: Seems a bit too much work for now. Suggestion 5: I tried this, but does not fix the issue, still get the "Unexpected token <" error.
      singulars
    2. COFirst thing, I'd try to track down that error. Get the page back to the state prior to the error if you have source control for example. Check inside the vbhtml file (I assume it is vb as well) to make sure you don't have mismatched quotes, inside script tags or included javascript. The reason there isn't an out-of-the-box solution is due to the browser security policies. These have been around for quite awhile, but CORS (Cross-Origin Resource Sharing) should help, though support is not complete or missing in some older browsers (http://en.wikipedia.org/wiki/Cross-origin_resource_sharing).
      singulars
    3. COThen when its in that state try #5 as a quick fix. Using crossdomain.xml should actually work just fine, I'll update the answer in a few minutes with a working crossdomain.xml example. To convert your web service to JSONP you can check these resources: http://www.sattsoft.com/tutorials/contents/1/14/cross-domain-call-using-ajax-jquery-jsonp-and-vb-net-web-service.html and http://stackoverflow.com/questions/17107161/access-asmx-webservice-cross-domain-and-load-results-into-cascading-dropdown/17213675?noredirect=1#comment24938737_17213675
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload