Posts

How to add soap header to WCF service call. Part 2

If you want to add to every wcf call a soap header and don't want to wrap them - you can easily implement method ApplyClientBehavior of an interface IOperationBehavior , and in this method attach your own message wrapper: clientOperation.Formatter = new MessageWrapper(clientOperation.Formatter); MessageWrapper should implement an interface IClientMessageFormatter . To add your header you have to add next code to SerializeRequest method: public Message SerializeRequest(MessageVersion messageVersion, object[] parameters) {     Message res = curFormatter.SerializeRequest(messageVersion, parameters);     if (SPContext.Current == null)     {         res.Headers.Add(MessageHeader.CreateHeader("MyTestHeader", "Test Value"));     } } Your Operation Behavior can be attached on initializing stage of your service proxy: foreach (OperationDescription operation ...

Contacts importer

I've researched a lot of public free mail services, such as gmail, hotmail, aol, rediff, mail.ru, but small part of them supports contact api. Aol has api only for authentication part and has a post of their developer dated by the end of the middle of the last year about comming soon api :). rediff and mail.ru don't provide any kind of api at all :(. So my customer are very dissapointed. But he is clever guy and didn't choose implementing logic which imitate user actions (login through the web interface). So far it is a library which supports gmail, hotmail and yahoo contact api and could be easy extended if new services appear.

How to add soap header to WCF service call. Part 1

Yeah, I've tried different solutions, spent a lot of hours and nerves. Interesting situation, when became deadline to workaround this problem - the key have been found quickly. The trick is to wrap service call with OperationContextScope and add to current operation context outgoing message a header- and that's it :). using (TestServiceClient testClient = new TestServiceClient()) {     using (OperationContextScope scope = new OperationContextScope(testClient.InnerChannel))     {         MessageHeader header = MessageHeader.CreateHeader("MyTestHeader", "", "Test Value");         OperationContext.Current.OutgoingMessageHeaders.Add(header);         testClient.DoTestCall();     } }

Next task

It seems that I must develop smth. for import contacts from most popular web mail services. Well, interesting task, will see... J

First phrase - first step

So lets blogging... :)