Two problems encountered when XML serialization matches RESTful WCF Data Contract

Source: Internet
Author: User

Question 1:

XML serialization and RESTful WCF Data Contract cannot match and the class value cannot be passed.

 

Symptom:

If [Serializable] Attribute is added to the class, serialization can be successful, but the WCF Service cannot recognize it. It is found that the sequence of XML serialization and members in WCF Data Contract must be the same.


Solution:

1. Clear the default namespace of the WCF Data Contract Class header (see the code ).

2. Add XML serialization and WCF Order to all elements (see the Code), including the called class.

=   = =   id { ; = =   userName { ; = =   nickName { ;          Profile m_profile = = =  {  { m_profile ==  = =   id { ; = =   nation { ; = =   gender { ; 

 


Question 2:

In case of the List type, the WCF Service cannot be identified.

 

Symptom:

The Service cannot identify the object serialized in XML.

 

Solution:
Add the complete Type of List to the [XmlElement] Attribute (see the code ).

        [DataMember(Order = = , Type = (List<SchoolGradeClass> List<SchoolGradeClass> SchoolGradeClassList { ; ; }    

 

 

What should I do when Google fails to solve the above problems? Experience and knowledge are your secrets. Technology is a developing thing that requires every technician to learn for life. Learning should be part of the programmer's blood! We encourage everyone on the technical front.

 

 

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.