triton
triton

Reputation:

Managed C++ Web reference to WCF service problems

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);

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?

Upvotes: 0

Views: 849

Answers (1)

Reputation:

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

Upvotes: 1

Related Questions