RMNETTest in Visual COBOL

[Migrated content. Thread originally posted on 18 November 2011]


I am trying to figure out how to replicate this program based on a RM/COBOL example in Visual COBOL:
       identification division.
       program-id.  RMNetTest.

       data division.
       working-storage section.

       01  prservices2.
           02  men-mensaje        pic x(30) value "texto del mensaje".

       01  request-payload             usage pointer.
       01  response-payload            usage pointer.
       01  response-error              usage pointer.
       01  response-status             pic 9(3) value zero.
       01  response-len                pic s9(4).
       01  a-single-char               pic x.
       01  longrequest.
           02 filler                   pic x occurs 1 to 65000
                                         times depending on counters.
       01 counters                     pic 9(5).

       01 Returned-text                pic x(1031).

       78  Desired-SOAPAction value  'SOAPAction' & x"00" &
             '"tempuri.org/.../message"' & x"00".

       78  Post-Address value

       78  ContentType value  "text/xml; charset=utf-8".

           Copy "lixmlall.cpy".

       linkage section.

       01 http-response pic x.
       01 http-error pic x.

       procedure division.
           display "Liant RMNet Test"
             line 1 position 10 erase.

           xml initialize.
           if not xml-ok then
              display "error inicializando xml"
              stop run

           XML EXPORT TEXT
           if not XML-OK then
              display "error export text"
              stop run

           call "NetInit" giving response-status.
           if not response-status = 0
               display "Error NetInit! ", response-status
               call "NetGetError" giving response-error
               set address of http-error to response-error
               display "Error message: ", http-error(1:)

             stop run
           display "call netsetsslca".
           call "NetSetSSLCA" using "cert_desa_ipsCA_root.pem".

           display "httpsetcookiefile".
           call "HttpSetCookieFile" giving response-status.
           if not response-status = 0
               display "Error HttpSetCookieFile! ", response-status
               call "NetGetError" giving response-error
               set address of http-error to response-error
               display "Error message: ", http-error(1:)

             stop run

           perform b.

           XML TERMINATE.
           Stop Run.

           set response-payload to address of Returned-text.

           display "httphost".
           call "HttpPost" using

           if not response-status = 0
               display "Error HttpPost! ", response-status
               call "NetGetError" giving response-error
               set address of http-error to response-error
               display "Error message: ", http-error(1:)

             stop run

      *    set address of http-response to response-payload.

           display "Response: ", response-status.

           if response-payload = NULL
               display "Error:  NULL pointer returned", line 10, blink
               accept a-single-char prompt
               stop run

           xml put text
           if not xml-ok then
              display "error en xml"
              stop run
           call "NetFree" using response-payload.

The template that I am using to communicate with the web service is like this:
<?xml version='1.0' ?>
<xsl:stylesheet    version="1.0" xmlns:xsl="www.w3.org/.../Transform">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
      <soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/.../" xmlns:ns0="tc" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance">
                  <message soapenv:encodingStyle='schemas.xmlsoap.org/.../' xsi:type='xsd:string'>
                        <xsl:value-of select="prservices2/men-mensaje"/>

I suppose I have to use 'System.Xml' in the way you will do it when you are working with C#. But... after that? What is the equivalent to 'call "NetInit"', 'call "NetSetSSLCA"', 'call "HttpSetCookieFile"', and so on?

Thank you

  • Verified Answer

    The RM/COBOL program that you are converting to Visual COBOL uses XML Extensions and RMNet in order to consume a web service. In Visual COBOL, however, you should use the .NET WCF service components to consume web services.

    There is no need to use RMNet, an http client, or XML Extensions in order to consume web services in Visual COBOL as Microsoft, through .NET, has provided extremely convenient and easy-to-use mechanisms for accessing web services. Therefore, you will need to rework/rewrite this program to remove the RMNet and XML Extensions elements, and, replace them with the .NET web services mechanisms.

    The Visual COBOL for Visual Studio documentation contains a tutorial for both creating a WCF service and a WCF client that consumes the service. The Visual COBOL for Visual Studio documentation can be found on our website at the following location:


    The tutorial on "Creating and Accessing WCF COBOL Services" can be found in the following section of the documentation:

    Micro Focus Developer->Micro Focus Visual COBOL for Visual Studio->Programming->WCF and COBOL->Tutorial: Creating and Accessing WCF COBOL Services

    I would recommend going through this tutorial, first, in order to get an idea of how the .NET WCF service mechanisms are implemented and, then, apply that process to your particular RMNet/XML Extensions programs.