Marco Mendoza
Member
Hello,
With the followinf code I get the MESSAGE VIEW-AS error:
http error: 415
Message: Cannot process the message because the content type 'text/xml; charset="ISO-8859-1"' was not the expected type 'text/xml; charset=utf-8'.
How can I change the Content type from ISO-8859-1 to UTF-8?
With the followinf code I get the MESSAGE VIEW-AS error:
http error: 415
Message: Cannot process the message because the content type 'text/xml; charset="ISO-8859-1"' was not the expected type 'text/xml; charset=utf-8'.
Code:
USING OpenEdge.Core.*.
USING OpenEdge.Net.HTTP.*.
USING OpenEdge.Net.HTTP.IHttpClientLibrary.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.
USING OpenEdge.Net.URI.
DEFINE VARIABLE cDLC AS CHARACTER NO-UNDO.
DEFINE VARIABLE oLib AS IHttpClientLibrary NO-UNDO.
DEFINE VARIABLE cSSLProtocols AS CHARACTER EXTENT 1 NO-UNDO.
DEFINE VARIABLE cSSLCiphers AS CHARACTER EXTENT 1 NO-UNDO.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
DEFINE VARIABLE oURI AS URI NO-UNDO.
DEFINE VARIABLE oRequestBody AS OpenEdge.Core.String NO-UNDO.
DEFINE VARIABLE hXMLHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE lcXML AS LONGCHAR NO-UNDO.
ASSIGN cSSLProtocols[1] = 'TLSv1.2'
cSSLCiphers[1] = 'ECDHE-RSA-AES256-GCM-SHA384'.
/* Web Service based on this public WS http://www.dneonline.com/calculator.asmx . It consumes the WebService executing the Add Operation. */
oRequestBody = NEW OpenEdge.Core.String(
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">' +
' <soapenv:Header/>' +
' <soapenv:Body>' +
' <tem:Consulta>' +
' <tem:expresionImpresa>' +
'<![CDATA[?re=CBE070913344&rr=CCO0309098N8&tt=28903.17&id=04C979D3-2D0F-45A1-AD80-E4625B7C5192]]>' +
' </tem:expresionImpresa>' +
' </tem:Consulta>' +
' </soapenv:Body>' +
'</soapenv:Envelope>'
).
oLib = ClientLibraryBuilder:Build()
:sslVerifyHost(NO)
:SetSSLProtocols(cSSLProtocols)
:SetSSLCiphers(cSSLCiphers)
:Library.
oURI = URI:Parse("https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc").
oRequest = RequestBuilder:Post(oUri, oRequestBody)
:ContentType('text/xml;charset=UTF-8')
:AcceptAll()
:AddHeader('SOAPAction', 'http://tempuri.org/IConsultaCFDIService/Consulta')
:Request.
oResponse = ClientBuilder:Build()
:UsingLibrary(oLib)
:Client
:Execute(oRequest).
IF oResponse:StatusCode <> 200 THEN
DO:
MESSAGE "http error: " oResponse:StatusCode SKIP
"Message: " oResponse:StatusReason VIEW-AS ALERT-BOX.
RETURN ERROR "Request Error: " + STRING(oResponse:StatusCode).
END.
ELSE
DO:
hXMLHandle = CAST(oResponse:Entity,WidgetHandle):Value.
hXMLHandle:SAVE('LONGCHAR',lcXML).
MESSAGE STRING(lcXML) VIEW-AS ALERT-BOX.
END.
How can I change the Content type from ISO-8859-1 to UTF-8?