none
How can insert custom http header Date in WCF service Windows Phone? RRS feed

  • Question

  • i'm working on WCF service created with service reference on visual studio 2012 for Windows phone 8 and i need to set custom http header in all messages. I can set either the standard http headers and additional custom headers, but i can't set the header "Date". This is my code:

    HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
            httpRequestProperty.Headers["authorization"] = "WDTC64Y08CT453AA453J:SrkMQKI2lYkKPLiyIcm5X54LQgTM5DthTxk9b8JeOU8=";
            httpRequestProperty.Headers[System.Net.HttpRequestHeader.Date] = "Thu, 31 May 2007 20:35:00 GMT";
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

    When i send the message, i check the packet with wireshark and i don't see the header http Date. The strange is if i set "Date-" in the Property , the header is in the message.

    Can anyone explain why this happends?Is it connected to the type of binding?

    More info:

    this is the servicereference file configuration:

    <configuration>
    <system.serviceModel>
       
    <bindings>
           
    <basicHttpBinding>
               
    <binding name="credentialServiceSoapBinding" maxBufferSize="2147483647"
                   
    maxReceivedMessageSize="2147483647">
                   
    <security mode="None" />
               
    </binding>
           
    </basicHttpBinding>
       
    </bindings>
       
    <client>
           
    <endpoint address="http://*************.*****.it/api/services/credentialService/"
               
    binding="basicHttpBinding" bindingConfiguration="credentialServiceSoapBinding"
               
    contract="CredentialService.CredentialService" name="CredentialServicePort" />
       
    </client>
    </system.serviceModel>

    Tuesday, March 26, 2013 11:30 AM

Answers

  • Hi, I afraid you cannot set this manually, the Date header specifies the date and time at which the request originated.

    http://msdn.microsoft.com/en-us/library/system.net.httprequestheader(v=vs.100).aspx

    Thursday, March 28, 2013 5:54 AM