2011-06-29 24 views
0

XMLシリアル化を使用してオブジェクト(Webサービスを使用するクラスであるMCCI_IN000001TR01Message)をシリアル化しようとしていますが、シリアル化する際にエラーが発生します。xmlシリアル化エラー

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クラスは、私が作成されていませんです。これはWebサービスクラスです。

型System.Stringこの文脈で使用されなくてもよいです。 説明:現在のWeb要求の実行中に、未処理の例外が発生しました。エラーの詳細とコード内のどこで発生したのかについては、スタックトレースを参照してください。

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 
+0

あなたは例外がスローされ、あなたのコードを投稿することができますか? –

+0

質問を編集します。 MCCI_IN000002TR01メッセージdonen = service.MCCI_AR000001TR_MCCI_IN000001TR(メッセージ);例外がスローされます。 – Dakmaz

答えて

1
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()); 
    } 
    } 
} 
+0

は、あなたの答えがなぜ役立つのかを説明します。 – jgauffin