473,382 Members | 1,377 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,382 software developers and data experts.

Missing namespace in XML serialization

We have the following XML schema: there's a root element (Response) with of a
single child element (Result).
----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TaskRequest"
targetNamespace="http://xyz.com/TaskResponse/1.0"
elementFormDefault="qualified" xmlns="http://xyz.com/TaskResponse/1.0"
xmlns:mstns="http://xyz.com/TaskResponse/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Result">
<xs:sequence>
<xs:any minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="TaskNumber" type="xs:int" use="required" />
</xs:complexType>
<xs:element name="Response">
<xs:complexType>
<xs:sequence>
<xs:element name="Result" type="Result"
maxOccurs="unbounded" minOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
----------------------------------------------------------------------------------------------

We generated a VB wrapper class of this schema using the XSD.exe tool:

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

'

'This source code was auto-generated by xsd, Version=2.0.40607.85.

'

'''<remarks/>

<System.SerializableAttribute(), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0"), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0", IsNullable:=false)> _

Public Class Response

Private resultField() As Result

'''<remarks/>

<System.Xml.Serialization.XmlElementAttribute("Res ult")> _

Public Property Result() As Result()

Get

Return Me.resultField

End Get

Set

Me.resultField = value

End Set

End Property

End Class

'''<remarks/>

<System.SerializableAttribute(), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0")> _

Public Class Result

Private anyField() As System.Xml.XmlElement

Private taskNumberField As Integer

'''<remarks/>

<System.Xml.Serialization.XmlAnyElementAttribute() > _

Public Property Any() As System.Xml.XmlElement()

Get

Return Me.anyField

End Get

Set

Me.anyField = value

End Set

End Property

'''<remarks/>

<System.Xml.Serialization.XmlAttributeAttribute( )> _

Public Property TaskNumber() As Integer

Get

Return Me.taskNumberField

End Get

Set

Me.taskNumberField = value

End Set

End Property

End Class

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

Note that the namespace http://xyz.com/TaskResponse/1.0 is correctly applied
to both classes Response and Result.

Serializing an instance of Response class (defined as root element in the
schema) we can obtain an XML document that correctly shows the namespace
http://xyz.com/TaskResponse/1.0.

Serializing an instance of the Result class (defined as child element in the
schema) the namespace is missing from generated XML document.

Why does the namespace is not declared in the xml file resulting form the
Result serialization?
Thanks for the help!
Nov 12 '05 #1
0 1668

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

Similar topics

0
by: T | last post by:
I want to use the XmlSerializer to let .NET do the serialization for me to produce the following XML: <ws:Security xmlns:ws="http://schemas.xmlsoap.org/ws/2002/07/secext"> <ws:UsernameToken>...
6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
0
by: Peter Theill | last post by:
Hi, I'm having an issue with deserializing some xml using a proxy class generated by "xsd.exe". My proxy class contains this class definition: public class IqProfileType {
1
by: MattBell | last post by:
I have a root node attribute which contains a name space declaration. I'd like to put a reference onto the front of it (ie: ns1:RootNode) where ns1 is defined as the namespace I'm using. Is...
1
by: saliwen | last post by:
hi,all I'v gotten a problerm of deserializing xml to object.the scene is: I generated the classes using xsd tools including a class A and sub-class B, then I deserialize from XmlNodeReader only...
0
by: richwangler | last post by:
This problem should be easily reproducable if anybody has the time. I need to build the following XML programatically and decided to use the XMLSerializer. I simplified the XML (myExample.xml)...
1
by: Eric | last post by:
Hi, I have a WS client. All the code is generated by VS.NET 2003. For me its seems that an attribute is not generated during sending the request in the SOAPHeader. The problem is with...
2
by: Pathogenix | last post by:
Greetings, I'm trying to fix a web service client which has been implemented in a dailywtf worthy manner. I've decided to rip all the old code out and start again from the proxy generated by...
2
by: Bob | last post by:
Just new at this, Vs 2005 Vb.net Created a new Windows control library User control project. Only 1 file UserControl1.vb No code or object in it at all yet except what was placed by default when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.