WSE 3.0创建用户名令牌,但用户名和密码的值是空的(WSE 3.0 creates the Us

2019-10-16 15:53发布

<?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(请求);

这美丽的肥皂安全头,我设法噪音太大后创建安装,并于2010 VS但在使用WSE 3.0,我调用这个Web服务(我不控制)的地狱还在继续,而wverything看上去都不错,我通过这最后一个问题不能得到。

如果在请求头注意到,你可以看到这一切看起来不错,但,兴田的用户名和密码,我通过不存在的!

任何人都遇到过类似的情况?

谢谢。

Answer 1:

不知道如果你仍然有这个问题,但是你能尝试这样的事情? 我不知道你为什么想从令牌对象的用户名/密码。 它是什么,客户需要提供的服务。

UsernameToken token = new UsernameToken("myusername", "mypwd", PasswordOption.SendPlainText );

client.SetClientCredential(token);
client.SetPolicy("ClientPolicy");


文章来源: WSE 3.0 creates the UsernameToken but Username and Password values are empty