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: 1313

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

Anupama Nair posted a discussion

Marketo Adapter Invalid Token

Hi,We are using the Marketo adapter to push account updates to Marketo. It works well for some time then starts failing with Invalid Token unless restarted. Is there a configuration that can be done so it can auto refresh the token when required?Thanks!See More
Nov 6, 2023
Sayantini Basak posted a discussion

Maximum payload size(REST API) for requests interfacing to NeuronESB

I am new to Neuron ESB and in our current scenario,We need to process batch transactions comprising of ~1000 records and send them to Neuron ESB for further processing. I would like to understand what is the maximum size of payload that can be transferred using REST interface to Neuron ESB.See More
Jul 22, 2022
Profile IconRobert E Dunie and Sayantini Basak joined Neuron ESB User Network
Apr 28, 2022
Profile IconDayanand, Frederic C, Steffen Greve-Oksfeldt and 1 more joined Neuron ESB User Network
Mar 16, 2022
Profile IconCam Vong and Mitja Luznar joined Neuron ESB User Network
Jan 27, 2022
Profile IconWill Hitzges, Chad Parsons, michael larsen and 4 more joined Neuron ESB User Network
Jun 11, 2021
Anupama Nair posted a discussion

ODBC stored proc polling with temporary tables

We have set up an ODBC adapter to poll a stored proc.We found that if the stored proc has a temporary table defined the rows returned are always 0.Any idea why this would be and what we can do to get around it?See More
Dec 14, 2020
Prasanth Kharade is now a member of Neuron ESB User Network
Dec 30, 2019

Badge

Loading…

© 2024   Created by Neuron Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service