Neuron ESB User Network

The Service Bus for the Connected Business

Custom Service Endpoint headers (similar to adding a wcf behavior)

Greetings,

 

I need to add a custom header to my service endpoint.  I saw the api call to add a custom header (

AddCustomHeader) to the service connection, however, it seems to require that the value be the same 
for the life of the connection.  Is there a way (similar to adding a wcf behavior) to change the value 
per call as opposed to keeping the same value for the life of the connection?

        Client<T> svc = new Client<T>();
svc.AddCustomHeader("name", "namespace", "value");


Alternatively, I tried using the address from the neuron discovered client connector to construct a channel 
using the ChannelFactory and adding a custom behavior, but the headers seem to be stripped and not
passed on to the service connector.


   scf = new ChannelFactory<T>(new WSHttpBinding(SecurityMode.None, false), svc.Address);
scf.Endpoint.Behaviors.Add(new OriginationIdBehavior());
serviceConnection = scf.CreateChannel();

     Client<T> svc = new Client<T>();

Everything works if I don't use the bus to transport the message to the service address, but using Neuron, 
the headers are removed.

Thanks for your help,

Dave

Views: 67

Reply to This

Replies to This Discussion

Hi Dave,

 

you just have to make sure that you check the "Capture custom headers" check box on the Client Connector, and then check the "Restore custom headers" checkbox on the service connectors.  That way custom headers will flow through the bus without issue.

 

Kind regards,

 

Marty

Think I found it.  

 

On the Client Connector: Capture Custom Headers

On the Service Connector: Restore Custom Headers

 

:)

Hi Dave,

 

Also, I'm not sure if the AddCustomHeader() method will work for you even if you enable the custom headers.  However, this will work:

 


public

{

 

 

 

{

 

static void ClientTSendRequestByServiceNameAddHeaders()XmlReader xmlReader = null;Message reqMsg = null;using (Client/font>IRequestChannel> client = new Client/font>IRequestChannel>("PublicHRService"))// get the custom soap header

System.Xml.

 

{

 

{

 

XmlDocument doc = GetCustomSoapHeader();using (xmlReader = CreateMessage(_msg))using (reqMsg = Message.CreateMessage(MessageVersion.Default, "V2", xmlReader))// add custom headers to define services for scatter gather patter

 

reqMsg.Headers.Add(header);

 

reqMsg.Close();

}

xmlReader.Close();

}

}

}

MessageHeader header = MessageHeader.CreateHeader(_propName, _ns, doc.OuterXml);Console.WriteLine(client.Proxy.Request(reqMsg).ToString());

 Hi Dave,



Also, I'm not sure if the AddCustomHeader() method will work for you even if you enable the custom headers. However, this will work:


public static void ClientTSendRequestByServiceNameAddHeaders()
{
XmlReader xmlReader = null;
Message reqMsg = null;

using (Client<IRequestChannel> client = new Client<IRequestChannel>("PublicHRService"))
{
// get the custom soap header
System.Xml.XmlDocument doc = GetCustomSoapHeader();

using (xmlReader = CreateMessage(_msg))
{
using (reqMsg = Message.CreateMessage(MessageVersion.Default, "V2", xmlReader))
{
// add custom headers to define services for scatter gather patter
MessageHeader header = MessageHeader.CreateHeader(_propName, _ns, doc.OuterXml);
reqMsg.Headers.Add(header);

Console.WriteLine(client.Proxy.Request(reqMsg).ToString());
reqMsg.Close();
}
xmlReader.Close();
}
}
}

 Hi Dave,



Also, I'm not sure if the AddCustomHeader() method will work for you even if you enable the custom headers. However, this will work:


public static void ClientTSendRequestByServiceNameAddHeaders()
{
XmlReader xmlReader = null;
Message reqMsg = null;

using (Client<IRequestChannel> client = new Client<IRequestChannel>("PublicHRService"))
{
// get the custom soap header
System.Xml.XmlDocument doc = GetCustomSoapHeader();

using (xmlReader = CreateMessage(_msg))
{
using (reqMsg = Message.CreateMessage(MessageVersion.Default, "V2", xmlReader))
{
// add custom headers to define services for scatter gather patter
MessageHeader header = MessageHeader.CreateHeader(_propName, _ns, doc.OuterXml);
reqMsg.Headers.Add(header);

Console.WriteLine(client.Proxy.Request(reqMsg).ToString());
reqMsg.Close();
}
xmlReader.Close();
}
}
}

RSS

Neuron ESB Product Support Forums and Communities

Latest Activity

Nick Novotny posted a discussion

Script to stop/restart service connectors

Is there a way to turn on and off service connectors through the neuron api?  Right now I need to go to Endpoint Health in Activity, and right click to stop and restart service connectors, I would like to have a script to do this.  Is this possible? Thanks,-Nick NSee More
May 11
Profile Iconsuresh datla and Mahboob joined Neuron ESB User Network
Apr 24
Nick Novotny posted a discussion

Msmq network transport error logging

We have multi-casting one way messaging through a remote msmq server using wcf services for our system. One day one of our many environments got a message to multicast…and didn’t send anything out.  We have a pipeline step to audit the incoming message, topic properties to move msmq messages to a dead letter queue after a specific amount of time, and a service policy to move messages to the failed neuron db table after a specific amount of time/retries (matching the msmq network properties to…See More
Apr 13
Stas Makutin posted a discussion

Load-balancing using Neuron

I want to implement following scenario using Neuron ESB:- get big list of working items from somewhere (let's say some database)- split this list to small "batches" of working items- send these batches each to particular instance of specific subscriber (Worker), so each that instance will process assigned batch in parallel with other instances- collect feedback (is processing complete/failed) + implement some fail-over mechanism (resend failed batches, monitor if batches weren't processed…See More
Apr 11
Profile IconStas Makutin, Bjorn Thomsen and Steve Harclerode joined Neuron ESB User Network
Apr 11
MH is now a member of Neuron ESB User Network
Mar 29
Profile IconCraig Muir and mehnaz joined Neuron ESB User Network
Mar 12
John Ryan posted a discussion

Trouble creating a net.msmq Client Connector

Has anyone successfully created a Client Connector using Net.msmq?I'm trying as many different configurations as i can to post a message to a Client Connector but i get the following error on my client app:"The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state."It looks as though my client connector endpoint is not binding to the WAS correctly.If anyone has any ideas, i'd love to hear them.Here are my Client…See More
Mar 6

Badge

Loading…

© 2012   Created by Neuron Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service