Attempting to use a SoapClient like a HttpClient. I work in multiple different languages, so I apologize if my code examples flipflop between vb.net and c#.
The reason I need to target a specific IP is that I have multiple servers and want to test them individually.
This code works for the HttpClient.
private HttpClient request = new HttpClient() { DefaultRequestHeaders = { Host = "abc.google.com" } };
HttpResponseMessage responseFromApi = request.GetAsync(new Uri($"https://{server.IpAddress}/health/healthcheck.html")).ConfigureAwait(false).GetAwaiter().GetResult();
I have a SoapEndpoint that I added through the Visual Studio Service References (WSDL). I'd like to still be able to target certain IP's. This code does not work. Any suggestions?
Dim wsRate As RateUtilitySoapClient = New RateUtilitySoapClient()
Dim addressHeader = Channels.AddressHeader.CreateAddressHeader("Host", "", tbEndPoint.Text)
Dim endpoint = New EndpointAddress(New Uri(String.Format("http://{0}/SoapEndpoint.asmx", IPToTarget)), New AddressHeader() {addressHeader})
wsRate.Endpoint.Address = endpoint