Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created December 10, 2017 12:47
Show Gist options
  • Save justinyoo/dc7a6911de595db7f8d2453955354bd8 to your computer and use it in GitHub Desktop.
Save justinyoo/dc7a6911de595db7f8d2453955354bd8 to your computer and use it in GitHub Desktop.
SOAP over Azure API Management, Logic Apps and Functions
public static class WcfCallingHttpTrigger
{
[FunctionName("WcfCallingHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "data/{value}")] HttpRequestMessage req,
int value,
TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// Instantiates the binding object.
// Depending on the security definition, the security mode should be adjusted.
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
// If necessary, appropriate client credential type should be set.
//binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
// Instantiates the endpoint address.
var endpoint = new EndpointAddress(Config.WcfServiceEndpoint);
using (var client = new Service1Client(binding, endpoint))
{
// If necessary, username and password should be provided.
//client.ClientCredentials.UserName.UserName = "username";
//client.ClientCredentials.UserName.Password = "password";
var result = await client.GetDataAsync(value).ConfigureAwait(false);
log.Info($"{result} received.");
return req.CreateResponse(HttpStatusCode.OK, result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment