Talk, talk and more talk about BizTalk

Mocking an Http Request-Respose port

I occasionally want to be able to mock a Request-Response port, inthe event the target database is down, or I’m working locally.

The following ASP.NET snippet will allow me to point a two-way Send port at a local ASP.NET page, and gives me complete control over the mocked data I send back:

protected void Page_Load(object sender, EventArgs e)

String req = new System.IO.StreamReader(Request.InputStream).ReadToEnd();


FileStream outputFile = File.OpenRead(@”c:\temp\HttpListener\COPA_extract.xml”);

string extract = new StreamReader(outputFile).ReadToEnd();

//Write out the string to Response


// Need to call Response.End() or we get the standard Http DOCTYPE tags, etc




July 29, 2009 - Posted by | BizTalk | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: