I have a web API API method that calls an external REST API service using HttpClient. The results of an external REST call are then passed to the WCF service through a call to its proxy.
If I first call the WCF proxy and then call the external REST service, everything works as expected. If I reverse the order of the calls, the WCF proxy call fails because the InnerChannel (m_inner_channel = m_channel_factory.CreateChannel ()) in the proxy object is null.
Here is an example for illustrative purposes:
user = await m_http_client.GetProfileAsync(id).ConfigureAwait(false);
using (WCFServiceProxy wcf_proxy = new WCFServiceProxy())
{
config = await wcf_proxy.GetConfigAsync(user.ssid).ConfigureAwait(false);
}
The above code works, however, if I implement the code below the WCF InnerChannel proxy (m_inner_channel = m_channel_factory.CreateChannel ()) is null when I make a service call:
//Instantiate WCF Proxy - Creates ChannelFactory
WCFServiceProxy wcf_proxy = new WCFServiceProxy()
//Call to external REST Service (works)
user = await m_http_client.GetProfileAsync(id).ConfigureAwait(false);
//Call to WCF Service (InnerChannel is no longer instantiated)
config = await wcf_service.GetConfigAsync(user.ssid).ConfigureAwait(false);
, , :
//Instantiate WCF Service
WCFServiceProxy wcf_proxy = new WCFServiceProxy()
//Call to WCF Service (works)
config = await wcf_service.GetConfigAsync("2423432").ConfigureAwait(false);
//Call to external REST Service (works)
user = await m_http_client.GetProfileAsync(id).ConfigureAwait(false);
- , ? , ConfigureAwait true, .
Web API, - WCF , - , - WCF.
/ .
,