The CRM returns custom API responses as the correct type when early bound entities/messages are present with the corresponding RequestProxyAttribute and ResponseProxyAttribute (just use the early bound generator v2 from the XrmToolbox to generate those). This is working correctly in the CRM:
var response = service.Execute(new someRequest());
var typedResponse = (someResponse)response;
This only works when the request and response types annotated with the proces attributes are present. FakeXrmEasy doesn't do this. I register a custom API like this:
context.RegisterPluginStep<SomeCustomAPI>(new PluginStepDefinition()
{
MessageName = "whatever",
Stage = FakeXrmEasy.Abstractions.Plugins.Enums.ProcessingStepStage.Postoperation,
});
FakeXrmEasy just returns an OrganizationResponse. Is there any way to make FXE to return the concrete type like the CRM does?
An example of a generated request and response:
[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.RequestProxyAttribute("sit_some_custom_api")]
public partial class SomeRequest: Microsoft.Xrm.Sdk.OrganizationRequest
{
public static class Fields
{
public const string returnAll = "returnAll";
}
public const string ActionLogicalName = "sit_some_custom_api";
public bool? returnAll
{
get
{
if (this.Parameters.Contains("returnAll"))
{
return ((bool)(this.Parameters["returnAll"]));
}
else
{
return default(bool);
}
}
set
{
this.Parameters["returnAll"] = value;
}
}
public SomeRequest()
{
this.RequestName = "sit_some_custom_api";
}
}
[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.ResponseProxyAttribute("sit_some_custom_api")]
public partial class SomeResponse: Microsoft.Xrm.Sdk.OrganizationResponse
{
public static class Fields
{
public const string classifications = "classifications";
}
public const string ActionLogicalName = "sit_some_custom_api";
public SomeResponse()
{
}
public Microsoft.Xrm.Sdk.EntityCollection? classifications
{
get
{
if (this.Results.Contains("classifications"))
{
return ((Microsoft.Xrm.Sdk.EntityCollection)(this.Results["classifications"]));
}
else
{
return default(Microsoft.Xrm.Sdk.EntityCollection);
}
}
set
{
this.Results["classifications"] = value;
}
}
}
The CRM returns custom API responses as the correct type when early bound entities/messages are present with the corresponding
RequestProxyAttributeandResponseProxyAttribute(just use the early bound generator v2 from the XrmToolbox to generate those). This is working correctly in the CRM:This only works when the request and response types annotated with the proces attributes are present. FakeXrmEasy doesn't do this. I register a custom API like this:
FakeXrmEasy just returns an
OrganizationResponse. Is there any way to make FXE to return the concrete type like the CRM does?An example of a generated request and response: