Error Error in Consuming Service (v11.3.3)

patelspam

Member
Hey there!

Some weeks back, this site 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml' passed from "http" to "https" so I was tasked with fixing the original code so it would work in every client. I managed to do so, but i realised that the code wasn't compatible with some of the Progress versions.
I managed to fix on several versions (3 already) and now I caught one (11.3.3) that is complaning about "methodenum":1664889239011.png
But the only "fix" i found was to upgrade the version. However the client doesn't want that.
Is there any other way to go around it?

This is the code i use for those tests. The syntax is validated. I already added the certificates (the same ones i used on the other clients).
If you comment the chypers + protocols, it will throw the errors i refered before. If you don't, and run the code, the editor will shut down with no message.

Code:
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.   
USING OpenEdge.Net.HTTP.IHttpClientLibrary.   
USING OpenEdge.Net.HTTP.IHttpClient.     
USING System.Net.*.

DEFINE TEMP-TABLE xml-cambio NO-UNDO
    FIELD seq       AS INT
    FIELD NAME      AS CHARACTER
    FIELD nodevalue AS CHARACTER
    FIELD PARENT    AS CHARACTER
    FIELD level     AS INT
    FIELD moeda_cod AS CHAR      FORMAT "X(10)":U
    FIELD valor     LIKE ct_camb.camb_valor1.

DEFINE VARIABLE oRequest   AS IHttpRequest         NO-UNDO.
DEFINE VARIABLE oResponse  AS IHttpResponse        NO-UNDO.

DEFINE VARIABLE jsonObject AS Progress.Lang.Object NO-UNDO.
      
/* ***************************  Main Block  *************************** */

DEFINE VARIABLE oLib          AS IHttpClientLibrary NO-UNDO.
DEFINE VARIABLE oClient       AS IHttpClient        NO-UNDO.
DEFINE VARIABLE cSSLProtocols AS CHARACTER EXTENT   NO-UNDO.
DEFINE VARIABLE cSSLCiphers   AS CHARACTER EXTENT   NO-UNDO.

/* the size and values of the SSL protocols and ciphers depend on the server*/
EXTENT(cSSLProtocols) = 2.
EXTENT(cSSLCiphers) = 10.

/* TLSv1.1 and TLSv1.2 are supported with OpenEdge 11.6 and later.  See article What version of SSL and/or TLS does Progress OpenEdge use ?
 Supported ciphers and protocols at https://docs.progress.com/bundle/openedge-security-and-auditing/page/Supported-protocols-ciphers-and-certificates-for-OpenEdge-clients-and-servers.html */
ASSIGN cSSLProtocols[1] = 'TLSv1.2' 
       cSSLProtocols[2] = 'TLSv1.1'
       cSSLCiphers[1]  = 'AES128-SHA256'
       cSSLCiphers[2]  = 'DHE-RSA-AES128-SHA256'
       cSSLCiphers[3]  = 'AES128-GCM-SHA256'
       cSSLCiphers[4]  = 'DHE-RSA-AES128-GCM-SHA256'
       cSSLCiphers[5]  = 'ADH-AES128-SHA256'
       cSSLCiphers[6]  = 'ADH-AES128-GCM-SHA256'
       cSSLCiphers[7]  = 'ADH-AES256-SHA256'
       cSSLCiphers[8]  = 'AES256-SHA256'
       cSSLCiphers[9]  = 'DHE-RSA-AES256-SHA256'
       cSSLCiphers[10] = 'AES128-SHA'
       .
oLib = ClientLibraryBuilder:Build()
                    :SetSSLProtocols(cSSLProtocols)
                    :SetSSLCiphers(cSSLCiphers)
                    :Library.
                    
oClient = ClientBuilder:Build()
                :UsingLibrary(oLib)
                :Client.

                  
oRequest = RequestBuilder:Get('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'):Request.

oResponse = OpenEdge.Net.HTTP.ResponseBuilder:Build():Response.
OpenEdge.Net.HTTP.ClientBuilder:Build():UsingLibrary(oLib):Client:Execute(oRequest,oResponse).

jsonObject = oResponse:entity .


DEFINE VARIABLE hXml        AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml2       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml3       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml4       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild  AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild2 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild3 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild4 AS HANDLE  NO-UNDO.
DEFINE VARIABLE jx          AS INTEGER NO-UNDO.
DEFINE VARIABLE jx2         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx3         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx4         AS INTEGER NO-UNDO.

