Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

OperationContract formatting problem

 
 
Thread Tools Display Modes
Old 03-04-2006   #1 (permalink)
Amit Sharan
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.


Old 03-04-2006   #2 (permalink)
Roman Kiss [MVP]
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.
>
>



Old 03-04-2006   #3 (permalink)
Juval Lowy
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








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50