private Response GetNetworkDesignResponse(AesNetworkDesign and, AesBusinessSession abs) { Response resp = null; byte[] oByte = null; String sXml = null; MemoryStream memoryStream = new MemoryStream(); XmlSerializer xs = new XmlSerializer(typeof(AesNetworkDesign)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); xs.Serialize(xmlTextWriter, and); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; UTF8Encoding encoding = new UTF8Encoding(); oByte = memoryStream.ToArray(); sXml = encoding.GetString(oByte); int indx = sXml.IndexOf("<"); sXml = sXml.Substring(indx); // string strSoap = string.Format("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><GetNetworkDesign xmlns=\"http://cisco.com/mse/location\"><AesBusinessSession mask=\"-1\" id=\"{0}\" />", // abs.id); string strSoap = string.Format("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><soap:Body xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><GetNetworkDesign><AesBusinessSession mask=\"-1\" id=\"{0}\" />", abs.id); string sReq = sXml.Substring(indx - 1, sXml.IndexOf(">") + 1); sReq += strSoap; sReq += sXml.Substring(sXml.IndexOf("<", indx + 1)); sReq += "</GetNetworkDesign></soap:Body></soap:Envelope>"; oByte = encoding.GetBytes(sReq); Trace.WriteLine(sReq); string contType = null; byte[] ndResponse = SendNetworkDesignRequest(oByte, "urn:#GetNetworkDesign", ref contType); ImageParser imp = new ImageParser(ndResponse); string soapEnvelop = imp.GetSoapEnvelop(); resp = (Response)ParseSoapResponse(soapEnvelop, typeof(Response)); Attachment atch = imp.GetNext(); System.Collections.Hashtable htImagePaths = new System.Collections.Hashtable(); Trace.WriteLine("htImagePaths" + htImagePaths); String curDir = Directory.GetCurrentDirectory(); Directory.CreateDirectory("Images"); Directory.SetCurrentDirectory("Images"); while (atch != null) { String CID = atch.ContentID; Trace.WriteLine("CID" + CID.Length); CID = CID.Substring(CID.IndexOf("domain")); CID = CID.Substring(0, CID.Length - 1); Trace.WriteLine("CID" + CID); String sFileName = Directory.GetCurrentDirectory() + "\\" + CID + "." + atch.Extension;//Path.GetTempFileName(); Trace.WriteLine("Path" + sFileName); string extn = atch.Extension; if (extn != null) { sFileName = Path.ChangeExtension(sFileName, extn); } BinaryWriter bWrit = new BinaryWriter(new FileStream(sFileName, FileMode.Create)); System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string str = enc.GetString(atch.Data); if (str.Contains("------=_Part_")) str = str.Substring(0, str.IndexOf("------=_Part_")); byte[] imageBytes = Convert.FromBase64String(str); bWrit.Write(imageBytes); bWrit.Close(); htImagePaths.Add(atch.ContentID, sFileName); atch = imp.GetNext(); Trace.WriteLine("soapEnvelop3"); UpdateResponseWithImagePath(resp, htImagePaths, sFileName); } return resp; }
private Response GetNetworkDesignListForServiceResponse(ForServiceMethodArgs FSMA) { byte[] oByte = null; Response resp = null; UTF8Encoding encoding = new UTF8Encoding(); string soapEnvelope = null; soapEnvelope = string.Format("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><GetNetworkDesignListForService xmlns=\"http://cisco.com/mse/location\" serviceId=\"{0}\" options=\"{1}\"><AesBusinessSession mask=\"-1\" id=\"{2}\"/></GetNetworkDesignListForService></soap:Body></soap:Envelope>",FSMA.serviceId,FSMA.options,FSMA.AesBusinessSession.id); Trace.WriteLine("SOAP Request::" + soapEnvelope); oByte = encoding.GetBytes(soapEnvelope); string contType = null; byte[] ndlResponse = SendNetworkDesignRequest(oByte, "urn:#GetNetworkDesignListForService", ref contType); ImageParser imp = new ImageParser(ndlResponse); string soapEnvelop = imp.GetSoapEnvelop(); resp = (Response)ParseSoapResponse(soapEnvelop, typeof(Response)); Attachment atch = imp.GetNext(); System.Collections.Hashtable htImagePaths = new System.Collections.Hashtable(); Trace.WriteLine("htImagePaths" + htImagePaths); String curDir = Directory.GetCurrentDirectory(); Directory.CreateDirectory("Images"); Directory.SetCurrentDirectory("Images"); while (atch != null) { String CID = atch.ContentID; Trace.WriteLine("CID" + CID.Length); CID = CID.Substring(CID.IndexOf("domain")); CID = CID.Substring(0, CID.Length - 1); Trace.WriteLine("CID" + CID); String sFileName = Directory.GetCurrentDirectory() + "\\" + CID + "." + atch.Extension;//Path.GetTempFileName(); Trace.WriteLine("Path" + sFileName); string extn = atch.Extension; if (extn != null) { sFileName = Path.ChangeExtension(sFileName, extn); } BinaryWriter bWrit = new BinaryWriter(new FileStream(sFileName, FileMode.Create)); System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string str = enc.GetString(atch.Data); if (str.Contains("------=_Part_")) str = str.Substring(0, str.IndexOf("------=_Part_")); byte[] imageBytes = Convert.FromBase64String(str); bWrit.Write(imageBytes); bWrit.Close(); htImagePaths.Add(atch.ContentID, sFileName); atch = imp.GetNext(); Trace.WriteLine("soapEnvelop3"); UpdateResponseWithImagePath(resp, htImagePaths, sFileName); } return resp; }