Hello Community, first of all thank you very much for taking the time to read my question
I have a small problem with a development in Nav 2018, I have to consume a web service, I know how to do it by programming in Visual Studio Code with the AL extension
But right now I am developing with C / AL and I see that HttpClient variables are used as .NET variables
In AL I do it in the following way and the consumption of the web service works correctly for me
codeunit 50600 "Test Web Service"
{
procedure TestWebService(PBARFCEmisor: Text; PBARFCReceptor: Text; PBATotal: Text; PBAUUID: Text) //procedure TestWebServiceDoBrasil(var PBAXMLinTEXT: Text)
var
XMLDomMgt: Codeunit "XML DOM Mgt.";
PBAXML: Text;
PBADOCUMETXML: XmlDocument;
uri: Text;
RequestHeaders: HttpHeaders;
RequestMessage: HttpRequestMessage;
RequestContent: HttpContent;
HttpClient: HttpClient;
ResponseMessage: HttpResponseMessage;
Content: HttpContent;
text2Send: Text;
PushHttpAddress: Text[80];
lSuccess: Boolean;
ResponseInText: Text;
Pos: Integer;
Length: Integer;
PBAEstado: Text;
begin
///////////////////// Construccion XML exitosa //////////
PBAXML := '?re=' PBARFCEmisor '&rr=' PBARFCReceptor '&tt=' PBATotal '&id=' PBAUUID '';
XMLDomMgt.LoadXMLDocumentFromText(PBAXML, PBADOCUMETXML);
PBADOCUMETXML.WriteTo(PBAXML);
//PBAXMLinTEXT := PBAXML;
//Message(PBAXML);
///Construccion de la Llamada Web Service///
content.Clear();
HttpClient.Clear();
RequestHeaders.Clear();
RequestMessage.Content().Clear();
ResponseMessage.Content().Clear();
ResponseMessage.Headers().Clear();
lSuccess := False;
PushHttpAddress := 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl';
uri := pushHttpAddress;
RequestMessage.SetRequestUri(uri);
RequestMessage.Method := 'POST';
text2Send := PBAXML;
RequestContent.writefrom(Text2Send);
RequestContent.GetHeaders(RequestHeaders);
RequestHeaders.Remove('Content-Type');
RequestHeaders.Add('Content-Type', 'text/xml; charset=utf-8');
RequestHeaders.Add('SOAPAction', 'http://tempuri.org/IConsultaCFDIService/Consulta');
RequestMessage.Content(RequestContent);
if not HttpClient.Send(RequestMessage, ResponseMessage) then begin
Error('Error en el Web Service');
end;
Content := ResponseMessage.Content();
Content.ReadAs(ResponseInText);
lSuccess := ResponseMessage.IsSuccessStatusCode();
//Message(ResponseInText);
Pos := StrPos(ResponseInText, '') 10;
Length := StrPos(ResponseInText, '');
Length := Length - Pos;
PBAEstado := CopyStr(ResponseInText, Pos, Length);
Message('CFDI: ' PBAEstado);
end;
}
My question is how can I do the above code in C / AL using .NET variables
Thanks again for your time.