![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | OperationContract formatting problem HI, I'm working with winfx Beta2 and having a problem controlling the way OperationContract methods are serialized/deserialized. I need a pretty high granularity controll similar to the one given in asmx web methods using [SoapDocumentMethodAttribute] [XmlElement] and friends. (e.g. attributed controll over the method paramters elements names, name of return value, name of result element, etc). -------------------------------------------------------------------------------- example: [ServiceContract] interface MyService { [OperationContract] MyObject DoSomething ( MyObject obj ); } Indigo Default Request Serialization: <s:Envelope>... <s:Body> <DoSomething> <obj>....object serialization..<obj> </DoSomething> </s:Body> </s:Envelope> Desireable Request Serialization: <s:Envelope>... <s:Body> <DoSomething> <MyObject>....object serialization..<MyObject> </DoSomething> </s:Body> </s:Envelope> Indigo Default Response Serialization: <s:Envelope>... <s:Body> <DoSomethingResponse> <DoSomethingResult>...object serialization..</DoSomethingResult> </DoSomethingResponse> </s:Body> </s:Envelope> Desirable Response Serialization: <s:Envelope>... <s:Body> <DoSomethingResult> <MyObject>...object serialization..</MyObject> </DoSomethingResult> </s:Body> </s:Envelope> Any suggestions? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: OperationContract formatting problem Use the XmlSerializerFormatAttribute to decorate your OperationContract [ServiceContract] interface MyService { [OperationContract] [XmlSerializerFormat] MyObjectResponse DoSomething ( MyObjectRequest obj ); } and IXmlSerializable interface for your custom serialization/deserialization Request/Response object, see the following code snippet: public class MyObjectRequest : IXmlSerializable { // fields private MyObject _myObject; // properties public MyObject MyObject { get; set;} // constructors public MyObjectRequest() {} // IXmlSerializable Members public System.Xml.Schema.XmlSchema GetSchema() { // create schema return null; } public void ReadXml(XmlReader reader) { reader.ReadStartElement("DoSomething", "MyNamespace"); while (reader.NodeType != XmlNodeType.EndElement) { MyObject = reader.ReadElementContentAsObject("MyObject", "MyNamespace") as MyObject; // more objects reader.MoveToContent(); } } public void WriteXml(XmlWriter writer) { writer.WriteStartElement("DoSomething", "MyNamespace"); if (MyObject != null) { XmlSerializer xs = new XmlSerializer(MyObject.GetType()); xs.Serialize(writer, MyObject); } // more objects writer.WriteEndElement(); } } Roman "Amit Sharan" <amit.sharan@clicksoftware.com> wrote in message news:B2AAC4F2-788B-4E67-A64C-4B17EAE2D13D@microsoft.com... > HI, > > I'm working with winfx Beta2 and having a problem controlling the way > OperationContract methods are serialized/deserialized. > > I need a pretty high granularity controll similar to the one given in asmx > web methods using [SoapDocumentMethodAttribute] [XmlElement] and friends. > (e.g. attributed controll over the method paramters elements names, name > of > return value, name of result element, etc). > -------------------------------------------------------------------------------- > example: > > [ServiceContract] > interface MyService > { > [OperationContract] > MyObject DoSomething ( MyObject obj ); > } > > Indigo Default Request Serialization: > > <s:Envelope>... > <s:Body> > <DoSomething> > <obj>....object serialization..<obj> > </DoSomething> > </s:Body> > </s:Envelope> > > Desireable Request Serialization: > > <s:Envelope>... > <s:Body> > <DoSomething> > <MyObject>....object serialization..<MyObject> > </DoSomething> > </s:Body> > </s:Envelope> > > Indigo Default Response Serialization: > > <s:Envelope>... > <s:Body> > <DoSomethingResponse> > <DoSomethingResult>...object serialization..</DoSomethingResult> > </DoSomethingResponse> > </s:Body> > </s:Envelope> > > Desirable Response Serialization: > > <s:Envelope>... > <s:Body> > <DoSomethingResult> > <MyObject>...object serialization..</MyObject> > </DoSomethingResult> > </s:Body> > </s:Envelope> > > Any suggestions? > > Thanks. > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| problem with lastwritetime and formatting. | PowerShell | |||
| Problem formatting a dvd | Vista music pictures video | |||
| Problem formatting date | PowerShell | |||
| Formatting U3 device problem | Vista hardware & devices | |||
| Formatting Problem | Vista music pictures video | |||