CREATE X-DOCUMENT hXml.
CREATE X-DOCUMENT hXml2.
CREATE X-DOCUMENT hXml3.
CREATE X-DOCUMENT hXml4.
CREATE X-NODEREF hNodeChild.
CREATE X-NODEREF hNodeChild2.
CREATE X-NODEREF hNodeChild3.
CREATE X-NODEREF hNodeChild4.

hXml = CAST(oResponse:Entity, OpenEdge.Core.WidgetHandle):Value.

REPEAT jx = 1 TO hXml:NUM-CHILDREN:
    hXml:GET-CHILD(hNodeChild, jx).
    
    hXml2 = hNodeChild.
    REPEAT jx2 = 1 TO hXml2:NUM-CHILDREN:
        hXml2:GET-CHILD(hNodeChild2, jx2).
        hXml3 = hNodeChild2.
        REPEAT jx3 = 1 TO hXml3:NUM-CHILDREN:
            hXml3:GET-CHILD(hNodeChild3, jx3).
            hXml4 = hNodeChild3.
            REPEAT jx4 = 1 TO hXml4:NUM-CHILDREN:
                hXml4:GET-CHILD(hNodeChild4, jx4).
                
                /* MESSAGE "jx " jx
                     SKIP
                     "jx2 " jx2
                     SKIP
                     "jx3 " jx3
                     SKIP
                     "jx4 " jx4
                     SKIP
                     "hNodeChild4:NODE-VALUe " hNodeChild4:NODE-VALUE
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:num-children
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:subtype
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-PREFIX
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-URI
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:ATTRIBUTE-NAMES
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("time")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("currency")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("rate")
                     VIEW-AS ALERT-BOX.
                     */
                IF hNodeChild4:GET-ATTRIBUTE("currency":U) <> "":U THEN
                DO:
                    CREATE xml-cambio.
                    ASSIGN
                        xml-cambio.moeda_cod = hNodeChild4:GET-ATTRIBUTE("currency":U)
                        xml-cambio.valor     = DEC(replace(hNodeChild4:GET-ATTRIBUTE("rate":U),".":U,",":U))
                        NO-ERROR.
                END.
            END.
        END.
    END.
END.
 FOR EACH xml-cambio NO-LOCK:
          DISPLAY xml-cambio WITH 1 COL SCROLLABLE.
          END.
          PAUSE.

/*MESSAGE
    oResponse:StatusCode SKIP   
    oResponse:StatusReason SKIP
    oresponse:ContentLength SKIP
    oResponse:Entity SKIP
    CAST(oResponse:Entity, OpenEdge.Core.WidgetHandle):VALUE skip
    STRING(hXml)
    VIEW-AS ALERT-BOX.*/

/*
USING System.Net.Http.*.
USING System.Environment.

DEFINE VARIABLE HttpClient AS CLASS System.Net.WebClient.
DEFINE VARIABLE webResponse AS LONGCHAR NO-UNDO.
FIX-CODEPAGE (webResponse) = "UTF-8".

HttpClient = NEW System.Net.WebClient().
HttpClient:Proxy:Credentials = System.Net.CredentialCache:DefaultNetworkCredentials.
System.AppContext:SetSwitch("Switch.System.Net.DontEnableSchUseStrongCrypto", false).

webResponse = HttpClient:DownloadString('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml').

HttpClient:Dispose().
DELETE OBJECT HttpClient.

MESSAGE STRING(webResponse) SKIP
    Environment:VERSION VIEW-AS ALERT-BOX.
    */
 
Here is my bodge code since the client it not willing to update the OE version.

I've spent a total of 25 mins to hack this together. Is does rely on curl being installed, but that's standard with Windows 10. these days.

Code:
DEFINE TEMP-TABLE xml-cambio NO-UNDO
    FIELD seq       AS INT
    FIELD NAME      AS CHARACTER
    FIELD nodevalue AS CHARACTER
    FIELD PARENT    AS CHARACTER
    FIELD level     AS INT
    FIELD moeda_cod AS CHAR      FORMAT "X(10)":U
    FIELD valor     AS INT.


DEFINE VARIABLE cStandardIn AS CHARACTER   NO-UNDO.

DEFINE variable cOSCommand AS CHARACTER   NO-UNDO.
define stream sOSStream.


      
/* ***************************  Main Block  *************************** */



