WEB method usage in Web Services (2)

Source: Internet
Author: User

Since it was the first time to use WebService, it is not very easy to understand in many places.

At first, we thought we needed to pass in or return a custom type.

[System. xml. serialization. xmlinclude (typeof (...)]

Msdn Description: allows xmlserializer to identify the type when it serializes or deserializes an object.

Used when you call the serialize or deserialize methods of the xmlserializer classXmlincludeattribute.

When the applicationXmlincludeattributeSpecify the type of the derived class.XmlserializerAfter serialization contains objects of both the base class and the derived class, it can recognize two types of objects.

However, when using a custom typeSerializableattributeAttribute is applied to a type that indicates that instances of this type can be serialized.

Using system;

Namespace clscommon
{
/// <Summary>
/// The person role summary contains the specified role.
/// </Summary>
[Serializable]
Public class person
{
Public string name;
Public String gender;

Public Person ()
{}

Public Person (string name, string gender)
{
Name = Name;
Gender = gender;
}
}
}

Used when you call the serialize or deserialize methods of the xmlserializer classXmlincludeattribute.

When the applicationXmlincludeattributeSpecify the type of the derived class.XmlserializerAfter serialization contains objects of both the base class and the derived class, it can recognize two types of objects.

However, when using a custom typeSerializableattributeAttribute is applied to a type that indicates that instances of this type can be serialized.

Using system;

Namespace clscommon
{
/// <Summary>
/// The person role summary contains the specified role.
/// </Summary>
[Serializable]
Public class person
{
Public string name;
Public String gender;

Public Person ()
{}

Public Person (string name, string gender)
{
Name = Name;
Gender = gender;
}
}
}

Used when you call the serialize or deserialize methods of the xmlserializer classXmlincludeattribute.

When the applicationXmlincludeattributeSpecify the type of the derived class.XmlserializerAfter serialization contains objects of both the base class and the derived class, it can recognize two types of objects.

However, when using a custom typeSerializableattributeAttribute is applied to a type that indicates that instances of this type can be serialized.

Using system;

Namespace clscommon
{
/// <Summary>
/// The person role summary contains the specified role.
/// </Summary>
[Serializable]
Public class person
{
Public string name;
Public String gender;

Public Person ()
{}

Public Person (string name, string gender)
{
Name = Name;
Gender = gender;
}
}
}

Used when you call the serialize or deserialize methods of the xmlserializer classXmlincludeattribute.

When the applicationXmlincludeattributeSpecify the type of the derived class.XmlserializerAfter serialization contains objects of both the base class and the derived class, it can recognize two types of objects.

However, when using a custom typeSerializableattributeAttribute is applied to a type that indicates that instances of this type can be serialized.

Using system;

Namespace clscommon
{
/// <Summary>
/// The person role summary contains the specified role.
/// </Summary>
[Serializable]
Public class person
{
Public string name;
Public String gender;

Public Person ()
{}

Public Person (string name, string gender)
{
Name = Name;
Gender = gender;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.