WSE 3.0 creates the UsernameToken but Username and Password values are empty

筅森魡賤 提交于 2020-01-07 02:58:24

问题


<?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>

Client code:

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

This the beautiful soap security header I managed to create after too much noise to install and use WSE 3.0 in VS 2010. BUT, my hell of calling this web service (which I don't control) continues, and while wverything seemed fine, I can't get through this last issue.

If you notice on the request header, you can see that everything looks good, except, hte username and password I pass are not there!!!

Anyone ever faced similar situation?

Thank you.


回答1:


Not sure if you are still having this issue, however can you try something like this ? I don't know why you are trying to get username/pwd from token object. It is something that the client needs to provide to the service.

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

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


来源:https://stackoverflow.com/questions/10323800/wse-3-0-creates-the-usernametoken-but-username-and-password-values-are-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!