473,785 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"
elementFormDefa ult="qualified" xmlns="http://xyz.com/TaskResponse/1.0"
xmlns:mstns="ht tp://xyz.com/TaskResponse/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="Result">
<xs:sequence>
<xs:any minOccurs="1" maxOccurs="unbo unded" />
</xs:sequence>
<xs:attribute name="TaskNumbe r" type="xs:int" use="required" />
</xs:complexType>
<xs:element name="Response" >
<xs:complexType >
<xs:sequence>
<xs:element name="Result" type="Result"
maxOccurs="unbo unded" 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.406 07.85.

'

'''<remarks/>

<System.Seriali zableAttribute( ), _
System.Xml.Seri alization.XmlTy peAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0"), _
System.Xml.Seri alization.XmlRo otAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0", IsNullable:=fal se)> _

Public Class Response

Private resultField() As Result

'''<remarks/>

<System.Xml.Ser ialization.XmlE lementAttribute ("Result")> _

Public Property Result() As Result()

Get

Return Me.resultField

End Get

Set

Me.resultField = value

End Set

End Property

End Class

'''<remarks/>

<System.Seriali zableAttribute( ), _
System.Xml.Seri alization.XmlTy peAttribute([Namespace]:="http://xyz.com/TaskResponse/1.0")> _

Public Class Result

Private anyField() As System.Xml.XmlE lement

Private taskNumberField As Integer

'''<remarks/>

<System.Xml.Ser ialization.XmlA nyElementAttrib ute()> _

Public Property Any() As System.Xml.XmlE lement()

Get

Return Me.anyField

End Get

Set

Me.anyField = value

End Set

End Property

'''<remarks/>

<System.Xml.Ser ialization.XmlA ttributeAttribu te()> _

Public Property TaskNumber() As Integer

Get

Return Me.taskNumberFi eld

End Get

Set

Me.taskNumberFi eld = 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 1707

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

Similar topics

0
2857
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> <ws:Username>test_case_user6</wsse:Username> <ws:Password>password</wsse:Password> </ws:UsernameToken> </ws:Security>
6
8348
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 the dreaded <elementname xmlns=''> was not expected exception. If I comment out the XmlTypeAttribute, it works just fine. Just so you know, when I instantiate an instance of an XmlSerializer, I pass a default namespace to the ctor. ...
0
1439
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
1358
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 there a way to do this in C#? Also can I include other namespaces in this declaration as well?
1
1321
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 has B's node, and no exception was catched,and instance of B has been constructed,but has no data . thanks for any help
0
2802
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) that i need to create for this post. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
1
3168
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 RFCSendingValue. There the attribute 'groupeid0 isn't generated in the SOAP request.
2
5064
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 wsdl.exe. I've immediately run up against the same problem that spawned the original, deeply fascinating code. I can make a request, and Fiddler shows that the service is returning a valid response, but the client is returning a null object....
2
6536
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 created. Public Class UserControl1 end class. Can open file in designer and see user Control on which I can place other
0
9645
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
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
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
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.