AJAX client web service call

C

Cesar

Hello,

I have an asp.net ajax enabled web site that has one aspx page to call a web
service method via the script manager using the service reference.
My problem is that it's only works if my web serivce resides on the same
project; otherwise it doesn't. It has nothing to do with any misconfuguration
(e.g not having tested the "/js" on the webservice's url). The web service
method only returns the result of (A * B).

When I invoke the web service I get the following message: The server method
'Test' failed

This part of the client code of the aspx page:

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference
Path="http://localhost:1064/AJAXWebServiceTest/MyWebService.asmx" />
</Services>
</asp:ScriptManager>

A = <input type="text" id="a" /><br />
B = <input type="text" id="b" /><br /><br />
C = <span id="c"></span><br /><br />

<input type="button" value="Get Data" onclick="GetMyData();" />

Now the javascript code ...

<script language="javascript">

function Resultado()
{
var myValue1 = parseInt(document.getElementById("a").value);
var myValue2 = parseInt(document.getElementById("b").value);

//
// Web service call: ajax (WebService = class name)
//
WebService.Test(myValue1,myValue2,callComplete,callError);
}

function callComplete(result)
{
document.getElementById("c").innerHTML = result;
}

function callError(result)
{
document.getElementById("c").innerHTML = "Something went wrong: <br/>1)
" + result.get_exceptionType() + "<br/>2) " + result.get_message() + "<br/>3)
" + result.get_stackTrace();
}

</script>

Please remember that if the path of the ServiceReference is set to
"MyWebService.asmx" it works perfectly but if it's
"http://localhost:1064/AJAXWebServiceTest/MyWebService.asmx" it doesn't

Any ideas?
Thanks in advance,
Cesar
 
L

Lloyd Sheen

Cesar said:
Hello,

I have an asp.net ajax enabled web site that has one aspx page to call a
web
service method via the script manager using the service reference.
My problem is that it's only works if my web serivce resides on the same
project; otherwise it doesn't. It has nothing to do with any
misconfuguration
(e.g not having tested the "/js" on the webservice's url). The web service
method only returns the result of (A * B).

When I invoke the web service I get the following message: The server
method
'Test' failed

This part of the client code of the aspx page:

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference
Path="http://localhost:1064/AJAXWebServiceTest/MyWebService.asmx" />
</Services>
</asp:ScriptManager>

A = <input type="text" id="a" /><br />
B = <input type="text" id="b" /><br /><br />
C = <span id="c"></span><br /><br />

<input type="button" value="Get Data" onclick="GetMyData();" />

Now the javascript code ...

<script language="javascript">

function Resultado()
{
var myValue1 = parseInt(document.getElementById("a").value);
var myValue2 = parseInt(document.getElementById("b").value);

//
// Web service call: ajax (WebService = class name)
//
WebService.Test(myValue1,myValue2,callComplete,callError);
}

function callComplete(result)
{
document.getElementById("c").innerHTML = result;
}

function callError(result)
{
document.getElementById("c").innerHTML = "Something went wrong: <br/>1)
" + result.get_exceptionType() + "<br/>2) " + result.get_message() +
"<br/>3)
" + result.get_stackTrace();
}

</script>

Please remember that if the path of the ServiceReference is set to
"MyWebService.asmx" it works perfectly but if it's
"http://localhost:1064/AJAXWebServiceTest/MyWebService.asmx" it doesn't

Any ideas?
Thanks in advance,
Cesar

First thing I notice is the webservice call. It is the same as what I was
using until I found the following link:

http://dotnetslackers.com/columns/ajax/ASPNETAjaxWebService.aspx

You will notice the call is different than the call which I found in a video
a while back. There is some other info in the article which might help you.

Hope this helps (it did me)
Lloyd Sheen
 
C

Cesar

Hello Lloyd,

Thanks a lot for your help. However as far as I can understand, my problem
had nothing to do with the call signature; althought I had not included the
"userContext" it worked by having both the web service app and the calling
aspx page on normal (live) virtual directories:
1) http://localhost/ajaxwebservice/WebService.asmx
2) http://localhost/ajaxcall/default.aspx

And of course having the ServiceReference path set to
"http://localhost/ajaxwebservice/WebService.asmx"

I just started checking on ajax by myselft and so far, all the documentation
(videos included as well) only use the webservice within the same web
application as to the calling aspx page. I have no problems at with adding
"normal" web references to vs2005 "virtual web sites" (e.g.
http://localhost:4983/myWebService/myWebService.aspx) from another "virtual
web site" as they certainly work ...

But this time it didn't work for me calling ajax enabled web services
(running on a vs2005 virtual web site) from another aspx page running on
another virtual web site.

I'm not sure if I'm doing wrong but I guess I'll only use now "live" virtual
directories when testing ajax stuff.

Not sure though if anyone else has experienced this situation ?
Thanks a lot.

Best regards,
Cesar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top