/// <summary> /// This method gets a XMLRepresentation of this class and convert it to the document /// </summary> /// <param name="reader">an XMLRepresentation of this Class</param> public void ReadXml(XmlReader reader) { // The simplest way to make this work is to convert the reader into an XML Document // and parse its nodes. XmlDocument doc = new XmlDocument(); doc.LoadXml(reader.ReadOuterXml()); DocumentMetadata = doc.SelectSingleNode(@".//*[local-name()='SubmitObjectsRequest']"); XmlNodeList docs = doc.SelectNodes(@".//*[local-name()='Document']"); foreach (XmlNode item in docs) { IHEDocument iheDoc = new IHEDocument(); iheDoc.DocumentID = item.Attributes["id"].Value.ToString(); iheDoc.Document = Convert.FromBase64String(item.InnerText); documents.Add(iheDoc); } }
private void btnPRExecute_Click(object sender, EventArgs e) { try { string innerXml = null; if (PRDocumentMetadata != null) { ProvideAndRegisterDocumentSetRequest request = new ProvideAndRegisterDocumentSetRequest(); request.DocumentMetadata = PRDocumentMetadata.SelectSingleNode(@".//*[local-name()='SubmitObjectsRequest']"); if (!(String.IsNullOrEmpty(txtPRPatientID.Text))) { innerXml = request.DocumentMetadata.InnerXml; innerXml = innerXml.Replace("$PatientId", txtPRPatientID.Text.Replace("&", "&")); request.DocumentMetadata.InnerXml = innerXml; //request.DocumentMetadata.InnerXml = request.DocumentMetadata.InnerXml.Replace("$PatientId", txtPRPatientID.Text); } XmlNodeList docs = request.DocumentMetadata.SelectNodes(@"//*[local-name()='ExtrinsicObject']"); if (txtPRDocument1.Enabled == true && !string.IsNullOrEmpty(txtPRDocument1.Text)) { IHEDocument doc1 = new IHEDocument(); doc1.DocumentID = docs.Item(0).Attributes["id"].Value; doc1.Document = LoadFile(txtPRDocument1.Text); docs.Item(0).Attributes["mimeType"].Value = GetMimeType(txtPRDocument1.Text); request.Documents.Add(doc1); } if (txtPRDocument2.Enabled == true && !string.IsNullOrEmpty(txtPRDocument2.Text)) { IHEDocument doc2 = new IHEDocument(); doc2.DocumentID = docs.Item(1).Attributes["id"].Value; doc2.Document = LoadFile(txtPRDocument2.Text); docs.Item(1).Attributes["mimeType"].Value = GetMimeType(txtPRDocument2.Text); request.Documents.Add(doc2); } WCF.Message msgInput, msgOutput; msgInput = WCF.Message.CreateMessage(MESSAGE_VERSION , PROVIDEANDREGISTERDOCUMENTSETB_WSAACTION , request); msgOutput = WCF.Message.CreateMessage(WCF.MessageVersion.Soap12WSAddressing10, ""); XDSRepository.XDSRepositoryClient client = new XDSRepository.XDSRepositoryClient(GetRepositoryEndPointName()); msgOutput = client.ProvideAndRegisterDocumentSet(msgInput); XmlDictionaryReader rdr = msgOutput.GetReaderAtBodyContents(); XmlDocument result = new XmlDocument(); result.Load(rdr); XmlNode fault = result.SelectSingleNode(@"//*[local-name()='Fault']"); XmlNode errorList = result.SelectSingleNode(@"//*[local-name()='RegistryErrorList']"); if (fault != null) { lblPRResult.Text = "Error occurred when executing web service."; rtfPRMetadataContent.Text = fault.OuterXml; } else { if (errorList != null) { lblPRResult.Text = "Transaction resulted in Error!"; rtfPRMetadataContent.Text = result.OuterXml; } else { lblPRResult.Text = "Transaction succeded!"; rtfPRMetadataContent.Text = result.OuterXml; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }