【问题标题】:the HTTP request is unauthorized with client authentication scheme 'Anonymous'HTTP 请求未经客户端身份验证方案“匿名”授权
【发布时间】:2012-07-04 03:15:05
【问题描述】:

我使用 firstdata 网络服务 API。我使用带有 WCF 的 C# 客户端调用 firstdata webservice API。

但显示错误消息:

 "System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client 

authentication scheme 'Anonymous'. The authentication header received from the server was ''. ---> System.Net.WebException: 

The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at  System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End 

of inner exception stack trace --- Server stack trace: at 

System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, 

WebException responseException, HttpChannelFactory factory) at 

 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding) at 

System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at 

System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at 

System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at 

System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] 

ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 

methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage 

retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at 

com.firstdata.globalgatewaye4.api.ServiceSoap.SendAndCommit(SendAndCommitRequest request) at 

com.firstdata.globalgatewaye4.api.ServiceSoapClient.com.firstdata.globalgatewaye4.api.ServiceSoap.SendAndCommit

(SendAndCommitRequest request) at com.firstdata.globalgatewaye4.api.ServiceSoapClient.SendAndCommit(Transaction 

SendAndCommitSource)"

我的 web.config 信息如下:

<behaviors>
        <endpointBehaviors>
            <behavior name="FDGGBehavior">
                <clientCredentials>
                    <clientCertificate  findValue="WS1909642825._.1"  storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="TrustedPeople" />
                    <serviceCertificate>
                        <authentication certificateValidationMode="PeerTrust" />
                    </serviceCertificate>
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
<binding name="ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
             receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
             bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
             maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
             messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
             useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                 maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="Certificate" proxyCredentialType="Ntlm" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
<endpoint address="https://api.globalgatewaye4.firstdata.com/transaction/v11"
         binding="basicHttpBinding" bindingConfiguration="ServiceSoap"
         contract="com.firstdata.globalgatewaye4.api.ServiceSoap" name="ServiceSoap"  behaviorConfiguration="FDGGBehavior" />

如何解决问题?

【问题讨论】:

    标签: authentication anonymous firstdata


    【解决方案1】:

    遇到了同样的问题。 请检查您是否使用了正确的 GatewayID 和 Password。请注意,您需要在生成密码后点击更新按钮。 我也不使用行为配置

    <behaviors>
         <endpointBehaviors>
             <behavior name="FDGGBehavior">
                 <clientCredentials>
                     <clientCertificate  findValue="WS1909642825._.1"  
                         storeLocation="LocalMachine" 
                         x509FindType="FindBySubjectName"
                         storeName="TrustedPeople" />
                     <serviceCertificate>
                         <authentication certificateValidationMode="PeerTrust" />
                     </serviceCertificate>
                 </clientCredentials>
             </behavior>
         </endpointBehaviors>
     </behaviors>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 1970-01-01
      相关资源
      最近更新 更多