Rename parameters type for client
-
03-07-2021 - |
Frage
Is there any way to rename types for WCF service client?
For example I have service in two versions (V1 and V2). For each version I have same models (Model1 and Model2), but with versions changes (so I renamed it to Model1V1, Model1V2 and so on).
I want clients of both services to treat models types as Model1 and Model2.
I know I can rename operation contract.
[ServiceContract]
public interface ServiceV1
{
[OperationContract]
Model1V1 SomeOp(Model2V1 arg);
}
[ServiceContract]
public interface ServiceV2
{
[OperationContract]
Model1V2 SomeOp(Model2V2 arg);
}
[DataContract]
public class Model1V1
{
...
}
[DataContract]
public class Model2V1
{
...
}
[DataContract]
public class Model1V2
{
...
}
[DataContract]
public class Model2V2
{
...
}
Lösung
If the client is generated from WSDL/MEX, then this should be as simple as:
[DataContract(Name = "Model1")]
public class Model1V1
{ ...
etc
If the client is using assembly sharing, then it cannot be done, AFAIK.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow