I have a string array in datacontract as below
[DataMember(Name = "photos", IsRequired = true, Order = 3)]
public string[] photos { get; set; }
In WCF REST Service call I am passing below xml input for this string array
<photos>
<string>http://localhost:13169/MainPortal/ContentLibrary/21/58/1227132014-bmw-x1_100426158_m.jpg</string>
<string>http://localhost:13169/MainPortal/ContentLibrary/21/58/122713bmw2.jpg</string>
<string>http://localhost:13169/MainPortal/ContentLibrary/21/58/122713bmw3.jpg</string>
<string>http://localhost:13169/MainPortal/ContentLibrary/21/58/122713BMW_Hamann_Laguna_Seca.jpg</string><string>http://localhost:13169/MainPortal/ContentLibrary/21/58/1227132014-BMW-X1-SUV-sDrive-28i-4dr-4x2-Sports-Activity-Vehicle-Exterior-2.png</string>
</photos>
My client code able to make WebService call with passing xml in HttpWebRequest without any issues, from the service I could see all other data coming in except this string array. Am I missing something in DataContract to serialize arrays. Please help
Tried with CollectionDataContract as below still no luck
[CollectionDataContract(Name = "photos")]
public class Photos : Collection<string>
Also added KnownTypes which is however not required for ordinal types
[KnownType(typeof(string[]))]
public class PublishPhotos
{
Here is complete data contract class
[DataContract(Namespace = "http://myurl.com/Publisher")]
[KnownType(typeof(string[]))]
public class PublishPhotos
{
[DataMember(Name = "publicationId", IsRequired = true, Order = 0)]
public int publicationId { get; set; }
[DataMember(Name = "issueId", IsRequired = true, Order = 1)]
public string issueId { get; set; }
[DataMember(Name = "contentId", IsRequired = true, Order = 2)]
public string contentId { get; set; }
[DataMember(Name = "photos", IsRequired = true, Order = 3)]
public Photos photos { get; set; }
}
Finally I figured out what went wrong with XML in HttpWebRequest, the issue is with serializing string array. The easiest way I could have figured out through visiting /PublisherSvc.svc/help for string it requires namespace http://schemas.microsoft.com/2003/10/Serialization/Arrays as below
Hope this helps someone facing similar issue