Está en la página 1de 7

ASP.

NET - DEMO WEB_SERVICE


V d 1: To 1 website cung cp 1 webservice n gin thc hin tnh tng hiu 2 s nguyn To 1 website cha 1 trang web gi webservice to. I. Chun b

II. Thc hin B1: To website cung cp webservice : - File, New Website, chn ASP.NET Web Service, t tn WS01 chng hn

Lu hnh ni b

Trang 1

Vit code thm 2 phng thc trong webservice

Thc thi chy WebService va to = F5

Lu hnh ni b

Trang 2

Nhp vo lin kt Service Description trn trang web, hin th trang m t dch v

Sao chp a ch trn Address Bar ghi nh sau ny gi. V d nh trn l http://localhost:1584/WS02/Service.asmx?WSDL B2: To website cha trang gi webservice to t website trn: - File, New Website, chn ASP.NET Web Site, t tn TestWS01 chng hn

Lu hnh ni b

Trang 3

Khai bo tham chiu n a ch cha Webservice [menu] Website, Add Service Reference

Nu ng xut hin trong khung Solution Explorer

Lu hnh ni b

Trang 4

Trong trang aspx dng test ta to giao din n gin nh sau:

Vit code cho Button gi webservice nh sau

Nhn F5 chy th.

V d 2: To 1 website cung cp 1 webservice n gin thc hin cung cp t gi ngoi t so vi tin ng vit nam. To 1 website cha 1 trang web gi webservice to.

I. Chun b Trong database, to table tigia nh sau:

Lu hnh ni b

Trang 5

II. Thc hin B1: To website cung cp webservice : - File, New Website, chn ASP.NET Web Service, t tn WS02 chng hn

Vit code thm 1 phng thc trong webservice

Thc thi chy WebService va to = F5 Nhp vo lin kt Service Description trn trang web, hin th trang m t dch v Sao chp a ch trn Address Bar ghi nh sau ny gi. V d nh trn l http://localhost:1584/WS02/WebService2.asmx?WSDL

Lu hnh ni b

Trang 6

B2: To website cha trang gi webservice to t website trn: - File, New Website, chn ASP.NET Web Site, t tn TestWS02 chng hn

Khai bo tham chiu n a ch cha Webservice [menu] Website, Add Service Reference dn a ch ghi nh vo, nhp Go , ri OK Trong trang aspx dng test ta to giao din n gin nh sau:

Vit code cho Button gi webservice nh sau

Nhn F5 chy th. Lu hnh ni b Trang 7

Calificar