Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a rest service and it is working perfectly with my get operation, but i am trying to implement a POST, but when the xml data reaches the service it looks like this (missing half the objects and priority changes to 0 instead of 8888) :
XML
<?xml version="1.0" encoding="utf-8"?>
<DVBAlertDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <SessionID>9999</SessionID>
  <Priority>0</Priority>
</DVBAlertDetails>


and the class just has the dvbtriple and error as null

my code is as follows :

Call :
C#
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "DVBAlert")]
DVBAlertResponse DVBAlert(DVBAlertDetails AlertDetails);

Classes :
C#
[DataContract(Namespace = "")]
public class DVBTriple
{
    [DataMember]
    public int NetworkId { get; set; }

    [DataMember]
    public int ServiceId { get; set; }

    [DataMember]
    public int TransponderId { get; set; }
}

[DataContract(Namespace = "")]
public class Error
{
    [DataMember]
    public string ErrorType { get; set; }

    [DataMember]
    public string ErrorDescription { get; set; }
}

[DataContract(Namespace = "")]
public class DVBAlertDetails
{
    [DataMember]
    public int SessionID { get; set; }

    [DataMember]
    public DVBTriple DVBTriple { get; set; }

    [DataMember]
    public int Priority { get; set; }

    [DataMember]
    public List<Error> Errors { get; set; }
}

XMl Being posted :
XML
<DVBAlertDetails xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <SessionID>9999</SessionID>
  <DVBTriple>
    <NetworkId>3</NetworkId>
    <ServiceId>4</ServiceId>
    <TransponderId>5</TransponderId>
  </DVBTriple>
  <Priority>8888</Priority>
  <Errors>
    <Error>
      <ErrorType>Type</ErrorType>
      <ErrorDescription>Descr</ErrorDescription>
    </Error>
  </Errors>
</DVBAlertDetails>


Any help would be apreciated
Posted
Comments
Suvabrata Roy 28-Oct-14 6:58am    
You want to build a REST service with post Method ?
Hein_vdw 28-Oct-14 8:20am    
i have the service, it just doesnt read/parse the XML correctly, it only gets the first element in the xml data the rest turns into nulls
Suvabrata Roy 28-Oct-14 14:09pm    
where in server side or client side
Hein_vdw 29-Oct-14 2:01am    
The xml from clientside is good, but as soon as it gets serverside the elements become null

1 solution

Ended up using a DataContractSerializer instead of a xmldocument from the clientside
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900