My first web service: some newbie questions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

I have written my very first Web Service. And I have some
newbie question.

Here is what I have done (please advice if there is a better way).

I have created a simple service that does the following.
Takes in input a file name and return its content.

Here is the service:
'---------------------------------------
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://localhost/";, _
Name:="MyReportServices", _
Description:="Update and displays a file")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function GetReportByName(ByVal FileName As String) As String

Dim FileNameOnServer = Server.MapPath(FileName)

If Not System.IO.File.Exists(FileNameOnServer) Then
Return "File " & FileNameOnServer & " not found on Server"
End If

Return System.IO.File.ReadAllText(FileNameOnServer)

End Function

End Class
'-----------------------------------------------

I placed the service on my web root.

Then I had to figure out how to call it from a web page.
I didn't have a clue and did the following. Created a new asp.net
page. Placed on it a Button and a TextBox. Added a reference to my
webservice.
And under the Button click handler I wrote:


'-----------------------------------------------
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub ButtonLoadFile_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ButtonLoadFile.Click

Dim MyReportServices As New localhost.MyReportServices
With MyReportServices
Response.Write(.GetReportByName(Me.TextBoxFileName.Text))
End With

End Sub

End Class
'-----------------------------------------------


This seems to work fine (file content appears before the button
and the textbox). Now my questions:


1. If I want to call the service from a simple html page
with just a textbox and a button form. What would the code be?

2. I want to distribute the .asmx so that anyone can use the service
on his/her own server.
In such a case it is correct to have -->
Namespace:="http://localhost/";
or what should it be in order to work independently of the server
where the service is
hosted?

3. I see that the response appears before the button and TextBox.
How would I change the code to make it appear past them?

Please do advice if you see I am not doing things in a right manner.

-Pam

.



Relevant Pages

  • Re: beginner 2185 error & focus
    ... So I'm sure your advice works - it may be that when I was trying it at first ... one can not write to a textbox from within the If/Then with Access as that is ... As a result, the Text property applies only to the control that has focus, ... The button click kicks off a variety of calcs and I want to write a ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to do this
    ... Is the ControlSource for the textbox ... change it as per Marsh's advice. ... try changing the ControlSource for the textbox to something like ... "Tom" wrote in message ...
    (microsoft.public.access.formscoding)
  • Re: VBA Userform Textbox re-writing cells in Excel
    ... I got it to work with your advice after an undue amount of poking ... >> the textbox properties? ... > Excel Blog - Daily Dose of Excel ...
    (microsoft.public.excel.programming)
  • Re: How long before the "pump" becomes permanent?
    ... JohnW wrote: ... Newbie question! ... someone can offer advice? ... After I workout, I get the usual "pumped up" effect. ...
    (uk.rec.bodybuilding)
  • Re: Error handling.
    ... You can test the textbox date with something like ... fError = False ... > I would like some general advice on error handling please. ... > tests for a multiuser workbook being open. ...
    (microsoft.public.excel.programming)