0
I am doing an integration with an API in SOAP, in one of the methods need to pass as parameter a value of an API class, the problem is that I receive this parameter in the format String and need to convert it to the proprietary class Token of the API. I tried to use the code below without success, where I get the following error:
Error CS0266 Cannot implicitly convert type 'object' to 'WebService.Token'. An explicit conversion exists (are you missing a cast?)
Note: I tried to add the implicit element, but could not.
My code:
NFeClient client = new();
var result = client.SendOperation(arq);
//error converting string to Token class
Token token = Convert.ChangeType(result.ReturnCode, typeof(string));
var result = client.SendFile(token);
Class that will receive the parameter:
public partial class NFeClient : ServiceModel.ClientBase<WebService.INFe>, WebServiceTransben.INFe
{
public WebService.RetornoOfint SendFile(Token token)
{
return base.Channel.SendFile(token);
}
}
private string ReturnCodeField;
public string ReturnCode
{
get
{
return this.ReturnCodeField;
}
set
{
this.ReturnCodeField = value;
}
}