Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Service access problem
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Atif Aziz  
View profile  
 More options Jun 11 2007, 9:41 am
From: Atif Aziz <Atif.A...@skybow.com>
Date: Mon, 11 Jun 2007 15:41:18 +0200
Local: Mon, Jun 11 2007 9:41 am
Subject: RE: [Jayrock] Service access problem

> But I am running into this "Access is
> denied" problem with regard to Cross domain restrictions.
> I read all the past related postings in this group.

I think you missed this one which is related to your issue:
http://groups.google.com/group/jayrock/browse_frm/thread/9799b560abda...

Problem is that you're trying to use the proxy to communicate with the service residing in another domain than the hosting page. XmlHttpRequest objects or the browsers generally won't allow this. Grabbing the proxy script over a dynamically added script tag (as I see from your code) is not going to help because it uses the XmlHttpRequest under the hood. For cross-domain communication, you need to make each request back to the service via a dynamic script tag. There are several options for doing this but if want to stick with the dynamic script tag approach then Jayrock can help in two ways. First, you need to make sure your methods are accessible over HTTP GET by marking them as Idempotent (this is a property of the JsonRpcMethod attribute that you decorate your service methods with) because the browser script tag results in an HTTP GET request. Make sure the method behavior is indeed idempotent. Second, you need call the service methods over JSONP[1] for browser compatibility purposes. For this, you'll need to grab the latest developer build available at ftp://ftp.berlios.de/pub/jayrock as this bit of functionality is not currently available in any of the released packages. With these two in place, you can start the scripting magic. Usually, this requires a bit of infrastructure so for quick demonstration purposes, here's how you would call the "now" method of the demo service using the ScriptSrcTransport from dojo...

function getTime()
{
  dojo.io.bind({
    url: "http://localhost/jayrock/demo.ashx/now", // call "now" on the server
    transport: "ScriptSrcTransport",
    mimetype: "application/json",
    jsonParamName: "jsonp",
    load: function(type, data, event, kwArgs) {
      alert("Server time is " + data.result);
    },
    error: function(type, data, event, kwArgs) {
      alert("error!");
    },
    timeout: function() {
      alert("timed out!");
    },
    timeoutSeconds: 10
  });

}

Hope this helps.

- Atif

[1] http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

-----Original Message-----
From: jayrock@googlegroups.com [mailto:jayrock@googlegroups.com] On Behalf Of Tim
Sent: Sunday, June 10, 2007 8:23 PM
To: Jayrock
Subject: [Jayrock] Service access problem

I am new to Jayrock. I think it is really a cool tool. I am trying to
use it in one of our projects. But I am running into this "Access is
denied" problem with regard to Cross domain restrictions. I read all
the past related postings in this group. I used dynamic script tag to
call the web service. But it still only works locally, not on any
third-party site. I used all the standard Jayrock settings. Please
help me, I am just about to pull all my hairs out over this.

Is there any other settings I need to adjust in order to make this
work??

<%@ WebHandler Class="JayrockWeb.HelloWorld" %>

namespace JayrockWeb
{
    using System;
    using System.Web;
    using Jayrock.Json;
    using Jayrock.JsonRpc;
    using Jayrock.JsonRpc.Web;

    public class HelloWorld : JsonRpcHandler
    {
        [ JsonRpcMethod("greetings") ]
        public string Greetings()
        {
            return "Welcome to Jayrock!";
        }
    }
}

On client side:

window.onload = function()
        {
            AddTag();
        }

function AddTag() {
            var head = document.getElementsByTagName("head")[0];
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = "http://www.domainA.com/HelloWorld.ashx?
proxy"
            head.appendChild(script);
            script.onreadystatechange= function () {if
(this.readyState == 'complete') showPop();
            }
        }

function showPop()
        {
            var s = new HelloWorld();
            s.greetings(function(response) {
            alert("async:" + response.result)
            });
        }

Any help would be much appreciated !

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.