使用用户名和密码肥皂请求的WCF身份验证

时间:2018-11-15 06:56:00

标签: wcf wcf-binding wcf-security

我想使用用户名和密码对WCF服务上的请求进行身份验证 收到的请求肥皂标头将是这样, 我应该如何配置wcf服务以检查数据库中的此用户名和密码。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ns="http://schemas.datacontract.org/2004/07/">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:UsernameToken wsu:Id="UsernameToken-2">
            <wsse:Username></wsse:Username>
            <wsse:Password></wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <tem:RequestForCustomsExemption>
            <customsExemptionRequest>
                <BILL_NUMBER>12583603</BILL_NUMBER>
            </customsExemptionRequest>
        </tem:RequestForCustomsExemption>
    </soapenv:Body>
</soapenv:Envelope>

1 个答案:

答案 0 :(得分:0)

您将需要使用Custom UsernamePasswordValidator扩展名。本文应该包含您需要的所有信息:How to: Use a Custom User Name and Password Validator