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