473,791 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML deserialization (error)


This is what I am trying to do:

FileStream fs = new FileStream("C:\ \request1.xml", FileMode.Open);
XmlSerializer x = new XmlSerializer(t ypeof(Podpisani DokumentTip));
PodpisaniDokume ntTip doc = (PodpisaniDokum entTip)x.Deseri alize(fs);

And this is my class (auto generated from WSDL):

[System.CodeDom. Compiler.Genera tedCodeAttribut e("System.Xml ",
"2.0.50727. 42")]
[System.Serializ ableAttribute()]
[System.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://www.example.org/PodpisaniDokume nt")]
public partial class PodpisaniDokume ntTip {
...
}

This is XML:

<sgn:PodpisaniD okument xmlns:sgn="http ://www.example.org/PodpisaniDokume nt">
....
</sgn:PodpisaniDo kument>

This is the error message during deserialization :

---------------------------

---------------------------
System.InvalidO perationExcepti on: <PodpisaniDokum ent
xmlns='http://www.example.org/PodpisaniDokume nt'> was not expected.
at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onReaderPodpisa niDokumentTip.R ead36_Podpisani Dokument()
---------------------------
OK
---------------------------

What is wrong?

I've found this:

http://www.dotnet247.com/247referenc...58/294121.aspx

http://www.dotnet247.com/247referenc...46/231255.aspx

but it doesn't help me. :(
Apr 11 '06 #1
1 1612

Got it! :>

I've changed this:

public partial class PodpisaniDokume ntTip {
}

into this:

[System.Xml.Seri alization.XmlRo ot("PodpisaniDo kument", Namespace =
http://www.example.org/PodpisaniDokument)]
public partial class PodpisaniDokume ntTip {
}

and it worked. :>

I hope someone else will find this useful once.
Apr 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2365
by: Serg | last post by:
Hi. I have a problem with deserialization decimal value. I have a simple class: public class A { public decimal d; } The serialization a value 0.00000001 is OK. The file is
2
2336
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc shows the example in C# (no C++ available) : >> MySerializableClass myObject;
2
9453
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and...
4
3156
by: Mike Sarbu | last post by:
Hello all, I have an XML file like this: <?xml version="1.0" encoding="utf-8"?> <SomeObject xmlns="http://www.abcinc.com/objectdefinition" xmlns:someobj=http://www.abcinc.com/objectdefinition> ...... </SomeObject>
3
9796
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
3
9796
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
1
3752
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client that accesses a Axis provided web service. The client uses the code generated, using wsdl.exe, from the wsdl file provided by the web service provider. The web response has the following schema (roughly):
0
1145
by: Miguel RS | last post by:
Hi all, I have a winforms app (app1), a webservice (ws1) and a webpage (wp1). The webservice exposes a type (type1). When I generate a proxy (px1) for app1 I get the type ws1.type1. The thing is that I want to serialize an instance of this type, pass it as a parameter to wp1 and then deserialize it. Let's say that type1 is a person´s info, containig attributes like name, age and so on and I want to show that info in the webpage. OK, the...
0
1315
by: =?Utf-8?B?UGllcmNlQnJvc25hbg==?= | last post by:
I am using C#(Vs.Net 2003) The error I am getting is... System.Xml.XmlException: This is an unexpected token. The expected token is 'EndElement' I have come to understand that this error is being caused by a character or set of characters...in the value of an xml element.
1
1378
by: Kapps | last post by:
Hi, I was wondering how I would go about deserializing a file that was serialized from a different project. I've tried a couple things, but I can't really seem to figure it out. When looking it up, it seemed like it would be solved by just including a class project that did the actual serializing and deserializing, but when I tried this, I still couldn't get it to work. I created a DLL that was referenced by both of my projects, the server...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.