Die HTTP-Anforderung ist nicht autorisierte mit client-Authentifizierungsschema "Anonym". Der authentication header vom server empfangen wurde 'Basic Realm'

Ich versuche zu verbrauchen, SAP, WCF-webservice,

Habe ich diesen code:

var remoteAddress = new System.ServiceModel.EndpointAddress("https://appweb.xx.com/sap/bc/srt/wsdl/bndg_E5BBCE4ACBB46CF1A88900155D0A8410/wsdl11/allinone/ws_policy/document?sap-client=300");

                using (var cliente = new ServiceReference1.ZHRWS_GET_CERTIFICADOClient(new System.ServiceModel.BasicHttpsBinding(), remoteAddress))
                {
                     //set timeout
                    cliente.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 6000);
                    cliente.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    cliente.ClientCredentials.Windows.ClientCredential.UserName = "xx";
                    cliente.ClientCredentials.Windows.ClientCredential.Password = "xx";
                    ServiceReference1.ZhrGetCertificado cert = new ServiceReference1.ZhrGetCertificado();
                    cert.ICtflab = "1";
                    cert.IIcnum = "8026347";
                    //call web service method
                    var  response = cliente.ZhrGetCertificado(cert);
                }

und in meinem app.config habe ich dieses:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
        <bindings>
             <basicHttpBinding>
                <security mode="TransportCredentialOnly">
                      <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
                      <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>     
           </basicHttpBinding>
            <customBinding>
                <binding name="ZWSLINK">
                    <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style':    -->
                    <!--    <wsdl:binding name='ZWSLINK'>    -->
                    <!--        <wsaw:UsingAddressing xmlns:wsaw="http://schemas.xmlsoap.org/ws/2004/08/addressing">..</wsaw:UsingAddressing>    -->
                    <!--        <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer>    -->
                    <!--        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled>    -->
                    <textMessageEncoding messageVersion="Soap11" />
                    <httpsTransport authenticationScheme="Basic" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="https://appweb.xx.com/sap/bc/srt/wsdl/bndg_E5BBCE4ACBB46CF1A88900155D0A8410/wsdl11/allinone/ws_policy/document?sap-client=300"
                binding="customBinding" 
                bindingConfiguration="ZWSLINK" 
                contract="ServiceReference1.ZHRWS_GET_CERTIFICADO"
                name="ZWSLINK" />
        </client>
    </system.serviceModel>
</configuration>

Aber ich bin noch immer dieser Fehler:

Die HTTP-Anforderung ist nicht autorisierte mit client-Authentifizierungsschema "Anonym". Der authentication header vom server empfangen wurde 'Basic Realm'

InformationsquelleAutor Luis Valencia | 2016-03-28

Schreibe einen Kommentar