DEFINE VARIABLE hXml        AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml2       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml3       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml4       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild  AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild2 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild3 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild4 AS HANDLE  NO-UNDO.
DEFINE VARIABLE jx          AS INTEGER NO-UNDO.
DEFINE VARIABLE jx2         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx3         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx4         AS INTEGER NO-UNDO.

CREATE X-DOCUMENT hXml.
CREATE X-DOCUMENT hXml2.
CREATE X-DOCUMENT hXml3.
CREATE X-DOCUMENT hXml4.
create X-NODEREF hNodeChild.
CREATE X-NODEREF hNodeChild2.
CREATE X-NODEREF hNodeChild3.
CREATE X-NODEREF hNodeChild4.

DEFINE VARIABLE cOutfile AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cCurlError AS CHARACTER   NO-UNDO.

assign
    cOutfile = substitute("&1\&2-eurofxref-daily.xml", session:temp-dir, weekday(today) ).
    cOutfile = replace(cOutfile, '\\','\').
    
file-info:file-name = cOutfile.

//delete last know XML file if it exists. 
if file-info:full-pathname ne ? then
    os-delete value(cOutfile).

cOSCommand = substitute('curl https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml --output "&1" --silent --show-error', cOutfile ).

input stream sOSStream through value(cOSCommand).

repeat:

    import stream sOSStream unformatted cStandardIn.
    
    cCurlError = cCurlError + cStandardIn + '~r~n'.
    
    message cStandardIn.

end.

input stream  sOSStream close.

file-info:file-name = cOutfile.

   

if cCurlError ne "" or file-info:full-pathname eq ? then
do:

    message "Error downloading file" skip cCurlError
        view-as alert-box error.
        
    return error "eurofxref-daily.xml was not downloaded".        
    
end.

//Load the xml from file.
hXml:LOAD ( "FILE", cOutfile, false).

REPEAT jx = 1 TO hXml:NUM-CHILDREN:
    hXml:GET-CHILD(hNodeChild, jx).
    
    hXml2 = hNodeChild.
    REPEAT jx2 = 1 TO hXml2:NUM-CHILDREN:
        hXml2:GET-CHILD(hNodeChild2, jx2).
        hXml3 = hNodeChild2.
        REPEAT jx3 = 1 TO hXml3:NUM-CHILDREN:
            hXml3:GET-CHILD(hNodeChild3, jx3).
            hXml4 = hNodeChild3.
            REPEAT jx4 = 1 TO hXml4:NUM-CHILDREN:
                hXml4:GET-CHILD(hNodeChild4, jx4).
                
                /* MESSAGE "jx " jx
                     SKIP
                     "jx2 " jx2
                     SKIP
                     "jx3 " jx3
                     SKIP
                     "jx4 " jx4
                     SKIP
                     "hNodeChild4:NODE-VALUe " hNodeChild4:NODE-VALUE
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:num-children
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:subtype
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-PREFIX
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-URI
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:ATTRIBUTE-NAMES
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("time")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("currency")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("rate")
                     VIEW-AS ALERT-BOX.
                     */
                IF hNodeChild4:GET-ATTRIBUTE("currency":U) <> "":U THEN
                DO:
                    CREATE xml-cambio.
                    ASSIGN
                        xml-cambio.moeda_cod = hNodeChild4:GET-ATTRIBUTE("currency":U)
                        xml-cambio.valor     = DEC(replace(hNodeChild4:GET-ATTRIBUTE("rate":U),".":U,",":U))
                        NO-ERROR.
                END.
            END.
        END.
    END.
END.
 FOR EACH xml-cambio NO-LOCK:
          DISPLAY xml-cambio WITH 1 COL SCROLLABLE.
          END.
          PAUSE.
 
Here is my bodge code since the client it not willing to update the OE version.

I've spent a total of 25 mins to hack this together. Is does rely on curl being installed, but that's standard with Windows 10. these days.

Code:
DEFINE TEMP-TABLE xml-cambio NO-UNDO
    FIELD seq       AS INT
    FIELD NAME      AS CHARACTER
    FIELD nodevalue AS CHARACTER
    FIELD PARENT    AS CHARACTER
    FIELD level     AS INT
    FIELD moeda_cod AS CHAR      FORMAT "X(10)":U
    FIELD valor     AS INT.


DEFINE VARIABLE cStandardIn AS CHARACTER   NO-UNDO.

DEFINE variable cOSCommand AS CHARACTER   NO-UNDO.
define stream sOSStream.


     
/* ***************************  Main Block  *************************** */



DEFINE VARIABLE hXml        AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml2       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml3       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hXml4       AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild  AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild2 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild3 AS HANDLE  NO-UNDO.
DEFINE VARIABLE hNodeChild4 AS HANDLE  NO-UNDO.
DEFINE VARIABLE jx          AS INTEGER NO-UNDO.
DEFINE VARIABLE jx2         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx3         AS INTEGER NO-UNDO.
DEFINE VARIABLE jx4         AS INTEGER NO-UNDO.

CREATE X-DOCUMENT hXml.
CREATE X-DOCUMENT hXml2.
CREATE X-DOCUMENT hXml3.
CREATE X-DOCUMENT hXml4.
create X-NODEREF hNodeChild.
CREATE X-NODEREF hNodeChild2.
CREATE X-NODEREF hNodeChild3.
CREATE X-NODEREF hNodeChild4.

DEFINE VARIABLE cOutfile AS CHARACTER   NO-UNDO.
DEFINE VARIABLE cCurlError AS CHARACTER   NO-UNDO.

assign
    cOutfile = substitute("&1\&2-eurofxref-daily.xml", session:temp-dir, weekday(today) ).
    cOutfile = replace(cOutfile, '\\','\').
   
file-info:file-name = cOutfile.

//delete last know XML file if it exists.
if file-info:full-pathname ne ? then
    os-delete value(cOutfile).

cOSCommand = substitute('curl https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml --output "&1" --silent --show-error', cOutfile ).

input stream sOSStream through value(cOSCommand).

repeat:

    import stream sOSStream unformatted cStandardIn.
   
    cCurlError = cCurlError + cStandardIn + '~r~n'.
   
    message cStandardIn.

end.

input stream  sOSStream close.

file-info:file-name = cOutfile.

  

if cCurlError ne "" or file-info:full-pathname eq ? then
do:

    message "Error downloading file" skip cCurlError
        view-as alert-box error.
       
    return error "eurofxref-daily.xml was not downloaded".       
   
end.

//Load the xml from file.
hXml:LOAD ( "FILE", cOutfile, false).

REPEAT jx = 1 TO hXml:NUM-CHILDREN:
    hXml:GET-CHILD(hNodeChild, jx).
   
    hXml2 = hNodeChild.
    REPEAT jx2 = 1 TO hXml2:NUM-CHILDREN:
        hXml2:GET-CHILD(hNodeChild2, jx2).
        hXml3 = hNodeChild2.
        REPEAT jx3 = 1 TO hXml3:NUM-CHILDREN:
            hXml3:GET-CHILD(hNodeChild3, jx3).
            hXml4 = hNodeChild3.
            REPEAT jx4 = 1 TO hXml4:NUM-CHILDREN:
                hXml4:GET-CHILD(hNodeChild4, jx4).
               
                /* MESSAGE "jx " jx
                     SKIP
                     "jx2 " jx2
                     SKIP
                     "jx3 " jx3
                     SKIP
                     "jx4 " jx4
                     SKIP
                     "hNodeChild4:NODE-VALUe " hNodeChild4:NODE-VALUE
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:num-children
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:subtype
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-PREFIX
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:NAMESPACE-URI
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:ATTRIBUTE-NAMES
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("time")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("currency")
                     SKIP
                     "hNodeChild4:num-children" hNodeChild4:GET-ATTRIBUTE("rate")
                     VIEW-AS ALERT-BOX.
                     */
                IF hNodeChild4:GET-ATTRIBUTE("currency":U) <> "":U THEN
                DO:
                    CREATE xml-cambio.
                    ASSIGN
                        xml-cambio.moeda_cod = hNodeChild4:GET-ATTRIBUTE("currency":U)
                        xml-cambio.valor     = DEC(replace(hNodeChild4:GET-ATTRIBUTE("rate":U),".":U,",":U))
                        NO-ERROR.
                END.
            END.
        END.
    END.
END.
 FOR EACH xml-cambio NO-LOCK:
          DISPLAY xml-cambio WITH 1 COL SCROLLABLE.
          END.
          PAUSE.
Thank you Cecil! That worked like a charm! Have a great day!
 
Back
Top