没那么复杂吧
IIS站点里做一个web Service
客户端引用这个web Service
在web Service中实现一个方法 bool DelFile(string FilePath) 客户端调用.. web service 最后做标头验证.
IIS站点里做一个web Service
客户端引用这个web Service
在web Service中实现一个方法 bool DelFile(string FilePath) 客户端调用.. web service 最后做标头验证.
给一篇孟子的文章
你也许有用
http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
谢谢各位:不过首先强调的是我用的客户端是winform的。Firestone2003(笨笨小猪) 提供的是Asp页面上删除的功能。我在服务器端建立了webSevice,但我现在还不知道具体的服务器的IP地址呢?无法在客户端引用web引用。还请各位高手赐教。
//使用 Soap 标头自定义身份验证和授权
public class AuthHeader : SoapHeader
{
public string Username;
public string Password;
}
[WebService(Namespace="http://www.disku.net/service")]
public class DirInfo : System.Web.Services.WebService
{ private DataSet UserHtmlDefault = null;
string StrHtml="";
public AuthHeader sHeader;
public DirInfo()
{
InitializeComponent();
}private bool AuthenticateUser(string usr, string pwd)
{
if ((usr == "xxxxxx")&&(pwd =="xxxxx"))
{
return true;
}
return false;
}
[WebMethod(Description="删除用户目录")]
[SoapHeader("sHeader")]//应用标头
public void Del(string FilePath)
{
//删除操作
}}
SoapHeader需要引入
System.Web.Services.Protocols;
通过IDE添加web引用后会自动生成一个AuthHeader类如果命名空间为xxxx xxxx.mywebservice hp=new xxxx.mywebservice();
hp.Url="http://"+server+"/service.asmx";
xxxx.AuthHeader myHeader=new xxxx.AuthHeader();
myHeader.Username = "xxxxx";
myHeader.Password = "xxxxx";
hp.AuthHeaderValue=myHeader; 验证代码 ,这样你就可以通过 hp.Del(路径) 来删除文件了