Showing posts with label proxy. Show all posts
Showing posts with label proxy. Show all posts

Wednesday, March 28, 2012

Atlas web service proxy undefined - bug or mistake?

Ok, here's the deal: I have javascript method that is called on the window's load event:

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

Pretty striaghtforward, right? Well, when the getDataForTable method executes it calls an Atlas proxy method:

WebServices.Callbacks.CalendarFunctions.CheckDate(dateField.value, getDataForTable_Callback);
But when the script execute on load, I get an error stating that 'WebServices' is not defined. When I check the HTML output the Atlas javascript reference is there: "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/> "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/>
<script type="text/xml-script"><page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> <add src="/Anthem/Callback/CalendarFunctions.asmx/js" /> </references> <components /></page></script>
And when I hit the URL above the javascript there looks correct:
Type.registerNamespace('WebServices.Callbacks'); WebServices.Callbacks.CalendarFunctions=new function() {this.path = "http://localhost:64408/Project/Callback/CalendarFunctions.asmx"; this.appPath = "http://localhost:64408/Anthem/"; var cm=Sys.Net.ServiceMethod.createProxyMethod; cm(this,"CheckDate","date"); }

So... here is the question: why is this undefined? I think this is a bug because when I debug the script the ".asmx/js" script is not loaded in the script explorer window like other referenced scripts. So, any work arounds? How else do I get this call to execute during the window.onload event?

Thanks in advance for the help.

The best thing to do I think is to install something like fiddler, and verify that the request going out is in the form you expect, and that you are indeed getting the javascript that you get when you use the script include. Hopefully you'll see something obvious...

Actually I think this might be a timing issue, you are probably calling your onLoad before atlas has a chance to load its scripts, so you can verify that is the case in fiddler. Anyways you probably want to register your getDataForTable on pageLoad or using atlas's ApplicationOnLoad.

Hope that helps,
-Hao


You are right, I added the getDataForTable method after I posted this and it worked - it was just a timing issue. Thanks for the help though!

Saturday, March 24, 2012

Atlas through apache proxy

Hi

I'm hosting pages on apache, and I need access to asp.net2 pages hosted on another server. To expose only one server on the net, I decided to show my apache server, and use a virtual directory as proxy to the iis server, with somethink like this :
http://www.codeproject.com/aspnet/cassini_apache_101.asp

The thing works well, but not atlas...
I'm explaining :
Apache is configured to redirect /iis/* requests to the IIS server as /*
I'm using a sample empty page to test atlas (update panel containing 1 button, 1 textbox and 1 label, with an updateprogress).
The page works well, without any atlas objects.
When adding atlas, the proxied page doesn't work (javascript error).
When reading the source, I see a script with this url :

<script src="http://pics.10026.com/?src=/testatlas/WebResource.axd?d=V3h7lAaHQGE9jJRzRQZIfy1AxfEQzTtQmmpxyF4UrKQxRFNElU1QoINPfX3GmTiJpZAHIiXxweeRrf8WfQuZZjp6nneIqCzcGcWwa4A2zOk1&t=632799255520000000" type="text/javascript">
The url is bad. Let's look a the calls made at each step :
My browser is requesting http://server/iis/page.aspx
Apache proxy is handling this request, and makes a request http://iis/page.aspx
The response is returned to the browser.

So all the path infos are returned relative to the request made by the proxy, and not rewritten when the response is returned.

One solution can be to specify relative url from the page (with enough ../ ) to go to the root, and not relative url from root.

Does anyone know if there is another solution ?

I suggest that you look at the following post:

http://forums.asp.net/2/1248767/ShowThread.aspx

You can use the technique mentioned by mharder to override the Atlas scripts path, so that instead of using the web resource it uses Atlas scripts from the location you specify.