Deserialize Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wervis
    New Member
    • Jan 2007
    • 7

    #1

    Deserialize Problem

    I want to deserialize a SOAP Header Element to a class using:

    Code:
    XmlSerializer serializer = new XmlSerializer( typeof(Context));
    Context context = serializer.Deserialize(new StringReader.xmlElementOuterXml))
    When the code is executed a get an exception 'There is an error in XML document (1, 2).'

    The XmlElement from the SOAPHeader:
    Code:
    <Context CompanyName="Wervis Personeelsadvies en Automatisering" ProductSerial="00000000-0000-0000-0000-000000000005" xmlns="http://www.product.nl/" />
    The Context Class:
    Code:
    using System;
    using System.Web.Services.Protocols;
    
    namespace Wervis.Product.Dto
    {
        public class UserContext
        {
            private string companyName;
            private String productSerial;
    
            public string CompanyName
            {
                get { return companyName; }
                set { companyName = value; }
            }
    
            public string ProductSerial
            {
                get { return productSerial; }
                set { productSerial = value; }
            }
        }
    }
    I don't know what is going wrong. Can someone help me out here please?
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Welcome to TheScripts TSDN...

    Please post your XML document or structure with data.

    Comment

    • wervis
      New Member
      • Jan 2007
      • 7

      #3
      Originally posted by dorinbogdan
      Welcome to TheScripts TSDN...

      Please post your XML document or structure with data.
      [CODE=xml]<?xml version="1.0" encoding="utf-8" standalone="yes "?>
      <soap:Envelop e xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
      <soap:Header>
      <Context CompanyName="We rvis Personeelsadvie s en Automatisering" ProductSerial=" 00000000-0000-0000-0000-000000000005" xmlns="http://www.product.nl/" />
      </soap:Header>
      <soap:Body>
      <CheckLicenseBy SerialNumber xmlns="http://www.product.nl/">
      <checkLicenseRe quest>
      <CompanyName>We rvis Personeelsadvie s en Automatisering</CompanyName>
      <SerialNumber>0 0000000-0000-0000-0000-000000000005</SerialNumber>
      </checkLicenseReq uest>
      </CheckLicenseByS erialNumber>
      </soap:Body>
      </soap:Envelope>[/CODE]

      Comment

      • dorinbogdan
        Recognized Expert Contributor
        • Feb 2007
        • 839

        #4
        Originally posted by wervis
        The Context Class:
        Code:
        ...
                private string companyName;
                private String productSerial;
        ...
        Until new answers come, try to use string instead of String, to be consistent with the property data type.

        Comment

        • dorinbogdan
          Recognized Expert Contributor
          • Feb 2007
          • 839

          #5
          I will copy the thread to the .Net forum too.

          Comment

          Working...