0
私はこの使用してSOAPエンベロープにシリアライズを実行します。石鹸シリアル化で接頭辞_x003C_を取り除くにはどうすればいいですか?
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENC:Array SOAP-ENC:arrayType="a1:Person[2]" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/Serialization/Serialization%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<item href="#ref-3"/>
<item href="#ref-4"/>
</SOAP-ENC:Array>
<a1:Person id="ref-3" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/Serialization/Serialization%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<_x003C_Name_x003E_k__BackingField id="ref-5">Tom</_x003C_Name_x003E_k__BackingField>
<_x003C_Age_x003E_k__BackingField>29</_x003C_Age_x003E_k__BackingField>
</a1:Person>
<a1:Person id="ref-4" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/Serialization/Serialization%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<_x003C_Name_x003E_k__BackingField id="ref-6">Bill</_x003C_Name_x003E_k__BackingField>
<_x003C_Age_x003E_k__BackingField>25</_x003C_Age_x003E_k__BackingField>
</a1:Person>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
私は "_x003E_k__BackingField" "x003C" と接尾辞接頭辞を取り除くことができます方法:
[Serializable]
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Person(string name, int age)
{
Name = name;
Age = age;
}
}
class Program
{
static void Main(string[] args)
{
Person person = new Person("Tom", 29);
Person person2 = new Person("Bill", 25);
Person[] people = new Person[] { person, person2 };
SoapFormatter formatter = new SoapFormatter();
using (FileStream fs = new FileStream("people.soap", FileMode.OpenOrCreate))
{
formatter.Serialize(fs, people);
Console.WriteLine("Serialized");
}
using (FileStream fs = new FileStream("people.soap", FileMode.OpenOrCreate))
{
Person[] newPeople = (Person[])formatter.Deserialize(fs);
Console.WriteLine("Deserialized");
foreach (Person p in newPeople)
{
Console.WriteLine("Name: {0} --- Age: {1}", p.Name, p.Age);
}
}
Console.ReadLine();
}
}
私は以下のようにシリアル化された石鹸を取得します私のフィールド "名前"と "年齢"で?
ありがとうございます。