xmlserialization error
I am trying to serialize an object (MCCI_IN000001TR01Message that is a class to use web service) using xml serialization, however when serializing it I am getting an error.
MCCI_IN000001TR01Message message = new MCCI_IN000001TR01Message()
{
id = new MCCI_IN000001TR01MessageID()
{
root = "2.16.840.1.113883.3.129.2.1.2",
extension = _sGuid
},
acceptAckCode =
new MCCI_IN000001TR01MessageAcceptAckCode()
{
code = "AL"
},
receiver =
f_Receiver(),
sender = f_Sender(),
controlActEvent = f_ControlActEvent(dialysis)
};
MCCI_IN000002TR01Message donen = service.MCCI_AR000001TR_MCCI_IN000001TR(message);
MCCI_IN000001TR01Message
is a class is not created by me. It is web service class.
The type System.String may not be used in this context. Description: An unhandled exception occ开发者_运维百科urred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: **The type System.String may not be used in this context.**
[InvalidOperationException: The type System.String may not be used in this context.]
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write216_StrucDocText(String n, String ns, StrucDocText o, Boolean isNullable, Boolean needType) +1823
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write403_Item(String n, String ns, POCD_MT000027TR01SocialSecurityFollowNumberSection o, Boolean isNullable, Boolean needType) +1087
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write404_POCD_MT000027TR01Component45(String n, String ns, POCD_MT000027TR01Component45 o, Boolean isNullable, Boolean needType) +942
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write434_Item(String n, String ns, POCD_MT000027TR01ReceptionDataset o, Boolean isNullable, Boolean needType) +1192
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write435_POCD_MT000027TR01Component44(String n, String ns, POCD_MT000027TR01Component44 o, Boolean isNullable, Boolean needType) +942
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write436_Item(String n, String ns, POCD_MT000027TR01StructuredBody o, Boolean isNullable, Boolean needType) +1477
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write437_POCD_MT000027TR01Component1(String n, String ns, POCD_MT000027TR01Component1 o, Boolean isNullable, Boolean needType) +942
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write438_POCD_MT000027TR01Dialysis(String n, String ns, POCD_MT000027TR01Dialysis o, Boolean isNullable, Boolean needType) +1951
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write439_MCCI_IN000001TR01Subject(String n, String ns, MCCI_IN000001TR01Subject o, Boolean isNullable, Boolean needType) +781
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write440_Item(String n, String ns, MCCI_IN000001TR01ControlActEvent o, Boolean isNullable, Boolean needType) +878
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write441_MCCI_IN000001TR01Message(String n, String ns, MCCI_IN000001TR01Message o, Boolean isNullable, Boolean needType) +1627
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterMCCI_IN000001TR01Message.Write442_MCCI_IN000001TR01(Object o) +144
[InvalidOperationException: There was an error generating the XML document.]
waSaglikNetUygulamasi._Default.Page_Load(Object sender, EventArgs e) in C:\Users\duygu.akmaz\Desktop\FMC-Projeler\SaglikNet\trunk\Default.aspx.cs:255
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
public string ToXml(DataSet ds)
{
using (var memoryStream = new MemoryStream())
{
using(TextWriter streamWriter = new StreamWriter(memoryStream))
{
var xmlSerializer = new XmlSerializer(typeof(DataSet));
xmlSerializer.Serialize(streamWriter, ds);
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
}
}
精彩评论