1
코드 구성에서 끝점 헤더를 설정하는 코드은 무엇입니까?코드에서 wcf 엔드 포인트 헤더 설정
<client>
<endpoint address="http://localhost/..." >
<headers>
<something>blah</something>
</headers>
</endpoint>
코드 구성에서 끝점 헤더를 설정하는 코드은 무엇입니까?코드에서 wcf 엔드 포인트 헤더 설정
<client>
<endpoint address="http://localhost/..." >
<headers>
<something>blah</something>
</headers>
</endpoint>
이 작동 :
var header = MessageHeader.CreateHeader("something", "", "blah");
using (new OperationContextScope(channel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(header);
//your normal call here
}
새로운 OperationContextScope를 만들고 헤더를 클라이언트가 EndpointAddress를 만들 때 헤더를 지정하는 것입니다 사용할 때마다 설정이 필요하지 않습니다 대안. (https://stackoverflow.com/a/5340009/35233 각색)
예
var binding = new WSHttpBinding();
var address = new EndpointAddress (
new Uri (RemoteAddress),
new AddressHeader[] {
AddressHeader.CreateAddressHeader ("APIKey", "", "bda11d91-7ade-4da1-855d-24adfe39d174")
});
var client = new ExampleClient (binding, address);
현재의 동작 상황에있을 필요없이 클라이언트 또는 ChannelFactory에 미리 이들에 할당하는 방법이 있는가? – kappasims