Hello,
I'm converting an application from an equipment supplier, and he provided me with a C# source.
I tried to convert from C# to Cobol, using the "OpenText C# to Micro Focus Visual Cobol Translator" tool, but it is giving me an erro in one of the parts.
The original source:
public async Task<InitialResponse> InitiateOperationAsync(string baseUrl, PaymentRequest paymentRequest)
{
string payJson = JsonSerializer.Serialize(new
{
PAY = new
{
posto = paymentRequest.Posto,
operador = paymentRequest.Operador,
valor = paymentRequest.Valor
}
});
string requestUrl = $"{baseUrl}?PAY={payJson}";
try
{
HttpResponseMessage response = await _httpClient.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<InitialResponse>(content);
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed to initiate payment operation.", ex);
}
}
The result in cobol:
method-id InitiateOperationAsync (baseUrl as string, paymentRequest as type PaymentRequest) yielding return-value as type InitialResponse async final.
declare payJson as string = type JsonSerializer::Serialize(
PAY
posto paymentRequest::Posto
operador paymentRequest::Operador
valor paymentRequest::Valor
)
declare requestUrl as string = string::Format("{0}?PAY={1}", baseUrl, payJson)
try
declare response as type HttpResponseMessage = await _httpClient::GetAsync(requestUrl)
invoke response::EnsureSuccessStatusCode()
declare #content as string = await response::Content::ReadAsStringAsync()
set return-value to type JsonSerializer::Deserialize[type InitialResponse](#content)
goback
catch ex as type Exception
raise new InvalidOperationException("Failed to initiate payment operation.", ex)
end-try
end method.
Can you help me mor one time?
Best regards
Alberto Ferraz
------------------------------
Alberto Ferraz
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------











