I have serialize one sample C# object into soap xml message.
Sample C# Class -
[Serializable]
public class Sample
{
public CarDetails CarDetails { get; set; }
public OwnerDetails OwnerDetails { get; set; }
}
[Serializable]
public class CarDetails
{
public string Name { get; set; }
public string Model { get; set; }
public string Color { get; set; }
public string Number { get; set; }
}
[Serializable]
public class OwnerDetails
{
public string Name { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string PhoneNumber { get; set; }
}
Serialization Code -
Sample ss = new Sample();
ss.CarDetails = new CarDetails();
ss.CarDetails.Name = "Tata Nano";
ss.CarDetails.Model = "Z 500";
ss.CarDetails.Color = "Red";
ss.CarDetails.Number = "Tn 08 5222";
ss.OwnerDetails = new OwnerDetails();
ss.OwnerDetails.Name = "Jagadees";
ss.OwnerDetails.LastName = "Natrajan";
ss.OwnerDetails.Address = "Kattuputhur";
ss.OwnerDetails.City = "Trichy";
ss.OwnerDetails.PhoneNumber = "91000000000";
var r = new Random();
SoapFormatter formatter = new SoapFormatter();
string myTempFile = Path.Combine(Path.GetTempPath(), r.Next() + "xml.txt");
GC.SuppressFinalize(myTempFile);
Stream objfilestream = new FileStream(myTempFile, FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(objfilestream, ss);
objfilestream.Close();
What I Expect -
<SOAP-ENV:Envelope xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY" xmlns:SOAP-ENC="http://ift.tt/wEYywg" xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:clr="http://ift.tt/1jCPeMR" SOAP-ENV:encodingStyle="http://ift.tt/wEYywg">
<SOAP-ENV:Body>
<Sample xmlns:a1="http://ift.tt/1tbnXzd">
<CarDetails>
<Name>Tata Nano</Name>
<Model>Z 500</Model>
<Color>Red</Color>
<Number>Tn 08 5222</Number>
</CarDetails>
<OwnerDetails>
<Name>Jagadees</Name>
<LastName>Natrajan</LastName>
<Address>Kattuputhur</Address>
<City>Trichy</City>
<PhoneNumber>91000000000</PhoneNumber>
</OwnerDetails>
</Sample>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP XML that I got -
<SOAP-ENV:Envelope xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY" xmlns:SOAP-ENC="http://ift.tt/wEYywg" xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:clr="http://ift.tt/1jCPeMR" SOAP-ENV:encodingStyle="http://ift.tt/wEYywg">
<SOAP-ENV:Body>
<a1:Sample id="ref-1" xmlns:a1="http://ift.tt/1tbnXzd">
<_x003C_CarDetails_x003E_k__BackingField href="#ref-3"/>
<_x003C_OwnerDetails_x003E_k__BackingField href="#ref-4"/>
</a1:Sample>
<a1:CarDetails id="ref-3" xmlns:a1="http://ift.tt/1tbnXzd">
<_x003C_Name_x003E_k__BackingField id="ref-5">Tata Nano</_x003C_Name_x003E_k__BackingField>
<_x003C_Model_x003E_k__BackingField id="ref-6">Z 500</_x003C_Model_x003E_k__BackingField>
<_x003C_Color_x003E_k__BackingField id="ref-7">Red</_x003C_Color_x003E_k__BackingField>
<_x003C_Number_x003E_k__BackingField id="ref-8">Tn 08 5222</_x003C_Number_x003E_k__BackingField>
</a1:CarDetails>
<a1:OwnerDetails id="ref-4" xmlns:a1="http://ift.tt/1tbnXzd">
<_x003C_Name_x003E_k__BackingField id="ref-9">Jagadees</_x003C_Name_x003E_k__BackingField>
<_x003C_LastName_x003E_k__BackingField id="ref-10">Natrajan</_x003C_LastName_x003E_k__BackingField>
<_x003C_Address_x003E_k__BackingField id="ref-11">Kattuputhur</_x003C_Address_x003E_k__BackingField>
<_x003C_City_x003E_k__BackingField id="ref-12">Trichy</_x003C_City_x003E_k__BackingField>
<_x003C_PhoneNumber_x003E_k__BackingField id="ref-13">91000000000</_x003C_PhoneNumber_x003E_k__BackingField>
</a1:OwnerDetails>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I got soap message like above,. its not have clear field _x003c something i am not including in code anywhare?. I don't know why it happen?. help me to find my mistake. thanks.
No comments:
Post a Comment