473,795 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a way to set a namespace prefix using XmlSerializer

T
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:UsernameTok en>
<ws:Username>te st_case_user6</wsse:Username>
<ws:Password>pa ssword</wsse:Password>
</ws:UsernameToke n>
</ws:Security>

Is there any way, maybe through class and member attributes or
properties in the XmlSerializer, to be able to tell the XmlSerializer
to include the "ws:" prefix when it serializes the following classes?

/// <remarks/>
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://schemas.xmlsoap .org/ws/2002/07/secext")]
[System.Xml.Seri alization.XmlRo otAttribute("Se curity",
Namespace="http ://schemas.xmlsoap .org/ws/2002/07/secext",
IsNullable=fals e)]
public class Security {

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "UsernameToken" )]
public SecurityUsernam eToken[] Items;
}

/// <remarks/>
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://schemas.xmlsoap .org/ws/2002/07/secext")]
public class SecurityUsernam eToken {

/// <remarks/>
public string Username;

/// <remarks/>
public string Password;
}
Nov 12 '05 #1
0 2857

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

Similar topics

0
1530
by: siddharthkhare | last post by:
HiAll, i am having hard time serializing a object in a specific xml.I need to feed it to a biztalk port. i Have a root object(c# class) 'CTSCServiceOrder'. When i serilize it using a xml serializer following is the out put. <?xml version="1.0"?>
4
2630
by: Hollywood | last post by:
I'm using XML serialization to produce the following XML document: <TestDoc xmlns:srd="some-url"> <Additional> <Security> <srd:Login>login_id</srd:Login> <srd:Password>password</srd:Password> </Security> </Additional> </TestDoc>
4
12169
by: AP | last post by:
Hi, I have a class that I wish to serialize to XML, part of which looks like this: public class TitleNotification { public string NoNameSpaceSchemaLocation = http://www.pdr.com\nhttps://extw3c.pdr.com/prism/b2b/schemas/TitleNotification.xsd;
1
5922
by: Bill Geake | last post by:
I am successfully serializing to XML from a class like this: private static void CreateXML() { testClass c = new testClass(); c.stringElement = "data1"; c.stringElement2 = "data2"; subClassDataType s = new subClassDataType(); s.subThingElement1 = "data3";
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?
0
2803
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"...
2
21646
by: scottpet | last post by:
Hi, I want to add a namespace prefix to the root node of an object I am serializing to XML. I have been reading though this article: http://msdn2.microsoft.com/en-gb/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx I get namespace prefixes in the document, but not on the root node. Specifically, the serializer does not work as described in the last
9
6483
by: Mark Olbert | last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified, and the default namespace needs to be included on it as an attribute. The schema I'm using is this: <xs:schema xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40"...
2
2339
by: bmomalley | last post by:
Hi Folks, I need help, because I am just at a loss. I'm not super comfortable with XML, but I'm trying to fight my way through generating an RSS XML file for Google Base, and I'm stuck with a Namespace issue. How can I get XmlSerializer to generate the standard RSS tags with no prefix, but ensure that the Google specific tags a prefixed with "g:"? Here's a sample of the code I'm using, and it puts g: in front of ALL
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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
10165
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
10002
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
7543
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
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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...
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
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.