![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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. |
| | #2 (permalink) |
| Guest | 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. > > |
| | #3 (permalink) |
| Guest | Re: OperationContract formatting problem Hello Amit, Did you try the XmlSerializerFormatAttribute as well as the /uxs switch of SvcUtil? Thanks, Juval. > 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. > |
| |
| |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with 'folder style' formatting | Imageman | Vista General | 3 | 01-17-2008 09:12 AM |
| Problem formatting date | Jobbsy | PowerShell | 1 | 11-14-2007 02:15 AM |
| Formatting U3 device problem | Dave T. | Vista hardware & devices | 1 | 10-27-2007 11:53 AM |
| Formatting CD problem in Vista | Bill S | Vista General | 12 | 07-28-2007 12:22 AM |
| Formatting Problem | David Williams | Vista music pictures video | 0 | 04-01-2007 06:05 AM |