title: The HTTP request was forbidden with client authentication scheme 'Anonymous' when making http request via service reference
body: <p>I am doing a paygate integration (<a href="https://www.paygate.co.za" rel="nofollow noreferrer">https://www.paygate.co.za</a>), but when I attempt to make a call via the Payhost service reference, it appears that something is blocking my request?</p>
  <hr />
  <p>Here is the exception</p>
  <pre><code>System.ServiceModel.Security.MessageSecurityException: **The HTTP request was forbidden with client authentication scheme 'Anonymous'.**
     at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
     at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.&lt;&gt;c__DisplayClass1_0.&lt;CreateGenericTask&gt;b__0(IAsyncResult asyncResult)
  </code></pre>
  <hr />
  <p>Here is my code (you can run this in a console app) the credentials for the API below are public information on the paygate API. I also want to point out that I have used and tested the below code in the past so I doubt its a code issue:</p>
  <pre><code>using PayHOSTService; //https://secure.paygate.co.za/payhost/process.trans?wsdl
  try {
    PayGateAccountType PaygateAccount = new PayGateAccountType();
    PaygateAccount.PayGateId = &quot;10011072130&quot;; //Public Test Credentials
    PaygateAccount.Password = &quot;secret&quot;; //Public Test Credentials
  
    OrderType OrderType = new OrderType();
    OrderType.Amount = Convert.ToInt32(50 * 100);
    OrderType.Currency = CurrencyType.ZAR;
    OrderType.MerchantOrderId = &quot;TestOrder&quot;;
    OrderType.TransactionDate = DateTime.Now;
    OrderType.Locale = &quot;en-za&quot;;
  
    PersonType User = new PersonType();
    User.FirstName = &quot;name&quot;;
    User.LastName = &quot;Surname&quot;;
    User.Email = new string[1];
    User.Email[0] = &quot;avalidemail@gmail.com&quot;;
  
    AddressType Address = new AddressType();
    Address.AddressLine = new string[1];
    Address.Country = CountryType.ZAF;
    Address.CountrySpecified = true;
    User.Address = Address;
  
    BillingDetailsType BillingDetails = new BillingDetailsType();
    BillingDetails.Address = Address;
    BillingDetails.Customer = User;
    OrderType.BillingDetails = BillingDetails;
  
    RedirectRequestType Redirect = new RedirectRequestType();
    Redirect.ReturnUrl = &quot;http://localhost:44337/Payment/ReturnClient&quot;;
    Redirect.NotifyUrl = &quot;http://localhost:44337/Payment/Notify&quot;;
    WebPaymentRequestType WebPaymentRequest = new WebPaymentRequestType();
    WebPaymentRequest.Account = PaygateAccount;
    WebPaymentRequest.Order = OrderType;
    WebPaymentRequest.Customer = User;
    WebPaymentRequest.Redirect = Redirect;
    WebPaymentRequest.PaymentType = new PaymentType[1];
  
    SinglePaymentRequest Request = new SinglePaymentRequest();
    Request.Item = WebPaymentRequest;
  
    //The request is sent here
    PayHOSTClient PayhostClient = new PayHOSTClient();
    SinglePaymentResponse1 Response = await PayhostClient.SinglePaymentAsync(Request);
    WebPaymentResponseType WebPaymentResponse =
      (WebPaymentResponseType) Response.SinglePaymentResponse.Item;
  
    Console.Write(WebPaymentResponse);
  } catch (Exception Ex) {
    Console.Write(Ex);
  }
  
  Console.ReadKey();
  </code></pre>
  <hr />
  <p>What I have tried:</p>
  <ul>
  <li>I have tried to run this on Mac (macOS Monterey) and Windows (11)</li>
  <li>I have tried the code in a console app (.net 6 (also tried .NET Framework 4.7.2)) and in an MVC project (.net core 3.1)</li>
  <li>I have tried this on 2 different networks (home and mobile)</li>
  </ul>
  <p>What is the issue?</p>