Test01 Go Test01 Go Test01 Lienlacschema N: Cau1: Drop Database Create Database Use Create XML Schema Collection As
Test01 Go Test01 Go Test01 Lienlacschema N: Cau1: Drop Database Create Database Use Create XML Schema Collection As
xml version="1.0" encoding="UTF-16"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="InfoContact"> <xsd:complexType> <xsd:sequence> <xsd:element name="Parents" type="xsd:string"/> <xsd:element name="Address" type="xsd:string"/> <xsd:element name="TelNumber" type="xsd:string"/> <xsd:element name="HandPhone" type="xsd:string"/> <xsd:element name="Email" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema>' Create table LienLac(maso nchar(5), Info xml (CONTENT LienLacSchema) NOT NULL,) insert into LienLac(maso,Info) values ('00002', N'<InfoContact> <Parents>Anh</Parents> <Address>Nguyen Sinh Cung, Hue</Address> <TelNumber>0123456</TelNumber> <HandPhone>0123456</HandPhone> <Email>[email protected]</Email> </InfoContact>') select Info.query('/InfoContact/HandPhone') as HandPhone from LienLac where maso ='00002' select Info.value('(/InfoContact/HandPhone)[1]','nvarchar(15)') as HandPhone from LienLac where maso ='00002' Cau2 USE master; GO Create database Test01 go ALTER DATABASE Test01 SET ENABLE_BROKER; GO USE Test01;
GO CREATE MESSAGE TYPE GuiMessage01 VALIDATION = WELL_FORMED_XML; CREATE MESSAGE TYPE NhanMessage01 VALIDATION = WELL_FORMED_XML; GO CREATE CONTRACT [DanhBa01] (GuiMessage01 SENT BY INITIATOR, NhanMessage01 SENT BY TARGET ); GO CREATE QUEUE QueueNhan01; CREATE SERVICE ServiceNhan01 ON QUEUE QueueNhan01 (DanhBa01); GO CREATE QUEUE QueueGui01; CREATE SERVICE [ServiceGui01] ON QUEUE QueueGui01; GO USE Test01; GO DECLARE @GuiDlgHandle01 UNIQUEIDENTIFIER; DECLARE @GuiMsg01 NVARCHAR(100); BEGIN TRANSACTION; BEGIN DIALOG @GuiDlgHandle01 FROM SERVICE ServiceGui01 TO SERVICE N'ServiceNhan01' ON CONTRACT DanhBa01 WITH ENCRYPTION = OFF; SELECT @GuiMsg01 = N'<RequestMsg>Thng ip gi cho ServiceNhan .</RequestMsg>'; SEND ON CONVERSATION @GuiDlgHandle01
MESSAGE TYPE [GuiMessage01] (@GuiMsg01); SELECT @GuiMsg01 AS GuiRequestMsg; COMMIT TRANSACTION; GO USE Test01; GO DECLARE @NhanReqDlgHandle01 UNIQUEIDENTIFIER; DECLARE @NhanReqMsg01 NVARCHAR(100); DECLARE @NhanReqMsgName01 sysname; BEGIN TRANSACTION; RECEIVE TOP(1) @NhanReqDlgHandle01 = conversation_handle, @NhanReqMsg01 = message_body, @NhanReqMsgName01 = message_type_name FROM QueueNhan01; SELECT @NhanReqMsg01 AS NhanRequestMsg; IF @NhanReqMsgName01 = N'GuiMessage01' BEGIN DECLARE @TraLoiMsg01 NVARCHAR(100); SELECT @TraLoiMsg01 = N'<ReplyMsg>Thng ip tr li cho ServiceGui.</ReplyMsg>'; SEND ON CONVERSATION @NhanReqDlgHandle01 MESSAGE TYPE [NhanMessage01] (@TraLoiMsg01); END END CONVERSATION @NhanReqDlgHandle01;
SELECT @TraLoiMsg01 AS GuiTrLoiMsg; COMMIT TRANSACTION; GO DECLARE @NhanReplyMsg01 NVARCHAR(100); DECLARE @NhanReplyDlgHandle01 UNIQUEIDENTIFIER; BEGIN TRANSACTION; RECEIVE TOP(1) @NhanReplyDlgHandle01 = conversation_handle, @NhanReplyMsg01 = message_body FROM QueueGui01;
Cau3: USE Test01 go drop PROCEDURE ViewMark go CREATE PROCEDURE ViewMark (@SBD int) AS BEGIN SELECT SBD, HoVaTen, DTB FROM DiemThi WHERE SBD = @SBD END go Exec ViewMark 1
sp_delete_http_namespace_reservation N'http://localhost:81/ViewMark' go sp_reserve_http_namespace N'http://localhost:81/ViewMark' go drop endpoint GetViewMarkEndPoint go CREATE ENDPOINT GetViewMarkEndPoint STATE = STARTED AS HTTP ( AUTHENTICATION = ( INTEGRATED ), PATH = '/ViewMark', PORTS = ( CLEAR ), CLEAR_PORT=81, SITE = 'localhost' ) FOR SOAP ( WEBMETHOD 'ViewMark' (NAME = 'Test01.dbo.ViewMark',SCHEMA = STANDARD), SCHEMA = STANDARD, WSDL = DEFAULT, DATABASE = 'Test01', NAMESPACE = 'http://aptech-worldwide.com/httpendpoints' ) Go
CodeFile="ViewMark.aspx.cs"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Order Details</title> </head> <body> <form id="frmViewMark" runat="server"> <div> <asp:Label ID="lblSBD" runat="server" Text="SBD:"></asp:Label> <asp:TextBox ID="txtSBD" runat="server" Width="90px"></asp:TextBox> <asp:RequiredFieldValidator ID="valSBD" runat="server" ControlToValidate="txtSBD" ErrorMessage="Enter SBD." SetFocusOnError="True"></asp:RequiredFieldValidator><br /> <br /> <br /> <asp:Button ID="btnViewMark" runat="server" Text="View mark" Width="120px" OnClick="btnViewMark_Click" /><br /> <br /> <asp:Label ID="lblTotalRecords" runat="server"></asp:Label><br /> <br /> <asp:GridView ID="gvViewMark" runat="server">
/* * ViewMark.aspx.cs * * Copyright 2008 Aptech Software Limited. All rights reserved. */ using using using using using using using using using using using System; System.Data; System.Configuration; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.SqlTypes; System.Net;
// Declares the namespace for the Web Service. using Diem; public partial class ViewMark : System.Web.UI.Page { // Sets focus on the txtProductID textbox. protected void Page_Load(object sender, EventArgs e) { SetFocus(txtSBD); } // Calls the Web method and displays data in the GridView control. protected void btnViewMark_Click(object sender, EventArgs e) { try { // Creates an instance of GetOrderDetailsEndPoint Web Service class. GetViewMarkEndPoint valViewMark = new GetViewMarkEndPoint(); // Assigns the security credentials for Web Service client authentication. valViewMark.Credentials = new NetworkCredential("lab", "abc123", "hue-aptech"); // Calls Web method. object[] objResult = valViewMark.ViewMark(SqlInt32.Parse(txtSBD.Text)); DataSet dsetViewMark = (DataSet)objResult[0];
gvViewMark.DataSource = dsetViewMark; gvViewMark.DataBind(); if (gvViewMark.Rows.Count > 0) lblTotalRecords.Text = "Total number of Orders: " + gvViewMark.Rows.Count; else lblTotalRecords.Text = "No records found."; } catch (Exception ex) { Response.Write("Error: " + ex.Message); } } }
Cau4 Thc hin theo hng dn Cu5 Thc hin theo hng dn