sql2005建webservice及在vs2005中的应用
sql2005创建webservice
CREATE ENDPOINT mymusic
state=started
as http(
path='/sql/music',
AUTHENTICATION=(INTEGRATED),
ports=(clear)
)
for soap(
WebMethod 'mymusic'(
FORMAT=ROWSETS_ONLY,
SCHEMA =STANDARD ,
name='cm_text.dbo.getgs' --cm_text为数据库名getgs为存储过程
),
wsdl=default,
database='cm_text',
namespace='http://mysite.org/'
)
vs2005中应用
首先进行WEB引用,此处为music
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
vs2005中应用
首先进行WEB引用,此处为music
1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
using music;
12
using System.Net;
13
using System.IO;
14
using System.Text;
15![](/Images/OutliningIndicators/None.gif)
16
public partial class Default2 : System.Web.UI.Page
17
{
18
public ListBox catalogListBox;
19
public string ad="";
20
protected void Page_Load(object sender, EventArgs e)
21
{
22
Label1.Text=User.Identity.Name;
23
Label2.Text = User.Identity.AuthenticationType;
24
music.mymusic d = new mymusic();
25
CredentialCache a = new CredentialCache();
26
a.Add(new Uri("http://192.168.20.216"), "NTLM", new NetworkCredential("administrator", "密码")); //此处用的是NTLM登陆方式
27
d.Credentials = a.GetCredential(new Uri("http://192.168.20.216"),"NTLM");
28
GridView1.DataSource = d.Callmymusic();
29
GridView1.DataBind();
30
}
31
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)