I need help

vnarod

Regular
Joined
Mar 22, 2002
Messages
84
I need to do a simple thing: 3-tier app using XML web extensions.

Web Server should get data from database and send it to a client. I never did it before and I am stuck. On-line help doesn't make it easier. Can someone walk me through?

I created a Web Service with methods such as
<WebMethod> Public Function GetData(ByVal sSQL As String) As DataSet
Dim oCmd As SqlCommand = New SqlCommand(sSQL, cn)
Dim da As SqlDataAdapter = New SqlDataAdapter(oCmd)
Dim ds As New DataSet()
Try
da.Fill(ds)
Return ds
Catch e As SqlException
MsgBox(e.Message)
cn.Close()
End Try
End Function

What should I do next? How do I connect client to this service?
How do I test it?

Please, help
 
First things first. You should consider how efficient you want your application to be. For example Datasets are great but it doesn't mean you have to use them. You could use DataReaders to return readers and then send parameters to the web service for a command to update. Just something to consider as Datareaders are much faster than Datasets.
Once your webservice is up an running on the webserver you have to include a reference to it in your app. Once you do it's available to you like anything else. Simply add webreference, type in the url of the webservice, e.g. http://myserver/mywebservice/mywebservice.asmx.
Then to use it you declare a reference to the service:-

Dim WS As New myserver.mywebservice()
dim ds as dataset = ws.GetData("select * from mytable")
 
1. I tried Datareaders I got an error message saying that DataReader cannot be serialized so I cannot use them. Is there a way around it?

2. The problem I am haveing with adding webreference right now is that while I use "localhost" reference is added, but when I copy files to another webserver and use that server's name, instead of reference I get Open/Save Target/Cancel dialog box. It sees the file but as something to download not as reference.
Why is that?

3. Does this webreference mean that in the event my server program will be moved to another server I will need to change client program and recompile it? Is there a way to specify server name in INI or registry?

4. I keep reading about SOAP in connection with all this. Do I need to do anything with it?

Thank you
 
Webservices are by no means simple. I recommend you read up on them and get to grips with all that is involved. I think the problem you are having is that when putting a webservice on a server you also need to generate a discovery file, disco, that will allow your client to see it properly. In any case heres a link to check out:-

http://aspnet.4guysfromrolla.com/articles/062602-1.aspx

Regarding the datareader you are right and I was wrong :) I'm just too into finding faster ways of doing things.
 
Back
Top