Jois_Cool
Jois_Cool

Reputation: 397

Mixed data returned when client calls wcf service

I have wcf service invoked by around 100 clients. I am using Message Channel for this communication. After i get request from client with parameters which has datatable and a string, i invoke a static method to process this data. The processing i do is joining the datatable received from the client with the in memory cache datatable. As given below DTReplyData is the data table.I use the same datatable for input and output i.e my data contract has only one datatable.

public System.ServiceModel.Channels.Message GetData(System.ServiceModel.Channels.Message messageIn)
    {
        ExecutionOutput requestOperation = messageIn.GetBody<ExecutionOutput>();
        DataTable data = Cache.GetData(requestOperation.OperationName,requestOperation.DTReplyData);


    }    
public static DataTable GetData(string operationName,DataTable inputparameters)
    {
        try
        {

            return filterClientData(operationName, inputparameters);
        }
        catch (Exception ex)
        {                               

            return new DataTable();
        }
    }

    public static DataTable filterClientData(string operationName,DataTable inputparameters)
    {
        DataTable permanentcacheData = new DataTable();
        permanentcacheData = (DataTable)permanentCache[operationName];//this gets data from in memory cache

        if (permanentcacheData != null)
        {

            string[] columnNames = (from dc in inputparameters.Columns.Cast<DataColumn>()
                                    select dc.ColumnName).ToArray();
//Helper method invoked to join tables
                DataTableHelper dt = new DataTableHelper();

            DataTable filteredData = dt.JoinTwoDataTablesOnOneColumn(inputparameters, permanentcacheData, columnNames[0], DataTableHelper.JoinType.Inner);



            filteredData.TableName = "FilteredData";

            return filteredData;
        }
        else
        {

            return permanentcacheData;
        }
    }

The problem i am facing is when joining happens even if i create new object the datatable helper is having some data already and data mix up happens which results in errors.Any suggesstion here is this because of static methods used?Or becuase i am using the same datamember for result and request.Ideally this shouldnt create a problem i thought.

Upvotes: 1

Views: 133

Answers (1)

seabass2020
seabass2020

Reputation: 1123

It's most likely from using static methods. I had a similar problem with my WCF service mixing up data, and it was fixed by removing static from my methods.

Upvotes: 1

Related Questions