Web services deployment question

Associate
Joined
18 Oct 2002
Posts
972
Location
Derby
I have written a web service for my computing class which basically does the following:

An admin department can input various events that are happening in a football match. These events are inputted through a webservice and inserted into a database.

There is a client-side aspx page that refreshes and informs the user of any goals etc..

Basically the coding has gone ok I just have a couple of questions you guys might be able to help me out with with respect to how it's constructed. I have constructed it in Visual Studio 2005 and running the application works fine. The program has to be handed in on a CD with instructions on how it works. What I was thinking was:

Hand the code in on a CD with instructions on how to access the system through my webspace. My webspace supports ASP.NET so I assume that this would also work with my web service. Simple, I though and uploaded the files onto my webspace. I attempt to access the index.aspx page and get the following error:

Code:
 Compiler Error Message: BC30002: Type 'football' is not defined.

Football is name of my class that I have created and in the past working with notepad I have encountered this and read that I may need a proxy class. I then discovered that one of the super duper features of VS2005 is that it creates one for you. Therefore I am a bit concerned that it wont work on demo/hand-in date and was wondering if you guys could point out any glaringly obvious problems with the setup:

File: football.asmx

This page links to a code behind page shown below:

Code:
<%@ WebService Language="VB" CodeBehind="~/App_Code/football.vb" Class="football" %>

File: football.vb (found in App_Code)

Code:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.OleDb


<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class football
    Inherits System.Web.Services.WebService
    'Database variables
    Dim objCmd As New OleDbCommand
    Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings("DSN"))
    Dim objRdr As OleDbDataReader

File: index.aspx (I have added a method example just so you can check how it accesses the webmethods)

Code:
<%@ Page Language="VB" Debug="true"%>
<%@ import Namespace="System.Data.OleDb"%>

Sub getDates()
        Dim objService As New football()
        dateDropDown.DataSource = objService.getDate()
        dateDropDown.DataValueField = "date"
        dateDropDown.DataTextField = "date"
        dateDropDown.DataBind()
    End Sub

Finally i have a file called index.aspx.vb which contains the following:

Code:
Partial Class _Default
    Inherits System.Web.UI.Page

End Class

Does this look like a typical setup to you? I can imagine I have made a schoolboy error somewhere.

Thanks for your time
 
Associate
OP
Joined
18 Oct 2002
Posts
972
Location
Derby
therubble said:
Did u add a web reference to the consumer? It's the adding of this reference that creates the proxy class from the webservice.

If I do this and enter the local url then it discovers the web service but if I upload all the files to my webspace and enter the web URL i get the same "football" not defined error in the preview pane in VS2005. I did notice this url that maybe should be changed but I had no luck.

Code:
<WebService(Namespace:="http://tempuri.org/")>

Thanks for your help
 
Soldato
Joined
8 Jan 2003
Posts
3,737
Location
Scotland
You haven't imported a reference to your webservice in your index.aspx page. I'm also confused as to why your using code-inline but you've setup your index.aspx page to use code-behind.

Try moving your getDates procedure to your index.aspx.vb file.
 
Associate
Joined
14 Apr 2003
Posts
1,101
maybe stating the obvious here but your webspace is running ASP.NET v2.0 isn't it? Because VS 2005 compiles in 2.0 and a lot of web servers still run v1.1.

matt
 
Soldato
Joined
18 Oct 2002
Posts
4,903
Based on the code you've posted i'm not totaly getting the full picture
but based on what I can make out i'll try and go through the
steps you should have taken.

firstly you should realy move this bit of code into the codebehind file

Sub getDates()
Dim objService As New football()
dateDropDown.DataSource = objService.getDate()
dateDropDown.DataValueField = "date"
dateDropDown.DataTextField = "date"
dateDropDown.DataBind()
End Sub

when you move that also move this line
<%@ import Namespace="System.Data.OleDb"%>

but change it to
Code:
import System.Data.OleDb

now that you've moved them make sure you've consumed the web service
you created before. To do this right click on you web reference folder and
select "Add web reference" when past in the url to the web reference.
The give it a reference name Note: rememver the name you give it as
you'll need it next.

Right now you have the web reference setup, I usualy create an instance of
it similar to how you've done it, but I do it like this.

Code:
Dim objService As serviceReferenceName.football = new serviceReferenceName.football

that line wil replace your Dim objService As New football()

go though them steps if you havn't already. if that doesn't work it could
be the .Net version problem already mentioned.
 
Associate
OP
Joined
18 Oct 2002
Posts
972
Location
Derby
Well I can't work on it today but I was just posting to say thanks a lot for all your input. Gman you have shown me a few obvious omissions. I shall try all of your suggestions and let you know how it goes.

Cheers guys
 
Associate
OP
Joined
18 Oct 2002
Posts
972
Location
Derby
Unable to consume web services

I have been writing a webservice for one of my computing classes. What I have been doing is creating the web service in Visual Studio 2005 and adding aspx pages to invoke the web methods etc..

This has been working fine when I have been going along and debugging etc until the time when Ive got to demonstrate the software. I understand that my teacher wants it to work say, by simply copying the files to localhost and accessing it like that. This is were my problem lies.

I have created a very small web service to test this with at first before messing with my main project. The aim of this is to have a webmethod in a .asmx file and a aspx page that "consumes" the web service. Here is the contents of the asmx file:

Code:
<%@ WebService language="VB" class="CalcService" %>
Imports System.Web.Services

Public Class CalcService
<WebMethod ()> _
Public Function Calculate(x As Integer, y As Integer) As Integer
Return x + y
End Function
End Class

My aspx page contains the following code

Code:
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="CalcService" %>
<html>
<head>
<title>Testing</title>
</head>


<script runat="Server" language="VB">


Sub Calculate(s As Object, E As EventArgs)
Dim objService As New CalcService()

lblResult.Text = objService.Calculate(txtX.Text, txtY.Text)

End Sub

</script>

The whole thing falls over and tells me that on the aspx page:

Code:
BC30002: Type 'CalcService' is not defined

So I get reading and i find out that I am supposed to create a proxy class to enable the two to talk to each other. I firstly find out you can do this by adding a web reference in VS2005. I do this and get the same error. I also tried adding the web reference in my code as follows:

Code:
Dim aWebService As localhost.CalcService = New localhost.CalcService()

This does not work. I then try to make the proxy class and the DLL in cmd prompt. I point my paths to the WDSL.EXE in VS2005 and the compiler path to my .NET framework 2.0. I create the .vb file and the DLL, place them in the Bin directory and I get the same damn thing. I have tried compiling in .NET 1.1 and 2.0, I have also tried changing my compiler in IIS from 1.1 to 2.0.

Does anyone see anything obvious that I have done wrong. I dont get that if it works through VS then it should be a case of putting it in Inetpub/WWWRoot. Any help or suggestions really appreciated.
 
Back
Top Bottom