Consuming Web API with ESB Toolkit

This post describes how to implement WCF-WebHttp adapter provider.

While ESB Toolkit does not include adapter provider for WCF-WebHttp, it does work well with any BizTalk send adapter if there is a provider for it. The below code is for WCF-WebHttp adapter provider and  manifest:


namespace Samples.AdapterProviders.WcfWebHttp
{
public sealed class AdapterProvider: WCFBaseAdapterProvider
{
public override string AdapterName
{
get{ return "WCF-WebHttp”;}
}
}
}

The esb.config should be modified with new entry to register this adapter provider:


<adapterProvider moniker="Http,Https" name="WCF-WebHttp" type="Samples.AdapterProviders.WcfWebHttp.AdapterProvider, Samples.AdapterProviders.WcfWebHttp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<Your PKT>” />

For the manifest, simply create WCF-WebHttpPropertyManifest.xml, perhaps as copy of WCF-CustomPropertyManifest.xml and then add the following properties to it:

<property name="SuppressMessageBodyForHttpVerbs" type="WCF.SuppressMessageBodyForHttpVerbs" assembly="globalPropertySchemas" />
<property name="HttpMethodAndUrl" type="WCF.HttpMethodAndUrl" assembly="globalPropertySchemas" />
<property name="VariablePropertyMapping" type="WCF.VariablePropertyMapping" assembly="globalPropertySchemas" />
<property name="HttpHeaders" type="WCF.HttpHeaders" assembly="globalPropertySchemas" />
<property name="SecurityMode" type="WCF.SecurityMode" assembly="globalPropertySchemas" />
</properties>

Once this step is done, you can use resolver the designer, for example if you use PUT method with variable mapping and Json:

Action:
{Ignored}

Address:

http://localhost:5000/api/sample
HttpHeaders:

content-type:application/json

HttpMethodAndUrl:

<BtsHttpUrlMapping><Operation Url='/{APC}' Method ='PUT'/></BtsHttpUrlMapping>

ValuePropertyMapping:


<BtsVariablePropertyMapping xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<Variable Name='APC' PropertyName='RetryInterval' PropertyNamespace='http://schemas.microsoft.com/BizTalk/2003/system-properties' />
</BtsVariablePropertyMapping>