C ++ Managed Web Reference to WCF Service Issues
I developed a simple WCF service called CLSAPIService in which Content contains an UpdateLastOpenCloseCall method:
[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 test project in Managed C ++ in Visual.Net 2005 and created a web link 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 in a WCF method, it seems that only the Value property is updated and the Name property is null
      
        
        
        
      
    , even though I assigned a value to it.
What could be the problem?
0 
triton 
source
to share
      
1 answer
      
        
        
        
      
    
add the order to your data member. [DataMember (Name = "FirstName", IsRequired = true, Order = 2 )] and refer to the following article: Reorder Data Items
+1