Search code examples
c#androidwcfsoapksoap2

WCF SOAP receive empty list


I have an Android application and an WCF Service to store data. I try to send a request to the service, with the Android application (using kSOAP2). All works fine, but.. When I tried to send list (simple string or integer list) to the service, the WCF service recept the message but the list is always empty !

My SOAP message is like that :

<MyList>
    <int>12</int>
    <int>50</int>
</MyList>

No error in client or service... But the list is always empty and I have no idea why. Someone know the correct format for WCF list ?

Thanks in advance.

Edit :

My interface in service :

[ServiceContract(Namespace = MyService.NamespaceV3)]
public interface IMyService
{
    [OperationContract]
    void MarkMessagesAsRead(List<int> ids, DateTime readDate, int employeeId);
}

Parameters readDate and employeeId works properly, but the list ids is always empty (not null but empty).

Edit 2 :

My complete request is :

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
    <v:Header />
    <v:Body>
        <MarkMessagesAsRead xmlns="http://schemas.xxx.fr/Mobile">
            <ids><int>10293</int><int>10295</int></ids>
            <readDate i:type="d:DateTime">2015-10-19T16:32:44.04</readDate>
            <employeeId i:type="d:int">18572</employeeId>
        </MarkMessagesAsRead>
    </v:Body>
</v:Envelope>

Solution

  • Ok, I have found the solution: I simply add the correct namespace to the "int" element in the list.

    The namespace to use for arrays and list is : http://schemas.microsoft.com/2003/10/Serialization/Arrays