Highlighted
Absent Member.
Absent Member.
1409 views

RMNETTest in Visual COBOL

Jump to solution

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

Hello,

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" &
             '"http://tempuri.org/message/message"' & x"00".

       78  Post-Address value
             "https://desawflow.mango.com/eversuite/services/tc".

       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.
       a.
           display "Liant RMNet Test"
             line 1 position 10 erase.

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

           XML INITIALIZE
           XML EXPORT TEXT
               prservices2
               request-payload
               "/MNG/EXPL/XML/prservices2"
               "/MNG/EXPL/XML/prservices2pl.xsl".
           if not XML-OK then
              display "error export text"
              stop run
           end-if.           

           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
           end-if.
           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
           end-if.


           perform b.

           XML TERMINATE.
           Stop Run.

       b.
           set response-payload to address of Returned-text.

           display "httphost".
           call "HttpPost" using
               Post-Address
               ContentType
               request-payload
               response-payload
               Desired-SOAPAction
             giving
               response-status.

           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
           end-if.

      *    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
           end-if.

           xml put text
               response-payload
               "/MNG/EXPL/TMP/XML/respuesta2".
           if not xml-ok then
              display "error en xml"
              stop run
           end-if.
           
           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="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="tc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <soapenv:Body>
               <ns0:echo>
                  <message soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xsi:type='xsd:string'>
                        <xsl:value-of select="prservices2/men-mensaje"/>
                  </message>
               </ns0:echo>
            </soapenv:Body>
        </soapenv:Envelope>
    </xsl:template>
</xsl:stylesheet>

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

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: RMNETTest in Visual COBOL

Jump to solution
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:

http://supportline.microfocus.com/productdoc.aspx

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.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: RMNETTest in Visual COBOL

Jump to solution
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:

http://supportline.microfocus.com/productdoc.aspx

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.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.