Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

AJAX client web service call

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cesar - 03 Dec 2007 08:56 GMT
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
Lloyd Sheen - 03 Dec 2007 14:24 GMT
> Hello,
>
[quoted text clipped - 63 lines]
> 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
Cesar - 03 Dec 2007 19:04 GMT
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

> > Hello,
> >
[quoted text clipped - 74 lines]
> Hope this helps (it did me)
> Lloyd Sheen

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.