Reputation: 7030
I'm left with an old code that uses remoting. I need to upgrade this code to WCF.
Quite frankly, I'm stuck on how to redesign the interface that client & server use for communication. It looks like this:
public interface IDDCEngine
{
ReadDiagnosticEntirePointValuesResponse ReadDiagnosticEntirePointValues(string host);
GetEntirePointListResponse GetEntirePointList(string host);
SetSerialPortListResponse SetSerialPointList(string host, SetSerialPortList serialPortList);
SetNationalListResponse SetNationalList(string host, SetNationalList nationalList, int count);
SetModbusListResponse SetModbusList(string host, SetModbusList modbusList, int count);
SetIOPointListResponse SetIOPointList(string host, SetIOPoint pointList, int count);
GetIOPointResponse GetIOPointList(string host);
SetLogicListResponse SetLogicList(string host, SetLogicList logicList, int count);
GetDDCVersionResponse GetDDCVersion(string host);
GetDDCUptimeResponse GetDDCUptime(string host);
GetDDCCPUMemoryStatusResponse GetDDCCPUMemoryStatus(string host, int count);
...about 20 more interfaces
}
And the classes for request/response:
[Serializable]
public class SetIOPoint
{
public string[] pointidentifier;
public string[] pointname;
public string[] pointaddress;
public string[] pointtype;
public string[] devicetype;
public string[] description;
public string[] backup;
public string[] relinquishdefault;
public string[] unit;
public string[] minpresvalue;
public string[] maxpresvalue;
public string[] correctvalue;
public string[] covenable;
public string[] covincrement;
public string[] covtarget;
public string[] covlifetime;
public string[] historyenable;
public string[] historyincrement;
public string[] alarmenable;
public string[] highlimit;
public string[] lowlimit;
public string[] polarity;
public string[] inactivetext;
public string[] activetext;
public string[] feedbackenable;
public string[] feedbacktime;
public string[] numofstates;
public string[] statetext;
}
[Serializable]
public class GetIOPointResponse
{
public string[] pointidentifier;
public string[] pointname;
public string[] pointaddress;
public string[] pointtype;
public string[] devicetype;
public string[] description;
public string[] backup;
public string[] relinquishdefault;
public string[] unit;
public string[] minpresvalue;
public string[] maxpresvalue;
public string[] correctvalue;
public string[] covenable;
public string[] covincrement;
public string[] covtarget;
public string[] covlifetime;
public string[] historyenable;
public string[] historyincrement;
public string[] alarmenable;
public string[] highlimit;
public string[] lowlimit;
public string[] polarity;
public string[] inactivetext;
public string[] activetext;
public string[] feedbackenable;
public string[] feedbacktime;
public string[] numofstates;
public string[] statetext;
}
[Serializable]
public class RequestDDCRebootResponse
{
public string result;
}
[Serializable]
public class GetDDCCurrenttimeResponse
{
public string result;
}
[Serializable]
public class StartDDCBackupResponse
{
public string result;
}
[Serializable]
public class EndDDCBackupResponse
{
public string result;
}
[Serializable]
public class StartDDCRestoreResponse
{
public string result;
}
[Serializable]
public class EndDDCRestoreResponse
{
public string result;
}
...List goes ON
Pretty badly written interfaces and datastructure. I'd like to rewrite the interfaces and the datastructure so that I don't have to define millions of operationcontracts.
Are there any good recommendations on strategies of solid interface and datastructure design for WCF?
Upvotes: 0
Views: 130
Reputation: 172835
Take a look at this article:
Writing Highly Maintainable WCF Services
This article talks writing a WCF service as realy thin layer on top of an SOLIDly designed architectural pattern based on commands and queries. When using this command/query style of programming, the WCF service can be defined as a really tiny piece of infrastructure code that won't have to be changed, even when new operations are added.
Upvotes: 1