Ejemplo sobre cómo utilizar un web service, desde una aplicación para móviles, en .net.
- Instalar el "Mobile Internet Toolkit" para Visual Studio .NET
- Instalar emulador de aplicación móvil.
1.) Crear proyecto "Mobile Web Application"
2.) Agregar controles móviles TextBox y Command.
3.) Agregar "Web Reference" al webservice http://localhost/WorkShopUDP_v1/mensaje1.asmx
Cambiar el nombre del directorio "localhost" a "wsSaludos"en el "Solution Explorer".
- En el código del Mobile Web Form, importar el espacio de nombres asociado al webservice.
Imports MobileWebWSSaludo.wsSaludos
- En el código del botón, instanciar un objeto de la clase "Saludo", invocar la función "HelloWorld" asignando el resultado al TextBox1.
Dim objWsSaludo As New Saludo()
TextBox1.Text = objWsSaludo.HelloWorld
Imports MobileWebWSSaludo.wsSaludos
Public Class MobileWebForm1
Inherits System.Web.UI.MobileControls.MobilePage
Protected WithEvents Command1 As System.Web.UI.MobileControls.Command
Protected WithEvents TextBox1 As System.Web.UI.MobileControls.TextBox
Protected WithEvents Form1 As System.Web.UI.MobileControls.Form
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
Dim objWsSaludo As New Saludo()
TextBox1.Text = objWsSaludo.HelloWorld
End Sub
End Class
Construyendo la solución (Build).
Abrir el emulador abriendo la dirección de la página Mobiul Web Form.
- Instalar emulador de aplicación móvil.
1.) Crear proyecto "Mobile Web Application"

2.) Agregar controles móviles TextBox y Command.

3.) Agregar "Web Reference" al webservice http://localhost/WorkShopUDP_v1/mensaje1.asmx

Cambiar el nombre del directorio "localhost" a "wsSaludos"en el "Solution Explorer".

- En el código del Mobile Web Form, importar el espacio de nombres asociado al webservice.
Imports MobileWebWSSaludo.wsSaludos
- En el código del botón, instanciar un objeto de la clase "Saludo", invocar la función "HelloWorld" asignando el resultado al TextBox1.
Dim objWsSaludo As New Saludo()
TextBox1.Text = objWsSaludo.HelloWorld
Imports MobileWebWSSaludo.wsSaludos
Public Class MobileWebForm1
Inherits System.Web.UI.MobileControls.MobilePage
Protected WithEvents Command1 As System.Web.UI.MobileControls.Command
Protected WithEvents TextBox1 As System.Web.UI.MobileControls.TextBox
Protected WithEvents Form1 As System.Web.UI.MobileControls.Form
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
Dim objWsSaludo As New Saludo()
TextBox1.Text = objWsSaludo.HelloWorld
End Sub
End Class
Construyendo la solución (Build).
Abrir el emulador abriendo la dirección de la página Mobiul Web Form.

Benjamín González C.
Ingeniero de Sistemas