<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://tempuri.org/"
xmlns:types="http://tempuri.org/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="unt_PQxtsT0a8iV1KN2Y">
<wsse:Username></wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">i03CXze0uiIYG8+q8MhEMYHiMcL/NOpCwvEVpQ5xo+M=</wsse:Nonce>
<wsu:Created>2012-04-25T22:59:23Z</wsu:Created>
</wsse:UsernameToken>
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2012-04-25T22:59:23Z</wsu:Created>
<wsu:Expires>2012-04-25T22:60:23Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>客户端代码:
MessageServiceWse client = new MessageServiceWse();
UsernameToken usernameToken = new UsernameToken(token.Username, token.Password, PasswordOption.SendPlainText);
client.RequestSoapContext.Security.Tokens.Add(usernameToken);
client.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;Client.SomeMethod(请求);
这是我在VS2010中安装和使用WSE 3.0时,在太多的噪音之后设法创建的漂亮的soap安全头。但是,我调用这个web服务(我不能控制它)的地狱还在继续,虽然一切看起来都很好,但我无法解决最后一个问题。
如果你注意到请求头,你可以看到一切看起来都很好,除了我传递的用户名和密码不在那里!
有没有人遇到过类似的情况?
谢谢。
发布于 2012-05-02 06:35:40
不确定你是否仍然有这个问题,但是你可以尝试这样的东西吗?我不知道你为什么要从token对象中获取用户名/密码。它是客户端需要提供给服务的东西。
UsernameToken token = new UsernameToken("myusername", "mypwd", PasswordOption.SendPlainText );
client.SetClientCredential(token);
client.SetPolicy("ClientPolicy");https://stackoverflow.com/questions/10323800
复制相似问题