Web Service Basics

Web Service Basics: Access in webapp and windows app


Step1. Create Blank website
Add new item
select webservice
get .asmx page and vb file in App_code folder
make ur webservice methods

To get detail run the asmx file.

1 ############# Access web service in other webapplication ###########

Step2 Create another blank website
Add webreference in other website.
It ask for url.
get ur localhost url of webservice application created in step1.
it will create App_WebReferences folder and a wsdl file having detail of webservice
Now you can access the webservice in vb code


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim w As New localhost.WebService
        Response.Write(w.HelloWorld)

    End Sub



2#############To access webservice in standalone application we need dll.######
To Do this:

convert asmx file to vb file

open vs command prompt

>cd /d D:\vin\WebService

(wsdl language /n:reference url)

>wsdl /l:vb /n:localhost  http://localhost:54316/WebService/WebService.asmx

Now convert vb file to dll file

>vbc /t:library /r:System.Web.dll /r:System.Web.Services.dll WebService.vb

it will create the dll


Open a new windows apllication

Add reference > Browse > get that dll

Add 2 more dll from Add reference > .Net
System.Web
System.Web.Services

use in ur vb code


Imports localhost


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim ws As New WebService
        MsgBox(ws.HelloWorld)

    End Sub

Comments