开发者

Alternative to .NET WSE 3.0

I'm using .NET 2.0. There are any alternative to .NET WSE 3.0?

Is it possible to 开发者_如何转开发pass username and password in soap header without any toolkit, only using code?

Thanks


(This suggestion might be way off, since I'm not sure if you mean some special WS.* headers, or just any custom header... and I've never heard of WSE)

I call a webservice with user/pass in a header as follows. It's not production code, but the snippets should illustrate it.

On the client:

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();

The webservice:

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;
    }
}

The AuthHeader class: (defined at the "WS end")

public class AuthHeader : SoapHeader
{
    public string UserName = null;
    public string Password = null;
}


It's possible to alter the SOAP Message using SOAP Extensions including the required SOAP Header

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