KevinRF
KevinRF

Reputation: 602

Delphi unable to serialize WCF service collections (lists/arrays of integers, strings, objects, etc.) correctly

Attempting to pass a collection (array of integers, strings, List of objects, doesn't matter) via WCF (developed in Visual Studio 2012), the items inside the collection are not not present. No errors, the collection property on the complex object itself isn't null, and only the collection's content is missing.

The service interface contains a number of methods with data contracts from various satellite assemblies:

[OperationContract]
EmailPreferencesUpdateResponse UpdateEmailPreferences(EmailPreferencesUpdateRequest request);

public class EmailPreferencesUpdateRequest
{
    public int EmailId { get; set; }
    public string AccountNumber { get; set; }
    public int EmailFormat { get; set; }
    public string EmailAddress { get; set; }
    public int[] EmailPreferences { get; set; }
}

Using Fiddler, the Delphi generated SOAP request is slightly different than the message generated by the WCF test client:

Fiddler

I've tested this behavior in Delphi 2010, XE2, and easily reproducible in any WCF service with a method where a complex data-transfer-object parameter contains a collection (array, List, IEnumerable, doesn't matter).

Is there a 'trick' to getting the Delphi SOAP namespace correct? Is there an Delphi WSDL import option (using the WSDL import UI) missing (or I need to un-check): WSDL Import Options

Is there something I can do to the WCF service itself that wouldn't break existing contracts?

I've already made sure the endpoint is basicHttpBinding, tried using the XmlSerializerFormat (image below, which it sorta' works for Delphi, ran into other issues), but breaks already existing contracts used throughout existing .Net clients/implementations.

[ServiceContract(Name = "Delphi", Namespace = "SomeRandomNamespace")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]
public interface IDelphiCompatibleOrderTakingService

Upvotes: 2

Views: 1388

Answers (1)

KevinRF
KevinRF

Reputation: 602

I was able to resolve the issue by selecting 'Map pure collections to wrapper class types'

WSDL Import Options Dialog

Upvotes: 4

Related Questions