views:

366

answers:

1

Hi, I deveploped a simple WCF service called CLSAPIService that it's Contract contains a method named UpdateLastOpenCloseCall:

    [OperationContract(Name = "UpdateLastOpenCloseCall", Action = "http://uniform.com/UpdateLastOpenCloseCall")]
    CallResult UpdateLastOpenCloseCall(int iSwitchID, int iAgentID, string strExtension, BusinessDataField[] bdFields);

, that one of its parameters is a simple DataContract:

[DataContract]
public struct BusinessDataField
{
    [DataMember]
    public string Name;
    [DataMember]
    public object Value;
}

then I created a simple testing project in Managed C++ in Visual .Net 2005, and created web reference for the service:

    CLSAPIProxy::CLSAPIService^ service = gcnew CLSAPIProxy::CLSAPIService();
    CLSAPIProxy::BusinessDataField ^f1 = gcnew CLSAPIProxy::BusinessDataField();
    f1->Name = L"test_string";
    f1->Value = L"string";

    CLSAPIProxy::BusinessDataField ^f2 = gcnew CLSAPIProxy::BusinessDataField();
    f2->Name = L"test_int";
    f2->Value = 123;

    System::Collections::Generic::List<CLSAPIProxy::BusinessDataField^> ^list = gcnew System::Collections::Generic::List<CLSAPIProxy::BusinessDataField^>();
    list->Add(f1);
    list->Add(f2);
    service->UpdateLastOpenCloseCall(1,true,22817,true,L"24319",list->ToArray());

when the BusinessDataField structure arrives to the WCF method, it appears that only the Value property is updated, and the Name property is null, even though I assiged it a value.

what could be the problem?

A: 

Dear Trtion please add Order to your data member. [DataMember(Name = "FirstName", IsRequired = true, Order = 2)] and consult the following article: Change The Order Of data members