in the codeO
<? The XML version="1.0" encoding="utf-8"?>
Structure
Public class Response
{
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string the ResultCode {get; set; }
[DataMember]
Public string ResultContent {get; set; }
[DataMember]
Public List
}
Public class EUSERINFO
{
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string Name {get; set; }
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string Dept {get; set; }
[System. Xml Serialization. XmlElement (IsNullable=true)]
[DataMember]
Public string BM {get; set; }
}
Public string XmlSerialize
{
XmlSerializer xs=new XmlSerializer (obj. GetType ());
MemoryStream ms=new MemoryStream ();
//set the order ordering XML format
XmlWriterSettings XWS=new XmlWriterSettings ();
XWS. Indent=true;
XWS. OmitXmlDeclaration=true;
XWS. Encoding=Encoding. UTF8;
Using (XmlWriter XTW=XmlTextWriter. Create (ms, XWS))
{
XmlSerializerNamespaces _namespaces=new XmlSerializerNamespaces (
New XmlQualifiedName [] {
New XmlQualifiedName (string. The Empty string. Empty)
});
Xs. Serialize (XTW, obj, _namespaces);
Ms. Position=0;
XTW. Close ();
}
Byte [] b=Ms. ToArray ();
String s=System. Text.. Encoding UTF8. Get string (b, 0, b.L ength);
Return s;
}
CodePudding user response:
[the WebMethod]Public string USER (string Requestparam)
{
Try
{
EUSER_Request _EUSER=DESerializer
IEnumerable
If (mgetEUSERINFO==null)
{
_EUSER_Response. The ResultCode="1";//=new EUSER_Response () {the ResultCode="1", ResultContent="data acquisition failure", mEUSERINFO=};
_EUSER_Response. ResultContent="data acquisition failure";
}
The else
{
_EUSER_Response. The ResultCode="0";//=new EUSER_Response () {the ResultCode="1", ResultContent="data acquisition failure", mEUSERINFO=};
_EUSER_Response. ResultContent="data acquisition success";
_EUSER_Response. Data=https://bbs.csdn.net/topics/(List
}
XML string=XmlSerialize (_EUSER_Response);
//string filepath=AppDomain. CurrentDomain. BaseDirectory + "User. XML";
Return the XML.
}
Catch
{
Return a string. The Empty;
}
}
CodePudding user response:
The