472,983 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 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 6922
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.