Sunday, March 11, 2012

Tutorial issues

As a matter of fact, I checked in a fix to that tutorial about an hour after it went out the door.

The problem is with the path given in the ScriptManager element in the aspx file:

<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference path="~/HelloWorldService.asmx" />
</Services>
</asp:ScriptManager>

The "~" indicates an application relative path, maneing the "~" resolves to the root directory of the web app, which makes a lot of sense if the Web Services for the application are in a central location. In this case, since the Web Service is in the same dirctory as the aspx file, you can fix the path by simply removing the "~/" at which point it becomes a relative path and resolves to the current directory:

<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference path="HelloWorldService.asmx" />
</Services>
</asp:ScriptManager>

Leith McCombs

Microsoft


Gabby,

I ran into the same problem last week. I did a little research online and found an answer that allowed the demos to work.

In your WebService, decorate the WebService class with <Microsoft.Web.Script.Services.ScriptService()> (I'm a VB pgmr, so use [] instead of <> for C#). If you're as lucky as me, the samples should work once change is made.


Thanks JimboM,

Your solution solved the problem. I guess I just missed that line of code in the sample.

Gabby


No, you didn't miss it... It wasn't in the tutorial. Methinks the tutorials need to be updated. Wink

This is what your webservice (SimpleService.asmx) should look like in VB for tutorial #5:

<WebService(Namespace:="http://tempuri.org/")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<ScriptService()> _Public Class SimpleServiceInherits System.Web.Services.WebService <WebMethod()> _Public Function HelloWorld(ByVal strinAs String)As String Return"Hello " + strinEnd FunctionEnd Class

No comments:

Post a Comment