首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.NET WSE3.0的替代方案

.NET WSE3.0的替代方案
EN

Stack Overflow用户
提问于 2010-09-10 08:11:40
回答 2查看 747关注 0票数 0

我正在使用.NET 2.0。除了.NET WSE3.0,还有其他的选择吗?

是否可以在soap头中传递用户名和密码,而不需要任何工具包,只需使用代码?

谢谢

EN

回答 2

Stack Overflow用户

发布于 2010-09-10 08:37:51

(这个建议可能很离谱,因为我不确定您是指某些特殊的WS.*标题,还是任何自定义的标题.我从未听说过WSE)

我按如下方式调用具有用户/传递头的webservice。这不是生产代码,但是代码段应该说明这一点。

客户机上的

代码语言:javascript
复制
string userName = "someusername";
string password = "somepass";

//create the custom header object
MyService.AuthHeader authHeader = new MyService.AuthHeader();
authHeader.UserName = userName;
authHeader.Password = password;

//create the WS-proxy
MyService.SomeWebservice someWS = new MyService.SomeWebservice();
//set headers
someWS.AuthHeaderValue = authHeader;
someWS.SomeMethod();

webservice:

代码语言:javascript
复制
public class SomeWebservice : System.Web.Services.WebService
{
    public AuthHeader Authentication = null; //For receiving the authentication header from the SOAP client (you will never assign this property in user code, .NET handles the plumbing based on the [SoapHeader("Authentication")] attribute

    [WebMethod(Description = "Some webservice method")]
    [SoapHeader("Authentication")]
    public void SomeMethod()
    {
        string suppliedUserName = Authentication.UserName;
        string suppliedPassword = Authentication.Password;
    }
}

AuthHeader类:(定义在"WS端“)

代码语言:javascript
复制
public class AuthHeader : SoapHeader
{
    public string UserName = null;
    public string Password = null;
}
票数 1
EN

Stack Overflow用户

发布于 2010-09-10 11:17:50

可以使用SOAP扩展(包括所需的SOAP头)更改SOAP消息

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3683094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档