GVCLC Custom WCF Adapter-Part 2

Posted: November 24, 2012  |  Categories: BizTalk

Ahmed posted a comment to http://connectedpawns.wordpress.com/2011/01/31/the-gvclc-adapter-my-first-wcflob-adapter/

“Hi,

I tried to create a adapter to connect ISO switch using TCP/IP protocol, this is the same as you project here. but i could not make it work. Can you share the code for your adapter with out your business logic? i just want to see how you handle socket connection and how receiving part is taking place from WCF LOB adapter.

Thanks,”

I meant to post something more about my experiences. So here goes.

TryReceive  method

This first method in the Inbound Handler calls Stephenson’s socket library

// call socket library to get data

this.Connection.Client.SendData(pollMessage);

string pollMessageResponse = this.Connection.Client.ReceiveData();

returnValue = createGVCLCMessage(pollMessageResponse, out message); //test to see have to do something

this.Connection.isWaiting4BTSResponse = returnValue; // If we have to do something the polling loop stops while we wait for a response from BizTalk

A “polling loop” encapsulates this code snippet in the same way as the Microsoft WCF SQL adapter.

Reply Method

Secondly the Inbound Handler handles the response message from BizTalk. Finally this sends the response back to the socket using Stephenson’s library.

//Test for two actions. The first action is the default if you create a test client using adding addservice reference

//The second one is the default if you use the Consume WCF wizard from a BizTalk project

if (message.Headers.Action == “GVCLC/OnReceiveGVCLC/response” || message.Headers.Action == “GVCLC/OnReceiveGVCLCResponse”)

{

try

{

string input = message.GetBody<OnReceiveGVCLCResponse>().ToString();

//send it back to the socket

this._con.Client.SendData(input);

}

catch (Exception ex)

{

throw;

}

finally

{

this._con.isWaiting4BTSResponse = false; // Start the polling the socket for requests again

}

}

BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top