I've want to add specific custom headers on my wsdl for incoming soap message so i've added the required tags into the header node of the web.config like below:
<headers>
<Tag>Value</Tag>
</headers>
However, this works fine if the 'Value' in the custom tag is set to 'Value' when I change this value the service kicks it out giving the below error;
'DestinationUnreachable - The message with To 'http://localhost:3537/Service1.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.'
So how can I specify variable values for the actual value in between the tags?? like in url templates i.e.
<headers>
<Tag>{variable value here}</Tag>
</headers>
Any ideas, or am I going about custom headers the wrong way? I don't want to use a messageContract as we use RPC style soap over document style.
Also another curious thing is that for the message to be valid the custom defined in the header element must specify a 'IsReferenceParameter="true"' attribute with a ws-addressing namespace otherwise it throws the above error?
<Tag a:IsReferenceParameter="true">Value</Tag>
Can anyone explain this to me?
Thanks in advance
Jon
I can't really explain the concrete question you have - but typically, you would add custom headers to WCF calls in code, often using a behavior, rather than from web.config. Not sure if that even works, really.
What your custom headers behavior could do, of course, is read its values that it'll send from a config file or a database table or something else.
But if you really want to enforce the SOAP headers in your messages, I think your best bet would really be to use message contracts. Why is it you can't or don't want to use message contracts?? That's really the sole purpose of message contracts: defining the explicit SOAP message layout, including custom headers.
See some articles and blog posts on the topic:
This blog post here show how to inject custom SOAP headers into the WSDL being generated by implementing a custom "WsdlExporter" class - maybe that's the way to go for you?
Plenty more resources available if you just google for it - this is a very common scenario, and lots of folks have already implemented it in a great number of ways, with some ingenious solutions, and blogged about it - you should have no trouble finding all the answers out there!
Marc