Hello NIST IZ Team,
I am integrating with the NIST IZ Tool IISService endpoint and running into a difference between using a WCF client proxy and a raw HttpClient SOAP call.
Environment:
WCF Proxy Code (Startup.cs):
services.AddSingleton(provider =>
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls13;
var binding = new CustomBinding(
new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8),
new HttpsTransportBindingElement()
{
MaxReceivedMessageSize = 20000000,
AllowCookies = true
});
var endpoint = new EndpointAddress("https://hl7v2-iz-r1-5-testing.nist.gov/iztool/ws/iisService");
return new IISServiceClient(binding, endpoint);
});
Controller Method (using proxy):
[HttpPost("ConnectivityTest")]
public ActionResult<ConnectivityTestResponse> ConnectivityTest()
{
try
{
var request = new ConnectivityTestRequest { echoBack = "Hello NIST" };
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls13;
var response = _iisServiceClient.connectivityTest(request);
Console.WriteLine($"Response: {response?.@return}");
return Ok(response);
}
catch (Exception ex)
{
return BadRequest(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
}
}
Error Returned:
This is often caused by an incorrect address or SOAP action.'
BUT
Raw HttpClient SOAP Call (works fine, returns 200):
[HttpGet]
public async Task<ActionResult<string>> Get()
{
var soapEnvelope = @"<?xml version=""1.0"" encoding=""utf-8""?>
xmlns:urn=""urn:cdc:iisb:2011"">
<soap:Body>
<urn:connectivityTest>
<echoBack>Hello NIST</echoBack>
</urn:connectivityTest>
</soap:Body>
</soap:Envelope>";
using var client = new HttpClient();
var content = new StringContent(soapEnvelope, Encoding.UTF8, "application/soap+xml");
var response = await client.PostAsync(
return Ok(response.IsSuccessStatusCode
? " Endpoint is reachable."
: " Endpoint returned an error.");
}
This returns 200 OK, so the endpoint is reachable with a raw SOAP request.
Proxy Definition:
[ServiceContract(Namespace = "urn:cdc:iisb:2011")]
public interface IIISService
{
[OperationContract(Action = "urn:cdc:iisb:2011:connectivityTest", ReplyAction = "*")]
ConnectivityTestResponse connectivityTest(ConnectivityTestRequest request);
[OperationContract(Action = "urn:cdc:iisb:2011:submitSingleMessage", ReplyAction = "*")]
SubmitSingleMessageResponse submitSingleMessage(SubmitSingleMessageRequest request);
}
public class IISServiceClient : ClientBase<IIISService>, IIISService
{
public IISServiceClient(Binding binding, EndpointAddress address) : base(binding, address) { }
public ConnectivityTestResponse connectivityTest(ConnectivityTestRequest request) =>
Channel.connectivityTest(request);
public SubmitSingleMessageResponse submitSingleMessage(SubmitSingleMessageRequest request) =>
Channel.submitSingleMessage(request);
}
[MessageContract]
public class ConnectivityTestRequest
{
[MessageBodyMember(Order = 0)]
public string echoBack { get; set; }
}
[MessageContract]
public class ConnectivityTestResponse
{
[MessageBodyMember(Order = 0)]
public string @return { get; set; }
}
Is there any possible change needed to make my current CustomBinding configuration appropriate for communicating with the IISService endpoint?