How to generate xmlns in response xml of WCF Restful Service
-
Tuesday, June 26, 2012 8:51 AM
Hi,
I have a WCF Restful Service which generates the response xml
<ServiceContract(Namespace:="http://test.com/ns")> _ <XmlSerializerFormat()> _ Public Interface IItemTrackerService <OperationContract()> _ <WebInvoke(Method:="POST", RequestFormat:=WebMessageFormat.Xml, ResponseFormat:=WebMessageFormat.Xml, BodyStyle:=WebMessageBodyStyle.Bare, UriTemplate:="GetItemTrackingDetails")> _ Function GetItemTrackingDetails(ByVal request As ItemTrackingDetailsRequest) As ItemTrackingDetailsResponse End Interface
The related class is as follows
<ServiceBehavior(Namespace:="http://test.com/ns")> _ <DataContract(Namespace:="http://test.com/ns")> _ Public Class ItemTrackingDetailsResponse Private itemsTrackingDetailsField() As ItemTrackingDetail Private statusField As StatusRes Public Sub New() End Sub Public Sub New(ByVal itemsTrackingDetails() As ItemTrackingDetail, ByVal status As StatusRes) itemsTrackingDetailsField = itemsTrackingDetails statusField = status End Sub <DataMember(Order:=0)> _ Public Property ItemsTrackingDetailList() As ItemTrackingDetail() Get Return Me.itemsTrackingDetailsField End Get Set(ByVal value As ItemTrackingDetail()) Me.itemsTrackingDetailsField = value End Set End Property <DataMember(Order:=1)> _ Public Property Status() As StatusRes Get Return Me.statusField End Get Set(ByVal value As StatusRes) Me.statusField = value End Set End Property End Class
I would like to have xmlns="http://test.com/ns" to be inserted into the header of the response xml. With the above code it is not generating. What are the changes that needs to be done to Service and DataContract to generate xmlns in the response xml?
Regards, CPK_2011
All Replies
-
Friday, June 29, 2012 2:48 AMModerator
WCF Restful service does not based on SOAP messge, you could try to create a WCF service based on SOAP message instead of REST service, and do again to check whether it is ok, or use MessageHeader attribute and set its namespace.Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
- Marked As Answer by Yi-Lun LuoModerator Monday, July 09, 2012 2:41 AM

