When we do web service, we often need to pass a list from the background to the foreground. in the list, if the basic type such as string is directly inserted, there is no problem. If we define a data class file by ourselves, the metadata of [serializable] is added to the definition of this class file, it is no problem to pass the class object to the foreground using web service. However, when we insert this object into a list and use web service to transfer this list, an error will occur.
The error message is as follows.
System. invalidoperationexception. ---> System. invalidoperationexception: Type bcanddac. user specified specifies that the specified parameter has been used successfully. Zookeeper zookeeper uses zookeeper to specify the zookeeper xmlinclude zookeeper soapinclude attribute to enable zookeeper.
Field System. xml. serialization. xmlserializationwriter. writetypedprimitive (string name, string NS, object o, Boolean xsitype)
Microsoft. xml. serialization. generatedassembly. xmlserializationwriter1.write1 _ object (string N, string NS, object o, Boolean isnullable, Boolean needtype)
Microsoft. xml. serialization. generatedassembly. xmlserializationwriter1.write2 _ arrayofanytype (Object O)
Microsoft. Xml. Serialization. GeneratedAssembly. IListSerializer. Serialize (Object objectToSerialize, XmlSerializationWriter writer)
Field System. Xml. Serialization. XmlSerializer. Serialize (XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- The exception is when there are too many rows when there are rows before the last ---
Field System. Xml. Serialization. XmlSerializer. Serialize (XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
Field System. Xml. Serialization. XmlSerializer. Serialize (XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
Field System. xml. serialization. xmlserializer. serialize (xmlwriter, object o, xmlserializernamespaces namespaces)
Field System. xml. serialization. xmlserializer. serialize (textwriter, object o, xmlserializernamespaces namespaces)
Field System. xml. serialization. xmlserializer. serialize (textwriter, object O)
Field System. Web. Services. Protocols. xmlreturnwriter. Write (httpresponse response, stream outputstream, object returnvalue)
Site system. Web. Services. Protocols. httpserverprotocol. writereturns (object [] returnvalues, stream outputstream)
Field System. Web. Services. Protocols. webservicehandler. writereturns (object [] returnvalues)
Site system. Web. Services. Protocols. webservicehandler. Invoke ()
On the surface, it is an error that the object cannot be serialized. But why is this. I did not think of the specific reason, but I found a solution, that is, to add the xmlinclude metadata before the Web service method. The Code is as follows.
[System. xml. serialization. xmlinclude (typeof (User)]
Then run it again and find that the Web Service is normal. You can identify the user class that I have defined.