Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. WCF custom headers in .NET CF

WCF custom headers in .NET CF

Scheduled Pinned Locked Moved WCF and WF
csharpsecuritywcfhelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koleraba
    wrote on last edited by
    #1

    Hello I created a WCF service, which has a single endpoint and uses BasicHttpBinding, so it can be accessed by mobile clients. The service(for now) does not use security. I want to create an authentication mechanisem with CustomHeader-s. The client(a windows mobile device) calls a register method and adds a custom header with user credentials to the message. The service validates supplied credentials and returns a GUID - again in the CustomHeader. The problem is that I dot't know how to access the header on the client side. I tried to get header in the private TRESPONSE getResult(System.ServiceModel.Channels.Message reply, CFInvokeInfo info) where I made a call to the following method. public static string ReadHeader(Message request, XmlObjectSerializer serializer) { int headerIndex = request.Headers.FindHeader(HEADER_NAME, HEADER_NAMESPACE); if (headerIndex != -1) { XmlNode[] contentNode = request.Headers.GetHeader(headerIndex, serializer); string text = contentNode[0].InnerText; XmlSerializer deSerializer = new XmlSerializer(typeof(string)); StringReader reader = new StringReader(text); string content = (string)deSerializer.Deserialize(reader); reader.Close(); return content; } else { return null; } } The problem is in the XmlNode[] contentNode = request.Headers.GetHeader<XmlNode[]>(headerIndex, serializer);, where I get an InvalidCastException. Does anybody knows what am I doing wrong? Any ideas will be appreciated. Uros

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups