I'm attempting to prepare my application code to accept an annual change of a third-party wsdl
. I cannot make and have no control over the design of this wsdl
. Objects within this wsdl
may change, have items added, be removed, etc. However, I still need to keep the previous version(s) of the wsdl
.
My plan is to add the current wsdl
as a Service Reference, as I did with the previous wsdl
.
At the moment, I have multiple methods similar to that below (including the one below).
Using a property, TaxYear
to determine which wsdl
to actually reference: "Service2015" or "Service2016". I am passing in generic objects representing the objects from the wsdl
, and passing in a ref
parameter for those objects which I use in a parent method.
Refacotring like this, imposes a LOT of bloat, and I can't help but think there has to be a better way to do what I'm trying to do.
Is there a better way at doing this using C#, or is this the best and most inconvenient way of doing what I need to accomplish.
private static void RetrieveRequestObject(ref object objRequest, object objBusinessHeader, object objSecurityHeader, object objManifestHeader, object objFormData)
{
if (TaxYear.Equals(2015))
{
objRequest = new Service2015.BulkRequestTransmitterRequest()
{
ACABusinessHeader = (Service2015.ACABulkBusinessHeaderRequestType)objBusinessHeader,
Security = (Service2015.SecurityHeaderType)objSecurityHeader,
ACATransmitterManifestReqDtl = (Service2015.ACATrnsmtManifestReqDtlType)objManifestHeader,
ACABulkRequestTransmitter = (Service2015.ACABulkRequestTransmitterType)objFormData
};
}
else if (TaxYear.Equals(2016))
{
objRequest = new Service2016.BulkRequestTransmitterRequest()
{
ACABusinessHeader = (Service2016.ACABulkBusinessHeaderRequestType)objBusinessHeader,
Security = (Service2016.SecurityHeaderType)objSecurityHeader,
ACATransmitterManifestReqDtl = (Service2016.ACATrnsmtManifestReqDtlType)objManifestHeader,
ACABulkRequestTransmitter = (Service2016.ACABulkRequestTransmitterType)objFormData
};
}
}