public override void WriteObject(XmlWriter writer, object graph) { SetFileInfo SetFileInfoField = ((SetFileInfo)(graph)); if (WriteParentElement(writer, true, true, graph)) { schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer filesDCS = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer("files", "http://tempuri.org/", "http://schemas.datacontract.org/2004/07/WcfMtomService"); filesDCS.BodyParts = this.BodyParts; filesDCS.WriteObject(writer, SetFileInfoField.files); writer.WriteEndElement(); } return; }
public override object ReadObject(XmlReader reader) { SetFileInfo SetFileInfoField = null; if (IsParentStartElement(reader, false, true)) { SetFileInfoField = new SetFileInfo(); reader.Read(); schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer filesDCS = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer("files", "http://tempuri.org/", "http://schemas.datacontract.org/2004/07/WcfMtomService"); filesDCS.BodyParts = this.BodyParts; SetFileInfoField.files = ((schemas.datacontract.org.WcfMtomService.ArrayOfFileInfo)(filesDCS.ReadObject(reader))); reader.ReadEndElement(); } return(SetFileInfoField); }
public virtual SetFileInfoResponse SetFileInfo(SetFileInfo req) { // Create request header String action; action = "http://tempuri.org/IDataAccessService/SetFileInfo"; WsWsaHeader header; header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null); WsMessage request = new WsMessage(header, req, WsPrefix.None); // Create request serializer SetFileInfoDataContractSerializer reqDcs; reqDcs = new SetFileInfoDataContractSerializer("SetFileInfo", "http://tempuri.org/"); request.Serializer = reqDcs; request.Method = "SetFileInfo"; // Indicate that this message will use Mtom encoding request.BodyParts = new WsMtomBodyParts(); // Send service request m_requestChannel.Open(); WsMessage response = m_requestChannel.Request(request); m_requestChannel.Close(); // Process response SetFileInfoResponseDataContractSerializer respDcs; respDcs = new SetFileInfoResponseDataContractSerializer("SetFileInfoResponse", "http://tempuri.org/"); respDcs.BodyParts = response.BodyParts; SetFileInfoResponse resp; resp = ((SetFileInfoResponse)(respDcs.ReadObject(response.Reader))); response.Reader.Dispose(); response.Reader = null; return(resp); }
private void TestMtomService() { try { WS2007HttpBinding binding = new WS2007HttpBinding( new HttpTransportBindingConfig(new Uri("http://*****:*****@"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep. Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child. Bedtime stories can be read from a book, or rather, fictional stories made up by the storyteller. The stories are mostly rather short, between one and five minutes, and have a happy ending. A different form of bedtime reading is using longer stories, but dividing them up, thus creating cliffhangers. Children will look forward to their bedtime story, and a fixed routine is installed. "); m_proxy.SetData(req); GetData req2 = new GetData(); // get bytes < 1000 to test Base64 req2.value = 0; GetDataResponse resp = m_proxy.GetData(req2); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data))); // to get data > 1000 bytes to test mtom req2.value = 1; resp = m_proxy.GetData(req2); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data))); // to get data > 1000 (non-char) bytes to test mtom req2.value = 2; resp = m_proxy.GetData(req2); for (int i = 0; i < resp.GetDataResult.Data.Length; i++) { if ((byte)i != resp.GetDataResult.Data[i]) { Debug.Print("FAILURE!!!!! expected incrementing data byte values"); break; } } SetNestedData req3 = new SetNestedData(); req3.data = new schemas.datacontract.org.WcfMtomService.NestedClass(); req3.data.MTData = new schemas.datacontract.org.WcfMtomService.MtomData(); req3.data.MTData.Data = System.Text.UTF8Encoding.UTF8.GetBytes( @"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep." ); req3.data.MyData = System.Text.UTF8Encoding.UTF8.GetBytes(@"Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child."); m_proxy.SetNestedData(req3); GetNestedData req4 = new GetNestedData(); GetNestedDataResponse resp8 = m_proxy.GetNestedData(req4); Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp8.GetNestedDataResult.MyData))); for (int i = 0; i < resp8.GetNestedDataResult.MTData.Data.Length; i++) { if ((byte)i != resp8.GetNestedDataResult.MTData.Data[i]) { Debug.Print("FAILURE!!!!! expected incrementing data byte values"); break; } } SetFileInfo sfi = new SetFileInfo(); sfi.files = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfo(); sfi.files.FileInfo = new schemas.datacontract.org.WcfMtomService.FileInfo[2]; sfi.files.FileInfo[0] = new schemas.datacontract.org.WcfMtomService.FileInfo(); sfi.files.FileInfo[0].Name = "MyBook"; sfi.files.FileInfo[0].Size = 340; sfi.files.FileInfo[1] = new schemas.datacontract.org.WcfMtomService.FileInfo(); sfi.files.FileInfo[1].Name = "MyBook2"; sfi.files.FileInfo[1].Size = 341; m_proxy.SetFileInfo(sfi); } catch (System.IO.IOException) { // Is the web service down??? Debug.Print("Warning: could not connect to stocks web service"); } finally { if (m_proxy != null) m_proxy.Dispose(); } }
public override object ReadObject(XmlReader reader) { SetFileInfo SetFileInfoField = null; if (IsParentStartElement(reader, false, true)) { SetFileInfoField = new SetFileInfo(); reader.Read(); schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer filesDCS = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfoDataContractSerializer("files", "http://tempuri.org/", "http://schemas.datacontract.org/2004/07/WcfMtomService"); filesDCS.BodyParts = this.BodyParts; SetFileInfoField.files = ((schemas.datacontract.org.WcfMtomService.ArrayOfFileInfo)(filesDCS.ReadObject(reader))); reader.ReadEndElement(); } return SetFileInfoField; }
public virtual SetFileInfoResponse SetFileInfo(SetFileInfo req) { // Create request header String action; action = "http://tempuri.org/IDataAccessService/SetFileInfo"; WsWsaHeader header; header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null); WsMessage request = new WsMessage(header, req, WsPrefix.None); // Create request serializer SetFileInfoDataContractSerializer reqDcs; reqDcs = new SetFileInfoDataContractSerializer("SetFileInfo", "http://tempuri.org/"); request.Serializer = reqDcs; request.Method = "SetFileInfo"; // Indicate that this message will use Mtom encoding request.BodyParts = new WsMtomBodyParts(); // Send service request m_requestChannel.Open(); WsMessage response = m_requestChannel.Request(request); m_requestChannel.Close(); // Process response SetFileInfoResponseDataContractSerializer respDcs; respDcs = new SetFileInfoResponseDataContractSerializer("SetFileInfoResponse", "http://tempuri.org/"); respDcs.BodyParts = response.BodyParts; SetFileInfoResponse resp; resp = ((SetFileInfoResponse)(respDcs.ReadObject(response.Reader))); response.Reader.Dispose(); response.Reader = null; return resp; }