簡體   English   中英

客戶端身份驗證方案“匿名”未授權HTTP請求。 從服務器收到的身份驗證標頭為“基本”

[英]The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic

**當我嘗試在身份驗證中使用用戶名和密碼來調用Web服務時,會給我401(身份驗證錯誤),而Soap UI仍在使用該服務。 我的示例代碼和web.config供參考,供參考在Soap UI中,我正在屬性中傳遞密碼和用戶名。 **

ExternalTransferInRequest requestbody = new ExternalTransferInRequest();
    requestbody.referenceTxnId = 123456789101112131;
    requestbody.userName = "5F4aS7QIfS32A4qlCP0BlaEX4qi+lV0p";
    requestbody.password = "1kZ+ZKKNe6zRqot9Qels1g==";
    requestbody.deviceType = 9;
    requestbody.amount = "5000";
    requestbody.mobileAccountNumber = "33319015910";
    requestbody.bankName = "00–Ubank";
    requestbody.bankAccountNumber = "051000207960141";
    ExternalTransferInRequest1 request = new ExternalTransferInRequest1();
    ExternalTransferInResponse resposebody = new ExternalTransferInResponse();
    ExternalTransferInResponse1 response = new ExternalTransferInResponse1();
    //Customer_PortClient proxy = new Customer_PortClient();
    ThirdPartyServicesMiddleWareSoapPortClient c = new ThirdPartyServicesMiddleWareSoapPortClient();
    ThirdPartyServicesMiddleWareSoapPort ts = c;
    c.ClientCredentials.UserName.UserName = "*************";
    c.ClientCredentials.UserName.Password = "********";
    //c.ClientCredentials.UserName.UserName = "smw.tp_services_pibas";
    //c.ClientCredentials.UserName.Password = "Sybase@365";

    response = ts.ExternalTransferIn(request);
    resposebody = response.ExternalTransferInResponse; 

Web.config文件

 <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="ThirdPartyServicesMiddleWareSoapPortSoap11" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
      textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
      messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="Basic" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://**********:8083/mobiliser/thirdpartymw"
    binding="basicHttpBinding" bindingConfiguration="ThirdPartyServicesMiddleWareSoapPortSoap11"
    contract="TransferInSAP.ThirdPartyServicesMiddleWareSoapPort"
    name="ThirdPartyServicesMiddleWareSoapPortSoap11" />
</client>

我通過使用以下web.config配置解決了此問題

  <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic" proxyCredentialType="None" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM