Vishal Modi


  Home  |   Contact  |   Syndication    |   Login
  45 Posts | 0 Stories | 95 Comments | 0 Trackbacks


Tag Cloud

Article Categories


Image Galleries




Hi there,


Today we will be doing a quick little test to send a XML message to BizTalk with few lines of code. I had a scenario in my solution in which I had a WCF LOB Outbound Adapter which was doing some work and later the same code had to submit message back to BizTalk. First solution I thought of was writing the message to a File Location and than a BizTalk Receive Location picks it up from there and processes it. But then came up with a different solution of using WCF netPipe and submitting it directly to BizTalk.


Anyways, I created a small Console App which just take a XML from a file location (which in my code was the WCF Outbound Adapter forming this XML message) and then send to BizTalk and there is a Send Port putting this message out to another file location. Below are the steps.


·         Create a new Console Application.                                                                               


·         Add reference to the following assemblies

o   System.Runtime.Serialization

o   Sytem.ServiceModel


·         Below is the piece of code which does the work.


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

using System.ServiceModel.Channels;

using System.Xml;

using System.IO;


namespace TestConsole


    public class SendBizTalk



        private interface IBizTalkSubmission


            [OperationContract(Action = "*", ReplyAction = "*")]

            void Submit(Message msg);



        static void Main(string[] args)


            XmlTextReader xmlrdr = new XmlTextReader(@"C:\Test\In\Test.xml");

            Message msg = Message.CreateMessage(MessageVersion.Default, "*", xmlrdr);


            string uriLocationEsbOnRamp = "net.pipe://localhost/SendBizTalk";

            NetNamedPipeBinding b = new NetNamedPipeBinding();

            b.Security.Mode = NetNamedPipeSecurityMode.None;

            EndpointAddress epa = new EndpointAddress(uriLocationEsbOnRamp);

            IBizTalkSubmission proxy = ChannelFactory<IBizTalkSubmission>.CreateChannel(b, epa);






·         Build the solution à Successful. Nice


·         Next thing is to configure BizTalk Receive and Send port.


·         Open BizTalk Administration Console and select the Application where you want the Receive and Send Port.


·         Next create a new Receive Port name TestRcvPort and a Receive Location for it name TestRcvLocation.  


·         For the Receive Location select the Type as “WCF-NetNamePipe” and in than click Configure.


·         For the Address URI copy the URI which you specified in the Code.  There is a very cool thing about this, you can fetch this URI from SSO Config also. I will show this in my next blog. But for now let hard code it. "net.pipe://localhost/SendBizTalk". 


·         Nothing to be changed in the Binding Tab. Next is the Security Tab, by default it would be Transport, so change it to None.


IMPORTANT:  If you have Security set to None, then you code should also reflect the same security configuration. Like in the code above you can see the following line which sets the security as none.


NetNamedPipeBinding b = new NetNamedPipeBinding();

b.Security.Mode = NetNamedPipeSecurityMode.None;


·         Nothing to be changed in the Messages tab. Select the Receive Pipeline you want to use. For this test App I have PassThruReceive. You can use your own custom Pipeline or use ESB pipelines and then complete ESB stuff i.e. XMLDissembler, BRE, Maps etc etc but for now lets keep it simple.


·         Next to create a Send Port named “TestSndPort”. Select the Type as File and Configure it to point to some file location.


·         In the Filer tab select the BTS.ReceivePortName == TestRcvPort


·         Start/Enable the Receive Location and Send Port. Put a test message you want to test at C:\Test\In\Test.xml location. Run the Console app and check the output for the Send Port. Success….!!!!!


·         Total time of creating the app with the same piece of code and using any xml à around 5 mins.


·         Time for entire code to run with simple BizTalk artifacts à Fraction of Second.











posted on Friday, January 29, 2010 6:31 PM


# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 6/3/2010 8:35 PM radha
thank you but can i use the same to send over a HTTP .I want to send a multipart/form data through HTTP.Can I use the above with slight modification?

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 6/4/2010 1:38 AM Vishal Mody
Yes Sir. You can use any WCF binding to send the message over to BizTalk. WSHttpBinding, BasicHTTPBinding, netTCPBinding etc.


Vishal Mody

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 9/7/2011 7:44 AM dev
Thanks for this article. it helped me a lot. I have a question here. how do we pass user name and password in the above mentioned article. Please let me know.

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 5/7/2012 11:46 AM Corey Gleisner
Is there a way to make this work from a Restful service instead of a console app? I am trying to send a document to BizTalk from a Rest Service and I get the following error:
{"ExceptionType":"System.ServiceModel.EndpointNotFoundException","InnerException":{"ExceptionType":"System.IO.PipeException","Message":"The pipe endpoint 'net.pipe:\/\/localhost\/SendBizTalk' could not be found on your local machine. "},"Message":"There was no endpoint listening at net.pipe:\/\/localhost\/SendBizTalk that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.","StackTrace":"\u000d\u000aServer stack trace: \u000d\u000a at System.ServiceModel.Channels.PipeConnectionInitiator.GetPipeName(Uri uri)\u000d\u000a at System.ServiceModel.Channels.NamedPipeConnectionPoolRegistry.NamedPipeConnectionPool.GetPoolKey(EndpointAddress address, Uri via)\u000d\u000a at System.ServiceModel.Channels.CommunicationPool`2.TakeConnection(EndpointAddress address, Uri via, TimeSpan timeout, TKey& key)\u000d\u000a at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)\u000d\u000a at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\u000d\u000a at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\u000d\u000a at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\u000d\u000a\u000d\u000aException rethrown at [0]: \u000d\u000a at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\u000d\u000a at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\u000d\u000a at cattails.Services.RestfulServices.XMLDocuments.Controllers.ValuesController.IBizTalkSubmission.Submit(Message msg)\u000d\u000a at cattails.Services.RestfulServices.XMLDocuments.Controllers.ValuesController.Post(XmlDocument xmlDoc) in C:\\sandbox\\apps\\Lakeview Cloverleaf\\cattails.Services.RestfulServices\\cattails.Services.RestfulServices.XMLDocuments\\Controllers\\ValuesController.cs:line 47\u000d\u000a at lambda_method(Closure , Object , Object[] )\u000d\u000a at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass9.<GetExecutor>b__8(Object instance, Object[] methodParameters)\u000d\u000a at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\u000d\u000a at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments)\u000d\u000a at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0()\u000d\u000a at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}

Any ideas?

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 5/7/2012 1:23 PM Vishal Mody
@Corey Gleisner
I dont see it should be any issue to send the message though RESTFul service either as that small piece of code can be put in kind of app/service.
Make sure you have the bizTalk Recieve location enabled and listening for the messages from the service.
make sure you have the correct URI and binding configured in the code and same one for the Receive Port.


# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 5/7/2012 2:59 PM Corey Gleisner
I tried to be very careful and follow the example you had provided above. I created a receive port and receive location in the BizTalk admin console that matches the URI in the Rest service. I am attempting to run this on a Windows 7 VM, I don't know if that would make a difference.

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 5/7/2012 3:51 PM Vishal Mody
I dont think Window7 should be any problem if you have IIS and everything else configured properly.
Can you get the sample working with either a console or WinApp working. Once thats successful, try same code in the RESTful service and you should be good.


# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 5/9/2012 11:15 AM Corey Gleisner
I was able to get a message across to Biztalk. It turned out to be an issue with the host instance. Have you worked with Fiddler at all? I am having an issue with the Rest service where I attempt to send some xml to the URI through Fiddler. I have a breakpoint set and when I check the variable it shows as null. Ideas?

# re: Send Message to BizTalk Receive Location with few lines of C# code through WCF-NetNamedPipe as Transport Type 6/5/2012 3:29 PM Corey Gleisner
In the code when the message is created with Message.CreateMessage I noticed that it adds <string xmlns=""> to the actual message.
Is there anyway to avoid this? I only want to send Biztalk the incoming message.

Post A Comment