1

I am consuming a SOAP Web Service through a client auto generated with the "Add Service Reference..." wizard in Visual Studio. The service is invoked like this:

//Ag stands for Augo Generated
using (AgClient client = new AgClient())
{
    AgRequest request = new AgRequest();
    request.Data = "X";
    client.Method(request);
}

XML configuration of the client binding:

<customBinding>
    <binding name="CB">
        <textMessageEncoding messageVersion="Soap11" />
        <httpTransport authenticationScheme="Basic" />
    </binding>
</customBinding>

That was fine until the service provider introduced a load balancer. The balancer sends back HTTP redirects to one of the "real" endpoints. The set of the possible addresses is fixed. In this setup request authentication fails. Investigation of the network traffic shows that when the SOAP envelope is posted a HTTP 307 Temporary Redirect is returned. The client is smart enough to issue a new request to the specified address, but fails after receiving the 401 Unauthorized response.

I would like to configure the client to send a second HTTP POST request with the Authentication header set after receiving the 401 response.

I understand that it is a security measure not to send credentials to a "random" adress returned in the 307 response by default, but in this scenario the possible redirect addresses are known in advance. How can I set up the client to behave this way?

All the similar questions are different because they all seem to operate on client objects closer to the wire, so this kind of low level setup seems more straightforward than in the generated client class. For example this is about HttpClient and this is about HttpWebRequest. How can I achive the same with the generated client?

Community
  • 1
  • 1
Hari
  • 4,514
  • 2
  • 31
  • 33
  • Why are you getting a 307 response back? Is it because the service is now hosted in a new address? In that case, wouldn't it make sense to just configure the client to go to the right address in the first place? – tomasr Feb 27 '17 at 16:11
  • Beacause this is how the load balancer works. I have edited the question. Configuring the new address is possible, but following the redirect would be better (keep in mind that 307 is a temporary redirect, configuring one of the returned addresses would be permanent) – Hari Feb 27 '17 at 17:42

0 Answers0