<start>?</start>
WCF data contarct definition
I m trying create a wcf interface which should produce payload format as below , please help
<availmessage>
<name>?</name>
<datatype>?</datatype>
<!~~zero or more —!>
<blocks>
<start>?</start>
<end>?</end>
</blocks>
</availmessage>
What I’m getting is
<availmessage>
<name>?</name>
<datatype>?</datatype>
<blocks>
<!———zero or more ———-!>
<blockdatatype>
<start>?</start>
<end>?</end>
</blockadatatye>
</blocks>
</availmessage>
Class definition
[datacontract]
Public class availmessage
{
Public string name { get;set;}
Public string datatype { get; set;}
Public List<blockdatatype> blocks { get; set;}
}
[Datacontract]
Public class blockdatatype
{
Public string start { get; set;}
Public string end { get; set; }
}
2 answers
Sort by: Most helpful
-
-
Lan Huang-MSFT 30,176 Reputation points Microsoft Vendor
2022-07-14T06:37:09.077+00:00 Hi @Vara Prasad ,
I suggest you can use Message Contracts instead, because Message Contracts include IsWrapped property, which can help you achieve what you want.[MessageContract(IsWrapped = false)]
To suppress the wrapper element, set the IsWrapped property to false. To control the name and the namespace of the wrapper element, use the WrapperName and WrapperNamespace properties.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/using-message-contracts#controlling-whether-the-soap-body-parts-are-wrapped
https://learn.microsoft.com/en-us/dotnet/api/system.servicemodel.messagecontractattribute.iswrapped?view=dotnet-plat-ext-6.0Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.