In order to invoke a service that requires WS-Addressing from WCF you'll have to configure the client endpoint to use a binding that supports it, such as the WSHttpBinding.
You can then set the wsa:ReplyTo
header to a specific URL in your client code through the OperationContext.OutgoingMessageHeaders property:
using (new OperationContextScope((IContextChannel)channel))
{
OperationContext.Current.OutgoingMessageHeaders.ReplyTo =
new EndpointAddress("http://client/callback");
channel.DoSomething();
}
In this example we are setting the wsa:ReplyTo
header to a known URL where the client channel listens for incoming callback messages from the service.
Alternatively, if the service supports it, you could use the WSDualHttpBinding, which has built in support for duplex communication through WS-Addressing. In this case you would set the callback address through the WSDualHttpBinding.ClientBaseAddress property:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding clientBaseAddress="http://client/callback" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://server/service"
binding="wsDualHttpBinding"
contract="Namespace.Service" />
</client>
</system.serviceModel>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…