For Programmers: Free Programming Magazines  


Home > Archive > Cobol > December 2007 > IESHTTPB COBOL VSE sample









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author IESHTTPB COBOL VSE sample
Kirsten S. Campbell

2007-12-07, 7:55 am

Hi,

Does anyone have a working sample of a VSE COBOL batch program
doing a call to a servlet or CGI using IESHTTPB.

thanks
KS
SkippyPB

2007-12-07, 6:56 pm

On Fri, 7 Dec 2007 05:02:12 -0800 (PST), "Kirsten S. Campbell"
<k_s@boltblue.com> wrote:

> IESHTTPB


Try
ftp://ftp.software.ibm.com/eserver/.../HTTPClient.pdf
////
(o o)
-oOO--(_)--OOo-

"My mother buried three husbands, and two of them
were just napping."
---Rita Rudner
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve
Kirsten S. Campbell

2007-12-10, 7:55 am

Unfortunately this is in C and I was looking for a COBOL VSE program.

I have rumaged through the internet and all the manuals I could find
and found little. I managed to find the HTTP copybook and IBM supplied
some pseudo code, but no complete sample.

So rather than having to invent the wheel again - I was hoping that
someone out there has a working sample.

rgds
Kirsten S.
Frank Swarbrick

2007-12-10, 6:55 pm

>>> On 12/10/2007 at 3:10 AM, in message
<45f9a1d4-b10b-4638-9ad2-ba9218c71ba9@p69g2000hsa.googlegroups.com>,
Kirsten S. Campbell<k_s@boltblue.com> wrote:
> Unfortunately this is in C and I was looking for a COBOL VSE program.
>
> I have rumaged through the internet and all the manuals I could find
> and found little. I managed to find the HTTP copybook and IBM supplied
> some pseudo code, but no complete sample.
>
> So rather than having to invent the wheel again - I was hoping that
> someone out there has a working sample.


Try out the following. It does very little, but it works. Essentially, it
populates the VSE HTTP client structure, calls the client, and then
(intentionally!) abends. If you compile with the SYM option you should be
able to see the resulting document in RET-BUFFER.

The interface, being written in C, is not very Cobol/VSE friendly.
Especially since Cobol/VSE does not support 'ADDRESS OF' of working-storage.
This required the nested program PTR-ADDR.

IDENTIFICATION DIVISION.
PROGRAM-ID. HTTPTST.
AUTHOR. FRANK SWARBRICK.
INSTALLATION. FIRSTBANK DATA CORPORATION.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 stuff.
05 ws-url PIC X(80) VALUE SPACES.
05 ws-url-len pic 9(8) comp.
05 ws-user-agent PIC X(09) VALUE
'VSE/2.7.1'.
05 ws-accepts PIC X(15) VALUE
'text/plain, */*'.
05 ws-hdrline pic x(80) VALUE ALL 'X'.

01 HTTP-REQ.
05 szUrl pointer.
05 dwUrlLen pic 9(8) comp.
05 iRequest pic s9(8) comp.
05 szUserAgent pointer.
05 dwUserAgentLen pic 9(8) comp.
05 szAccepts pointer.
05 dwAcceptsLen pic 9(8) comp.
05 lpUserData pointer.
05 iPostHandler pic s9(8) comp.
05 lpPostData pointer.
05 dwPostLength pic 9(8) comp.
05 szPostContentType pointer.
05 dwPostContentTypeLen pic 9(8) comp.
05 iHandler pic s9(8) comp.
05 lpData pointer.
05 dwLength pic 9(8) comp.
05 szContentType pointer.
05 dwMaxContentTypeLen pic 9(8) comp.
05 szRetCode pointer.
05 dwMaxRetCodeLen pic 9(8) comp.
05 iProxyType pic s9(8) comp.
05 szProxy pointer.
05 dwProxyLen pic 9(8) comp.
05 usProxyPort pic 9(4) comp.
05 szUser pointer.
05 dwUserLen pic 9(8) comp.
05 szPassword pointer.
05 dwPasswordLen pic 9(8) comp.
05 szAsciiCP pointer.
05 dwAsciiCPLen pic 9(8) comp.
05 szEbcdicCP pointer.
05 dwEbcdicCPLen pic 9(8) comp.
05 szHdrLine pointer.
05 dwHdrLineLen pic 9(8) comp.

01 CONSTANTS.
05 HTTPCLI PIC X(8) VALUE 'IESHTTPB'.

01 HTTP-REQ-TYPES.
05 HTTP-GET PIC S9(8) VALUE +1.
05 HTTP-POST PIC S9(8) VALUE +2.

01 HTTP-HANDLER-TYPES.
05 HTTP-HANDLER-NOTHING PIC S9(8) VALUE +0.
05 HTTP-HANDLER-BUFFER PIC S9(8) VALUE +1.
05 HTTP-HANDLER-FUNCTION PIC S9(8) VALUE +2.
05 HTTP-HANDLER-PROGRAM PIC S9(8) VALUE +3.

77 ABEND-IT PIC S9(3) COMP-3.

01 returned-fields.
05 content-type PIC X(40).
05 ret-code PIC X(40).
05 ret-buffer pic x(9600).

PROCEDURE DIVISION.

accept ws-url
move zeroes to tally
inspect function reverse(ws-url)
tallying tally for leading spaces
compute ws-url-len = length of ws-url - tally
* display ws-url-len upon console
display ws-url (1:ws-url-len) upon console

initialize HTTP-REQ
call 'PTR-ADDR' using szUrl
ws-url
move length of ws-url to dwUrlLen
move HTTP-GET to iRequest
call 'PTR-ADDR' using szUserAgent
ws-user-agent
move length of ws-user-agent to dwUserAgentLen
call 'PTR-ADDR' using szAccepts
ws-accepts
move length of ws-accepts to dwAcceptsLen
* call 'PTR-ADDR' using szHdrLine
* ws-hdrline
* move length of ws-hdrline to dwHdrLineLen
set lpUserData to NULL
move HTTP-HANDLER-NOTHING to iPostHandler
set lpPostData to NULL
move zero to dwPostLength
set szPostContentType to NULL
move zero to dwPostContentTypeLen
move HTTP-HANDLER-NOTHING to iHandler
move HTTP-HANDLER-BUFFER to iHandler
call 'PTR-ADDR' using lpData
ret-buffer
move length of ret-buffer to dwLength
call 'PTR-ADDR' using szContentType
content-type
move length of content-type to dwMaxContentTypeLen
call 'PTR-ADDR' using szRetCode
ret-code
move length of ret-code to dwMaxRetCodeLen
call HTTPCLI using HTTP-REQ

display return-code upon console
if return-code = zero
display content-type upon console
display ret-code upon console
end-if

ADD 1 TO ABEND-IT

goback.

IDENTIFICATION DIVISION.
PROGRAM-ID. PTR-ADDR.
DATA DIVISION.
WORKING-STORAGE SECTION.

LINKAGE SECTION.
01 LS-POINTER POINTER.
01 LS-VALUE PIC X.

PROCEDURE DIVISION USING LS-POINTER
LS-VALUE.
SET LS-POINTER TO ADDRESS OF LS-VALUE
EXIT PROGRAM.

END PROGRAM PTR-ADDR.

END PROGRAM HTTPTST.

JCL:
// EXEC HTTPTST
http://resource.fb/
/*

(obviously replace 'resource.fb' with the URL you want to connect to.)

Have fun!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com