473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Deserialize Problem

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

Expand|Select|Wrap|Line Numbers
  1. XmlSerializer serializer = new XmlSerializer( typeof(Context));
  2. 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:
Expand|Select|Wrap|Line Numbers
  1. <Context CompanyName="Wervis Personeelsadvies en Automatisering" ProductSerial="00000000-0000-0000-0000-000000000005" xmlns="http://www.product.nl/" />
The Context Class:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Web.Services.Protocols;
  3.  
  4. namespace Wervis.Product.Dto
  5. {
  6.     public class UserContext
  7.     {
  8.         private string companyName;
  9.         private String productSerial;
  10.  
  11.         public string CompanyName
  12.         {
  13.             get { return companyName; }
  14.             set { companyName = value; }
  15.         }
  16.  
  17.         public string ProductSerial
  18.         {
  19.             get { return productSerial; }
  20.             set { productSerial = value; }
  21.         }
  22.     }
  23. }
I don't know what is going wrong. Can someone help me out here please?
May 17 '07 #1
4 1552
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN...

Please post your XML document or structure with data.
May 17 '07 #2
wervis
7
Welcome to TheScripts TSDN...

Please post your XML document or structure with data.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  2. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  3.     <soap:Header>
  4.         <Context CompanyName="Wervis Personeelsadvies en Automatisering" ProductSerial="00000000-0000-0000-0000-000000000005" xmlns="http://www.product.nl/" />
  5.     </soap:Header>
  6.     <soap:Body>
  7.         <CheckLicenseBySerialNumber xmlns="http://www.product.nl/">
  8.             <checkLicenseRequest>
  9.                 <CompanyName>Wervis Personeelsadvies en Automatisering</CompanyName>
  10.                 <SerialNumber>00000000-0000-0000-0000-000000000005</SerialNumber>
  11.             </checkLicenseRequest>
  12.         </CheckLicenseBySerialNumber>
  13.     </soap:Body>
  14. </soap:Envelope>
May 17 '07 #3
dorinbogdan
839 Expert 512MB
The Context Class:
Expand|Select|Wrap|Line Numbers
  1. ...
  2.         private string companyName;
  3.         private String productSerial;
  4. ...
  5.  
Until new answers come, try to use string instead of String, to be consistent with the property data type.
May 17 '07 #4
dorinbogdan
839 Expert 512MB
I will copy the thread to the .Net forum too.
May 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Carl Mercier | last post by:
Hi! I have 2 different applications/assembly. The first one creates an object and serializes it to a textfile on disk. The second one has the the exact same class (copied/pasted). It reads...
3
by: Amsteel | last post by:
I got something like this in VB.Net <Serializable()> Public Class YQProfileC Inherits CollectionBase Public Sub Save2File(ByVal FileName As String) Dim IFormatter As New BinaryFormatter() Dim...
2
by: PCH | last post by:
I have 2 functions, one to serialize an object, and one to deserialize it. I can serialize just fine, the problem is when I try to deserialize it later... I get an error: {"Invalid...
2
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
1
by: Pavel Pavel | last post by:
I have 2 solution to deserialize ArrayList which contains objects I am using for this MemoryStream, but MemoryStream is not functional - I receive always error #End of Stream encountered before...
4
by: Samuel R. Neff | last post by:
I'm deserializing an XML file. If I pass a Stream to the file directly to the deserializer as follows it works fine: o = (New XmlSerializer( GetType(...
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
1
by: Heron | last post by:
Hi, I'm having a problem deserializing my streams since they are utf8 encoded (they are being received over tcp/ip) so I was looking for a way to make the serializer use utf8, is there any? ...
11
by: wpmccormick | last post by:
I've a complex problem: I'm deserializing a very long string of XML into a very large object foo: <foo> ....... <bar>sometimes a simple string is here</bar> ....... </foo>
0
by: connectpalm03-forum | last post by:
I have a class named (MyClassA) in ControlClasses.dll and was able to serialize it to database. Like below SaveTo(MemoryStream stream) { IFormatter formatter = new BinaryFormatter(); ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.