Use the ArrayList object in WebService.

xiaoxiao2021-03-06  133

I often see someone asked online, how to use ArrayList in WebService. In fact, this is because I don't have a good reason for MSDN.

ArrayList is a linear list object (it is still a bit means.), But WebService does not support it, not a standard variable object, if you have to use the properties in WebService. [XMLRoot "]]

example:

______________________ serialized YouClass.cs

Using system.xml.Serialization;

Namespace Somens

{[Serializable] [XMLROOT ("NewYouClass")] // This property requires the serialization of XML roots Public class YOUSERIALIZABLASS {Private Long M_LID;

Public YOUSERIALIZABEDCLASS () {} public long lid {get {return m_lid;} set {m_lid = value;}}

}

_____________________________ to operate YouClass class A.CS

[XmlInclude (typeof (YouSerializabledClass))] public YouSerializabledClass YouSerializabledClassOperation (Some Var) {YouSerializabledClass.lID = Convert.ToInt64 (Var); return YouSerializabledClass;}

_______________________Webmethod

[WebMethod] [XmlInclude (typeof (YouSerializabledClass))] public YouSerializabledClass YouWebMetho (SomeVar Var) {YouSerializabledClass YouSerializabledClass1 = A.YouSerializabledClassOperation (Var); return YouSerializabledClass;} After this is completed, the mapping sequence generated in the client class.

________________________________ client's Reference.cs

/ / -------------------------------------------------------------------------------------------- ------------------------------ // // this code WAS generated by a Tool.// runtime version: 1.1.4322.573/// CHANGES TO THIS FILE MAY CAUSE INCORRECT Behavior and Will Be Lost IF // The code is regenerated> // --------------- -------------------------------------------------- -------------

// // This source code is automatically generated by Microsoft.vsdesigner 1.1.4322.573.

转载请注明原文地址:https://www.9cbs.com/read-127034.html

New Post(0)