locked
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="Default Realm"'. RRS feed

  • Question

  • User1326045626 posted

    Hi everybody, please help me with this problem.

    I've accessing a SOAP webservice in Java with Basic Authentication. 

    This is my code:

    SecureScannedOrderTrackingService.orderTrkg t = new TesteAcessoWebServiceOrderTracking.SecureScannedOrderTrackingService.orderTrkg();
    List<SecureScannedOrderTrackingService.orderTrkg> lista = new List<TesteAcessoWebServiceOrderTracking.SecureScannedOrderTrackingService.orderTrkg>();
    SecureScannedOrderTrackingService.ordersTrkg orders = new TesteAcessoWebServiceOrderTracking.SecureScannedOrderTrackingService.ordersTrkg();
    t.campNr = "4";
    t.campYear = "2014";
    t.collectorUser = "110016";
    t.dstrbtnCntr = "11";
    t.orderId = "407079";
    t.repNr = "7078192";
    t.trkgDateTime = "2014-04-24";
    t.trkgPoint = "";
    t.trkgStus = "15";
    t.volumeNr = "1";
    lista.Add(t);
    orders.orderTrkg = lista.ToArray();

    SecureScannedOrderTrackingService.SecureScannedOrderTrackingServiceClient ws2 = new TesteAcessoWebServiceOrderTracking.SecureScannedOrderTrackingService.SecureScannedOrderTrackingServiceClient();
    SecureScannedOrderTrackingService.generateOrderTrackingResponse r = new TesteAcessoWebServiceOrderTracking.SecureScannedOrderTrackingService.generateOrderTrackingResponse();

    ws2.ClientCredentials.UserName.UserName = "xxxxx";
    ws2.ClientCredentials.UserName.Password = "yyyyyy";

    r = ws2.generateScannedOrderTracking(orders);

    And my app.config file:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="SecureScannedOrderTrackingServicePortBinding"
    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="None">
    <transport clientCredentialType="None" proxyCredentialType="None"
    realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>
    </basicHttpBinding>
    </bindings>
    <client>
    <endpoint address="http://1.2.4.5:8080/SIRWS/services/SecureScannedOrderTrackingService"
    binding="basicHttpBinding" bindingConfiguration="SecureScannedOrderTrackingServicePortBinding"
    contract="SecureScannedOrderTrackingService.SecureScannedOrderTrackingService"
    name="SecureScannedOrderTrackingServicePort" />
    </client>
    </system.serviceModel>
    </configuration>

    And I've got this message: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="Default Realm"'.

    I tried to change <basicHttpBinding> to <wsHttpBinding>, but the server responds to use https instead of http.

    Perhaps there is a property I cannot see to setup.

    Thanks for any help.

    Tuesday, April 29, 2014 10:55 AM

Answers