473,320 Members | 2,000 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,320 software developers and data experts.

XMLSerialization - Do I need it?

LW
Hi!

I am getting the following error message for my fairly simple web service. I
have classes and have two DataSets that reference the same classes. The error
is:

The XML element named 'GetCustNoResponse' from namespace 'http://mydomain/'
references a method and a type. Change the method's message name using
WebMethodAttribute or change the type's root element using the
XmlRootAttribute.

What does this mean? I am not using any Serialization as yet but am rapidly
reading up on it as my guess is I need to use XMLSerialization or something?

LW
Oct 26 '06 #1
3 6947
Using DataSets presents complexity that is most often unneeded. And yes -
when using "native" webservices (ASMX), you are using XMLSerialization.

A better approach over DataSets is to declare your own datatypes used for
transport between Client and Server :

Example:

/// Information structure on payment.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class PaymentInfo
{
/// <summary>
/// The amount to reserve
/// </summary>
///
private float m_Amount;

/// <summary>
/// Gets or sets the amount.
/// </summary>
/// <value>The amount</value>
public float Amount
{
get { return m_Amount; }
set {

if (value <= 0)
throw new ArgumentOutOfRangeException("Amount can not be
negative nor zero");

m_Amount = value;
}
}

/// <summary>
/// Currencty used.
/// </summary>
public Currency Currency;
/// <summary>
/// the clients own private ref (should be a unique string e.g. GUID)
/// </summary>
public string CustomOrderID;
}

/// <summary>
/// Credentials used to acccess service.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class Credentials
{
/// <summary>
/// Username
/// </summary>
public string Username;
/// <summary>
/// Password
/// </summary>
public string Password;

/// <summary>
/// The instance id of the webcalling into the service.
/// </summary>
public int WebSiteInstanceID;
}
As you can see - they are quite simple classes used for communication only.
And you need to declare dem Serializable to use them (same goes with
DataSet; it is also Serializable).
--
rgds.
/Claus Konrad
"LW" wrote:
Hi!

I am getting the following error message for my fairly simple web service. I
have classes and have two DataSets that reference the same classes. The error
is:

The XML element named 'GetCustNoResponse' from namespace 'http://mydomain/'
references a method and a type. Change the method's message name using
WebMethodAttribute or change the type's root element using the
XmlRootAttribute.

What does this mean? I am not using any Serialization as yet but am rapidly
reading up on it as my guess is I need to use XMLSerialization or something?

LW
Oct 26 '06 #2
LW
Claus,

Thank you for your prompt reply. Turns out my error was due to namespace
conflict which I have resolved.

I cannot find examples of using serialization like you have on the web. I
have seen snippets here and there. I have seen examples of using
XMLSerializer Class which is different. Can you post some links? I'll look as
well. Also what if I don't use Serialization - What are the drawbacks of
that? I'll keep reading.

LW
------------------------------

"Claus Konrad" wrote:
Using DataSets presents complexity that is most often unneeded. And yes -
when using "native" webservices (ASMX), you are using XMLSerialization.

A better approach over DataSets is to declare your own datatypes used for
transport between Client and Server :

Example:

/// Information structure on payment.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class PaymentInfo
{
/// <summary>
/// The amount to reserve
/// </summary>
///
private float m_Amount;

/// <summary>
/// Gets or sets the amount.
/// </summary>
/// <value>The amount</value>
public float Amount
{
get { return m_Amount; }
set {

if (value <= 0)
throw new ArgumentOutOfRangeException("Amount can not be
negative nor zero");

m_Amount = value;
}
}

/// <summary>
/// Currencty used.
/// </summary>
public Currency Currency;
/// <summary>
/// the clients own private ref (should be a unique string e.g. GUID)
/// </summary>
public string CustomOrderID;
}

/// <summary>
/// Credentials used to acccess service.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class Credentials
{
/// <summary>
/// Username
/// </summary>
public string Username;
/// <summary>
/// Password
/// </summary>
public string Password;

/// <summary>
/// The instance id of the webcalling into the service.
/// </summary>
public int WebSiteInstanceID;
}
As you can see - they are quite simple classes used for communication only.
And you need to declare dem Serializable to use them (same goes with
DataSet; it is also Serializable).
--
rgds.
/Claus Konrad
"LW" wrote:
Hi!

I am getting the following error message for my fairly simple web service. I
have classes and have two DataSets that reference the same classes. The error
is:

The XML element named 'GetCustNoResponse' from namespace 'http://mydomain/'
references a method and a type. Change the method's message name using
WebMethodAttribute or change the type's root element using the
XmlRootAttribute.

What does this mean? I am not using any Serialization as yet but am rapidly
reading up on it as my guess is I need to use XMLSerialization or something?

LW
Oct 27 '06 #3
You will always use serialization; even without knowing it :-)
The SOAPMessage sent from the client to the server is serialized as a stream
of text (xml in this case); as well is the response from the server to the
client.
This is defined in the SOAP protocol.

So - you can not just "not" use serialization.
Using the simple constructs I presented allows you to be in complete control
of what is sent back and forth. Just for test, try experimenting with this
service:

namespace dummy
{
public interface IMyService
{
string GetResponse(InfoStructure structure);
}

[Serializable]
public class InfoStructure
{
public string SomeData;
}

public class ServiceImplementation : WebService, IMyService
{
[WebMethod()]
public string GetResponse(InfoStructure structure)
{
return structure.SomeData;
}
}

}

here you are using a class called InfoStructure to convey inforamtion from
the client to the server. It is FAR more simple than using DataSets. If you
look at the DataSet impelemtnation, you will see that it has a [Serializable]
attribute. You are merely doing the same here, adding the Serializable
attribute.

By default - that will make use of XML for serialization.
Do a Google search for these matters....
--
rgds.
/Claus Konrad
"LW" wrote:
Claus,

Thank you for your prompt reply. Turns out my error was due to namespace
conflict which I have resolved.

I cannot find examples of using serialization like you have on the web. I
have seen snippets here and there. I have seen examples of using
XMLSerializer Class which is different. Can you post some links? I'll look as
well. Also what if I don't use Serialization - What are the drawbacks of
that? I'll keep reading.

LW
------------------------------

"Claus Konrad" wrote:
Using DataSets presents complexity that is most often unneeded. And yes -
when using "native" webservices (ASMX), you are using XMLSerialization.

A better approach over DataSets is to declare your own datatypes used for
transport between Client and Server :

Example:

/// Information structure on payment.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class PaymentInfo
{
/// <summary>
/// The amount to reserve
/// </summary>
///
private float m_Amount;

/// <summary>
/// Gets or sets the amount.
/// </summary>
/// <value>The amount</value>
public float Amount
{
get { return m_Amount; }
set {

if (value <= 0)
throw new ArgumentOutOfRangeException("Amount can not be
negative nor zero");

m_Amount = value;
}
}

/// <summary>
/// Currencty used.
/// </summary>
public Currency Currency;
/// <summary>
/// the clients own private ref (should be a unique string e.g. GUID)
/// </summary>
public string CustomOrderID;
}

/// <summary>
/// Credentials used to acccess service.
/// </summary>
[Serializable]
[System.Xml.Serialization.XmlRoot(Namespace = "http://somethingUnique")]
public class Credentials
{
/// <summary>
/// Username
/// </summary>
public string Username;
/// <summary>
/// Password
/// </summary>
public string Password;

/// <summary>
/// The instance id of the webcalling into the service.
/// </summary>
public int WebSiteInstanceID;
}
As you can see - they are quite simple classes used for communication only.
And you need to declare dem Serializable to use them (same goes with
DataSet; it is also Serializable).
--
rgds.
/Claus Konrad
"LW" wrote:
Hi!
>
I am getting the following error message for my fairly simple web service. I
have classes and have two DataSets that reference the same classes. The error
is:
>
The XML element named 'GetCustNoResponse' from namespace 'http://mydomain/'
references a method and a type. Change the method's message name using
WebMethodAttribute or change the type's root element using the
XmlRootAttribute.
>
What does this mean? I am not using any Serialization as yet but am rapidly
reading up on it as my guess is I need to use XMLSerialization or something?
>
LW
Oct 27 '06 #4

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

Similar topics

0
by: Omkar Singh | last post by:
When I serialize my class using XmlSerialization.serialize, it make a lot of reference in the output document. Is there any way to off XmlSerialiation class to make references.
0
by: Omkar Singh | last post by:
I am using XmlSerialization and XmlDeserialization for making soap Body part. Then I am making sopa-header and other part of soap envelope manually. At last joining all part to get complete soap...
2
by: STom | last post by:
I have just started reading up on XMLSerialization and still do not understand the practical use of this technology. For example, if I have to know the class type on the client and on the web...
0
by: A programmer desperatly needing help! | last post by:
I use the xmlserialization on asp.net pages and on previous machines it never gave a problem. But now i somethings get a: Timed out waiting for a program to execute. The command being executed was...
4
by: pfrisbie | last post by:
I am developing a Web Services interface with C# and our partner is using Java (Axis 1.1). They require me to include xsi:types in the SOAP Messages I send them. For example: <Partner...
1
by: zacks | last post by:
When I figured out XMLSerialization, I thought that was the best thing since sliced bread! Since then, I have designed several XML files that I read and write via XMLSerialzation. A common...
1
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
2
by: Nightfarer | last post by:
Hello. One more issue. I'm rewriting code to use XmlSerialization .NET Class because I need it. In my project I created some classes using different namespaces. An example: Namespace xxx
0
by: IanWright | last post by:
This is a little bit more of an advanced topic for serialization. For those who don't know what XML serialization is, then this probably isn't for you just yet. For those that do, you may have come...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.