How to call web service trought jscript Options
lpastor
Posted: Monday, September 29, 2008 8:37:08 AM

Rank: Aficionado

Joined: 8/4/2008
Posts: 111
Location: Serbia
Hi

I wrote about my problem but with no answer. My deadline is today so if I dont figure out I should found another job :-).

I want to store time that visitor spend on each page. So when he leave a page or close brouser I have to save spend time to Database.

My solution is that onLoad page I create jscript variable with startTime value DateTime.Now()

so on onUnload jscript should call web service and send Diff between startTime and DateTime.Now().

Basicly in some other solution I will use ScriptManager and on Page call my web service like this ..
Quote:

<script type="text/jscript" src="/scripts/timeCountScript.js" ></script>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebServices/sendData.asmx" />
</Services>
</asp:ScriptManager>


and after that call web service method like

ret = sendData.ConfirmExit(timeString, OnComplete, OnTimeOut, OnError);

BUT becouse ScriptManager is already exist in umbraco I have to call this trought code


Quote:

ScriptManager objScriptManager = ScriptManager.GetCurrent(Page);

// Add a reference to the web service
ServiceReference objServiceReference = new ServiceReference();
objServiceReference.Path = "~/webservices/senddata.asmx";
objScriptManager.Services.Add(objServiceReference);



ScriptReference objScriptReference = new ScriptReference();
objScriptReference.Path = "/scripts/timeCountScript.js";
objScriptManager.Scripts.Add(objScriptReference);



The problem was that I always get a message that "....sendData is undefined ...."..
It seams that jscript can found a service...

I exam the other web service that is stored in folde /umbraco/webservices and found that all service have the namespace like ...umbraco.webservices so I put this namespace into my web service.

The result is that when I call web service like
http://localhost/umbraco/webservices/senddata.asmx
I get the list of methid and I can Invoke it and the data is stored in Database ...

SO MY SERVICE WORKING but from page I alvays get the same messsage "....sendData is undefined ...."

What is wrong?

I try to figure out what is the correct path for calling service , I put the all path .."http://localhost/umbraco/webservices/senddata.asm.."
but still nothing

maybe problem is somwere else... I thing that calling web service from jscript is OK ,becouse it work like this in stand alone page that I made for testing purpose...

BUT WHAT is worng

HELP





Adz
Posted: Monday, September 29, 2008 9:38:18 AM

Rank: Aficionado

Joined: 6/5/2008
Posts: 148
Location: United Kingdom
I'm afraid I can't help with the specific problem as I am no expert in .NET

However have you considered:

1. Google Analytics
This is a free service which gathers statistics and provides charts and tables of results

2. Sophus Metrics
This is a paid for service, similar to Google but you are be able to work with Sophus to customize your results.




Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
lpastor
Posted: Monday, September 29, 2008 10:07:55 AM

Rank: Aficionado

Joined: 8/4/2008
Posts: 111
Location: Serbia

Sory, but I cannot use third solution.... it should be internal solution because I need this data in database :-(
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.