For Programmers: Free Programming Magazines  


Home > Archive > Cobol > June 2007 > Re: Web Services and COBOL (Fairly long post, but I don't have time to write a proper









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 Re: Web Services and COBOL (Fairly long post, but I don't have time to write a proper
Rene_Surop

2007-05-21, 9:55 pm

Quite interesting.

Web Service is a great prerequisite for automated client-side code
generation in the mainstream Java and .NET SOAP frameworks. It's a
multi-language technology tool really, it could be C#, Cobol, Java.

Just wonderin', is there anyone who could provide NetExpress Cobol
code (Microfocus) similar above??

Pete Dashwood

2007-05-22, 7:55 am


"James J. Gavan" <jgavandeletethis@shaw.ca> wrote in message
news:g2v4i.206393$aG1.36136@pd7urf3no...
> Rene_Surop wrote:
> Rene,
>
> I could say 'Do your own bloody homework !" :-)


I'd forgive you for doing so :-) It seems to me to be stretching the
friendship to just sit back and let others do the work... Everything needed
to convert my code to MicroFocus can be found on the web (see below).
>
> Can't remember do you only have N/E 3.1 or do you also have V 5.0 ?
> If you have V 5.0 then I think the source should compile - whether yours
> works or not, that's another matter.


I'm very impressed that you would go to the trouble to do this, Jimmy.

So much so, I decided try and fix what you've posted, so it will work.

I don't have NE so I can't test the changes proposed below, but maybe you
could?

There are also a few responses to your comments and some general comments on
accessing COM servers from MicroFocus COBOL.

>
> If you are still back at N/E V 3.1 then you have problems. You will
> probably need to use the ISO 2000 directive like I've shown as the first
> line of the source below. You might also need Repository directives - but
> I keep getting syntax errors. If you read up on Directives for
> 2000/Repository, although you can simulate the *intended* COBOL 2000 (ha,
> ha, bloody ha !), it doesn't do any conformance checking in N/E 3.1.


I don't think using repository is the best way to go (although it is for
Fujitsu). I've used your Class-Control instead.
>
> I've dickered around with Pete's source and at this point in time there
> are only three compiler errors :-
>
> 1 - doesn't like where I've placed my substitute Class-Control entry
> 2 - doesn't like Line 210 - but that's associated with # 1


I hope that giving it the proper MF COM interface will resolve this.

> 3 - Line 642 doesn't recognize invoke COM - again back to #1 above ?


It never could. COM is a Fujitsu Class used to interface to COM components.
The equivalent in MF is $OLE$
>
> If you try other permutations I anticipate you will get a slightly
> different set of errors.
>
> I don't know if you can get it working without Repository syntax - I doubt
> it - just have to suck and see.


No, I believe it can work without Repository. It will be late bound anyway.

> Anyway as is, the source is just down to three errors. So now you can take
> over :-) - you can zip me back a copy if you get it working with N/E 3.1 -
> no point if you only do it with N/E 5.0. (If for some unknown reason the
> source below wraps around, e-mail me and I'll send the N/E source file as
> a zip).
>
> Note for Pete - what you transmitted - a bit of a pain in the butt, but
> not your intent :-). First I highlighted and pasted and each line was
> preceded by '>'. Then the problem with the wrap around comments.


That's because I use free-format COBOL and some of the lines were more than
76 bytes wide. Sorry.

Normally, I'd post it as COBOL source to a server and let people download
it, but it was so small I thought it would be easier to post it here and
hopefully stimulate some responses form people who tried using it.


> Probably OK if you were passing a source zipped file, but these damned
> e-mail programs aren't that clever. (My own style just using Columns 8
> thru 72 I enter '*>' in columns 8 and 9 - that allows me to highlight ( 1
> thru 72) and paste without wrap-arounds).
>
> EDITED SOURCE :
>
> $set iso2000 ooctrl(+p)


As we are accessing a COM server (The SOAP Component) you need the above MF
directive...it ensures parameters are passed correctly to the MF Run Time.
>
> *> This 'PARTIAL' version for Net Express V 3.1
>
> 000010 IDENTIFICATION DIVISION.
> 000020 PROGRAM-ID. 'SOAPTest'.
> 000030*AUTHOR. Peter E. C. Dashwood. *MODIFIED for MicroFocus by Jimmy
> Gavan.


> 000031*
> 000040* This program attempts to instantiate a SOAP Proxy class and
> 000050* access a Web Service using the new proxy...
> 000051*
> 000060*DATE_WRITTEN. May 2007.
> 000070 ENVIRONMENT DIVISION.
> 000080 configuration section.
> 000090 source-computer. IBM-PC.
> 000100 object-computer. IBM-PC.
>
> Class-Control. *> COM Class is "*com". (Can't work. COM is a
> Fujitsu Class.)


MSSOAP is class "$OLE$MSSOAP.SoapClient30"
>
> * Three possibilities for Repository Directive, kept on getting
> * errors 'Can't use here' :-


>
> * $set Repository Off
> * $set Repository Update
> * $set Repository Checking
>
>
> 000101 *>REPOSITORY.
> 000110 *> CLASS COM AS "*COM".
> 000120
> 000170
> 000200*------------------------ DATA DIVISION ---------------------
> 000210 DATA DIVISION.
> 000340*
> 000350 WORKING-STORAGE SECTION.
> 000360 01 in-interface-block pic x(8197).
> 000361 01 in-IB.
> 000362 12 in-ws-return pic x(5).
> 000363 88 in-ws-OK value '00000'. *> will contain SQLSTATE if
> 000364 *> there is a DB error
> 000365 12 in-ws-message pic x(256). *> will contain SQLMSG if
> 000366 *> there is a DB error
> 000367 12 in-ws-buffer pic x(2048). *> holds free format address
> data
> 000368 *> this will be formatted on
> return
> 000369 12 in-ws-breakdown.
> 000370 15 in-ws-streetNo pic x(20).
> 000371 15 in-ws-POBoxNo pic x(15).
> 000372 15 in-ws-RDNo pic x(8).
> 000373 15 in-ws-street pic x(150).
> 000374 15 in-ws-locality pic x(150).
> 000375 15 in-ws-city pic x(50).
> 000376 15 in-ws-lobby pic x(150).
> 000377 15 in-ws-postCode pic x(4).
> 000378 15 in-ws-addressType pic x(1).
> 000379 15 in-ws-streetSDX pic x(4).
> 000380 15 in-ws-localitySDX pic x(4).
> 000381 15 in-ws-lobbySDX pic x(4).
> 000382 15 in-ws-prologue pic x(100).
> 000383 12 in-ws-interface pic x.
> 000384 88 in-free-format-input value '1'.
> 000385 88 fixed-field-input value '2'.
> 000386 88 XML-input value '3'.
> 000387 12 in-ws-streetMatchFlag pic x(1).
> 000388 88 street-fuzzy value '0'.
> 000389 88 street-exact value '1'.
> 000390 12 in-ws-localityMatchFlag pic x(1).
> 000391 88 locality-fuzzy value '0'.
> 000392 88 locality-exact value '1'.
> 000393 12 in-ws-repeatLocalityFlag pic x(1).
> 000394 88 no-Locality value '1'.
> 000395 88 repeatLocality value '0'.
> *> used if Locality = City
> 000396 12 in-ws-ignoreInvalidPostcode pic x(1).
> 000397 88 ignoreInvalidPostCode value '1'.
> 000398 88 reportInvalidPostCode value '0'.
> *>stops if Post Code is invalid
> 000399 12 in-ws-foreignFlag pic x(1).
> 000400 88 foreign-address value '1'.
> *>stops if foreign address detected
> 000401 88 NOT-foreign-address value '0'.
> 000402
> 000403 01 out-interface-block pic x(8197).
> 000405 01 out-IB.
> 000406
> 000407 12 out-ws-return pic x(5).
> 000408 88 out-ws-OK value '00000'.
> *> will contain SQLSTATE if
> 000409 *> there is a DB error
> 000410 12 out-ws-message pic x(256). *> will contain SQLMSG if
> 000411 *> there is a DB error
> 000412 12 out-ws-buffer pic x(2048).
> *> holds free format address data
> 000413 *> this will be formatted on return
> 000414 12 out-ws-breakdown.
> 000415 15 out-ws-streetNo pic x(20).
> 000416 15 out-ws-POBoxNo pic x(15).
> 000417 15 out-ws-RDNo pic x(8).
> 000418 15 out-ws-street pic x(150).
> 000419 15 out-ws-locality pic x(150).
> 000420 15 out-ws-city pic x(50).
> 000421 15 out-ws-lobby pic x(150).
> 000422 15 out-ws-postCode pic x(4).
> 000423 15 out-ws-addressType pic x(1).
> 000424 15 out-ws-streetSDX pic x(4).
> 000425 15 out-ws-localitySDX pic x(4).
> 000426 15 out-ws-lobbySDX pic x(4).
> 000427 15 out-ws-prologue pic x(100).
> 000428 12 out-ws-interface pic x.
> 000429 88 free-format-input value '1'.
> 000430 88 fixed-field-input value '2'.
> 000431 88 XML-input value '3'.
> 000432 12 out-ws-streetMatchFlag pic x(1).
> 000433 88 street-fuzzy value '0'.
> 000434 88 street-exact value '1'.
> 000435 12 out-ws-localityMatchFlag pic x(1).
> 000436 88 locality-fuzzy value '0'.
> 000437 88 locality-exact value '1'.
> 000438 12 out-ws-repeatLocalityFlag pic x(1).
> 000439 88 no-Locality value '1'.
> 000440 88 repeatLocality value '0'.
> *> used if Locality = City
> 000441 12 out-ws-ignoreInvalidPostcode pic x(1).
> 000442 88 ignoreInvalidPostCode value '1'.
> 000443 88 reportInvalidPostCode value '0'.
> *> stops if Post Code is invalid
> 000444 12 out-ws-foreignFlag pic x(1).
> 000445 88 foreign-address value '1'.
> *>stops if foreign address detected
> 000446 88 NOT-foreign-address value '0'.
> 000447
> 000448
> 000449 01 WSDL-reference value
> 000450* WSDL to connect to the remote host (in San Francisco)
> z'http://primacomputing.co.nz/AVSWebService/AVSWebService.asmx?WSD
> -'L'.


The above literal needs a z in front and removal of the picture (I think?)
to indicate an ASCIIZ string, for MF.

I'm a bit worried about continuation of this string, Jimmy. It is critical
that the string is presented intact. If it doesn't work when you step
through it, try concatenating sections of the string, or STRING it into
WSDL-reference.

> 000451
>
> 000452* WSDL to connect to my IIS server on my new VAIO notebook
> * machine over wireless LAN.
> 000453* 'http://bigblack/AVSWebService/AVSWebService.asmx?WSDL'.
> 000454*
> 000455* I have tested both of the above and they both work perfectly.
> * Web services can
> 000456* be hosted anywhere you like and accessed from anywhere on Earth.
> * It's magic...!!
> 000457* (Like DCOM+ on steroids...)
> 000458


You don't need the following, because it is included in the Class-Control
entry...
> 000459 01 COMServer-ProgIDs.
> 000460 12 SOAP-ProgID pic x(19) value
> 000461 "MSSOAP.SoapClient30".



> 000462
> 000463 01 COMServer-Objects.
> 000464 12 objSOAPClient OBJECT REFERENCE. *> COM.
> 000465
> 000466 01 subscripts usage comp-5.
> 000467 12 J pic s9(5).
> 000468 12 K pic s9(5).
> 000469
> 000470 01 end-flag pic x.
> 000471 88 not-finished value zero.
> 000472 88 finished value '1'.
> 000473
> 000487
> 000490 PROCEDURE DIVISION.
> 000500 MAIN SECTION.
> 000510 a000.
> 000520 perform startup-housekeeping
> 000530 perform main-logic until finished
> 000540 perform close-down
> 000550 .
> 000560 a999.
> 000570 stop run.
> 000580*-----------------------------------------------------------
> 000590 STARTUP-HOUSEKEEPING section.
> 000600 sh000.
> 000640 set not-finished to TRUE


This can't work because you have no established reference to COM
> 000641* Instantiate SOAP COM Server...
> 000642 invoke COM "CREATE-OBJECT" using SOAP-ProgID
> 000643 returning objSOAPClient
> 000644 end-invoke


Try this instead...
invoke MSSOAP "new"
returning objSOAPClient
end-invoke


> 000645* Initialize the SOAP Server and point it at the WSDL for the Web
> * Service
> 000646 invoke objSOAPClient "mssoapinit"
> 000647 using WSDL-reference
> 000648 end-invoke
> 000649* At this point the objSOAPClient reference has become a proxy for
> * the AVS Web Service...
> 000650* This means you can reference any of the methods/properties/events
> * exposed by the Web Service,
> 000651* as if they belonged to the objSOAPClient object...
> 000652 .
> 000660 sh999.
> 000670 exit.
> 000680*-----------------------------------------------------------
> 000690 MAIN-LOGIC section.
> 000700 ml000.
> 000701*
> 000707*
> 000708* Now try the methods...
> 000709*
> 000710* The AVS Web Service only exposes one method, but the underlying
> * COM object has several.
> 000711
> 000712* Set up an address string... (Not essential... if you
> 000714* pass a blank interface block to AVS it will return a message in
> * the ws-message
> 000715* area telling you it was invalid...)
> 000716 move spaces to in-IB
> 000718 set in-free-format-input to TRUE
> 000719 move '97 21ST AVE TAURANGA' to in-ws-buffer *> A NZ address...
> 000720 move in-IB to in-interface-block
> 000721 *> Note that string parameters to COM objects must be 8197
> bytes
> 000722 *> and must be elemental.
> 000723
> 000724 invoke objSOAPClient "ValidateNZaddress"
> 000725 using in-interface-block *> input interface block
> 000726 returning out-interface-block *> output interface block
> 000727 *> Note that you could use just one block
> 000728 *> but you must reference it in and out because the
> 000729 *> Web Service expects in and out parameters n
> 000730
> 000731 end-invoke
> 000732*========================== SOAP XML Stringing error fix
> 000733* There is currently a problem with SOAP stripping out certain
> * characters
> 000734* in the returned string. This causes fields to be aligned
> * incorrectly. The
> 000735* following is a quick fix and won't be required once the service
> * is released.
> 000736*
> 000737 move 1 to K *> output buffer pointer
> 000746 perform
> 000756 varying J *> input buffer pointer (for this process)
> 000757 from 1
> 000758 by 1
> 000759 until K > function LENGTH (out-IB)
> 000760 move out-interface-block (J:1) to out-IB (K:1)
> 000761 add 1 to K
> 000762 if out-interface-block (J:1) = x'0A'
> 000763 move space to out-IB (K:1)
> 000764 add 1 to K
> 000765 end-if
> 000766 end-perform
> 000769
> 000770*
> 000771* ALL of the above code would be replaced by:
> 000772*
> 000773* move out-interface-block to out-IB
> 000774*
> 000775* ...once the COM server and SOAP wrapper are fixed. (I'm working
> * on it... :-))
> 000776*
> 000777*============ End of SOAP XML Stringing error fix ===========
> 000778*
> 000779
> 000780* Debugging Note
> 000781*
> 000782* Now is a good time to look at out-ws-breakdown and
> * out-ws-buffer...
> 000783*
> 000784* If you are stepping through this in the debugger, note that each
> * field has been
> 000785* filled in, (street number, street, locality, region, and postcode)
> * and the
> 000786* ws-buffer area now contains a properly formatted address which
> * complies with
> 000787* NZPO requirements, and has been converted to mixed case.
> 000788*
> 000789 set finished to TRUE
> 000790
> 000791 .
> 001210 ml999.
> 001220 exit.
> 001230*----------------------------------------------------------
> 001240 CLOSE-DOWN section.
> 001250 cd000.


Fujitsu is OK with NULL, but MF requires a specific invoke of the
finalizer...
> 001260 *> set objSOAPClient to NULL *> Help the garbage collector ...


invoke objSOAPClient "finalize" returning objSOAPClient

> 001340 .
> 001350 cd999.
> 001360 exit.
> 001370*---------------- END OF PROGRAM 'SOAPTEST' ----------------


I am hopeful that the above very minor changes will enable you to compile
and run this code in the Animator/Debugger.

It will be if you get it to work. Remember, the service is running on a
farm in San Francisco, let us know what your response is like.

Here are some other valid NZ addresses you could feed into it:

APT 510 GRACE JOEL VILLAGE 184 ST HELIERS BAY RD AUCKLAND
CARMELITE MONASTERY 52 HALSWELL RD CHCH
3/13A VOSPER ST MATAMATA
P O BOX 10042 TE MAI

(Valid postcodes and localites/regions should be returned for all of these.
It is just to show the flexibility of the free format input.)

If you are still getting compile errors, please post here and I'll take
another look at it.

Note to ALL:

Sometimes the action of finding out stuff is a very rewarding experience. I
don't know NE and don't have it, but I was very interested to see why
Jimmy's gallant attempt didn't work. It took me minutes to find what I
needed on the web, and identify what the major differences are in accessing
COM servers from Fujitsu and MF.

Having access to COM is a MAJOR feature of using OO. It seems that NE
implements it just as well (although a little differently) as Fujitsu does.
I hope some of you NE people are moved to try accessing some of the COM
components that already exist on your systems...Sometimes these components
are referred to as "Automation servers" They include things like ACCESS,
Excel, Powerpoint, and MS Word, all easily accessible from your COBOL, as
Automation or COM/OLE servers.

Once everyone is happy with ACCESSING a web service from COBOL, the next
step is to BUILD one in COBOL. One way is to take a COM component, wrap it
in the required SOAP/XML, generate the WSDL, and post it on a server. Or, as
in the case of AVS above, write a C# web service that wraps a COBOL COM
component, and let VS 2005 generate all the WSDL, XML, and SOAP.

Today, if I was writing AVS again, I'd do it in C#, but at the time I
started it, I was only just considering C# so I wrote the engine as a COBOL
COM server instead. Notice that this component based approach has meant that
even though I move away from COBOL, my COBOL legacy is still viable. BECAUSE
it is a COM server it can be easily wrapped and handled by C# as "unmanaged"
code in a web service. And it can be accessed in any language from anywhere
on any platform that supports web services. Alternatively, it can be dropped
as a COM component onto a web page or a desktop application and accessed
locally as a COM object, or remotely over DCOM+ using RPC. (Web services are
obsoleting this particular use of COM servers; they are more secure than
DCOM+ and generally more stable.)

Encapsulating functionality into components makes as much sense today as it
did 10 years ago. There are numerous spin offs from doing so.

Pete.


Pete Dashwood

2007-05-23, 3:55 am


"Rene_Surop" <infodynamics_ph@yahoo.com> wrote in message
news:1179887604.069942.171890@q66g2000hsg.googlegroups.com...
>
> Hi Pete,
>
> Been using the DCOM/COM for several years now... hmm, way back 2002
> and I've tried it to be very effective using Microfocus N/E v3.1. You
> could see how this N/E Cobol COM works associated with ASP here in my
> sample site;
>

http://infowaters.infodynamicsconsult.com
>
> At first access, the server will activate the COM (.dll file created
> in N/E)... once activated, it is now ready for user request. Try
> entering "starting customer name" in the box and select the desired
> customer name.
>
> 1st method: the .dll file is used for searching 10 records (per
> display)
> 2nd method: if customer name is selected, the .dll file will again
> retrieve the customer info
> 3rd method: after displaying customer info, it will display billing
> history records
>
> I used it 3years ago... well, that's is why Microfocus says "Cobol
> Rocks" then.
>
> Now you're saying Web Services rocks :-)
>

I've been using COM/DCOM+ MTS etc for over 10 years now. And I've built web
sites using ASP to activate COM components written in COBOL, and from COBOL
CGI/ISAPI code. It is an excellent component based technology. Web Services
take it a step further...

Pete.



Pete Dashwood

2007-05-23, 6:55 pm


"Rene_Surop" <infodynamics_ph@yahoo.com> wrote in message
news:1179896963.555487.99600@k79g2000hse.googlegroups.com...
>
> Didn't know there were COM ten (10) years back?


It was Online Linking and Embedding (OLE). This then evolved into the Common
Object Model.

Fujitsu has supported it since version 3 which I acquired in 1997. It was
one of the first OO COBOL compilers. Fujitsu offered it free to people who
were using MicroFocus COBOL. As this was the time of the great VISOC scam
where MF simply abandoned their user base, I took up the offer and have been
using Fujitsu ever since.

The made subsequent releases which steadily improved the product, but
unfortunately, they dropped the ball with their support which became
abysmal. With Version 6 they added a crazy Copy Protection system which
simply alienated the User base and by version 7, the Fujitsu NetCOBOL base
was feeling pretty much the way the MF Visoc base had felt some years
before... abandoned.

The sample code I posted was written in Version 6, as I refused to continue
paying maintenance for a service that was hopeless, and thus was unable to
upgrade to V7. ( I think they have dropped support for V6 now, but in the
interim I learned to support the product myself anyway, so I have no
problems with it. Also, the documentation for V7 was a huge improvement over
previous versions and this helped immensely; most of it applies equally well
to V6)

By then Fujitsu had released NetCOBOL for .NET which, like all their
previous releases, was of a very high standard, but expensive. Committed to
DotNET, but faced with stumping up several thousand dollars for this
product, I decided to give it one last go with COBOL, and sent off an
enquiry, with a view to buying it. It was never even acknowledged, and I had
no intention of begging them to sell me their product, so it was obvious to
me they didn't want/need my business. I therefore dropped COBOL and moved to
C#.

Very happy I did. I saved several thousand dollars, don't have to deal with
idiotic support, can get friendly and knowledgeable help for free whenever I
want it, and have learned a heap of stuff I otherwise wouldn't have. The
icing on the cake is that I can still use all my COBOL components from C#
and ASP.All-in-all, a good result :-).


NetExpress V3.1 came
> along year 2000 (that was Merant then), although COM came prior to
> that using the Object Cobol.
>
> Well... coming from a 3rd world country :-)
>

Your web site is certainly not "third world". It is very impressive.

It looks almost like Access Forms. Is that what you used?

Pete


Pete Dashwood

2007-05-24, 3:55 am


"Richard" <riplin@Azonic.co.nz> wrote in message
news:1179977091.567546.22670@n15g2000prd.googlegroups.com...
> On May 23, 10:02 pm, "Pete Dashwood"
> <dashw...@removethis.enternet.co.nz> wrote:
>
>
> Version 3 did not have OO or OLE. As this version is still (? adtools
> has gone) available it may mislead students into think that it does.
>
> Version 4 introduced OO and OLE in 1998. I have both sets of paper
> manuals.
>
>

Thanks Richard. I thought it did but was wrong.

Pete.


Pete Dashwood

2007-05-24, 7:55 am

Round of applause!!!

Really good stuff, Jimmy.

Some comments below...

"James J. Gavan" <jgavandeletethis@shaw.ca> wrote in message
news:EY85i.214410$6m4.184311@pd7urf1no...
> By George he's got it ! I think :-). Cut a long story short, I initially
> downloaded SOAP but doing that Registry check found I already had it.
> Whether or not that duplication was causing a problem ....???? Anyway
> deleted second.
>
> I keep on saying I code, (or used to code) in Classes so I have
> difficulty getting Procedurals to do exactly what I want without a lot of
> buggering around.


Not sure how you are using "Procedural" here.Maybe MF have a specific
meaning for it.

Example : I used '$set sourceformt "free"' and for
> some inexplicable reason the compiler queried your line numbers. I had
> other irritating problems as well. So sod it. Use what you are comfortable
> with. I went with the Class format - same as you did but now your
> paragraphs become methods. Here goes :-
>


I like what you did very much. I have reservations about trigger programs
but it works very well here.

> Give it a shot Rene and confirm that it works for you !
>
> The code for both starts in Column 8 -
>
> *>----------------- soaptrigger.cbl ----------------------------
>
> *> Trigger PROCEDURAL program used here. Assume Soaptest was
> *> selected from a Mster Menu - then the Menu would invoke in a
> *> similar manner.
>
> Program-id. SoapTrigger.
>
> Class-Control. SoapTest is class "soaptest".
>
> WORKING-STORAGE SECTION.
> 01 os-SoapTest object reference value null.
>
> PROCEDURE DIVISION.
>
> invoke SoapTest "new" returning os-SoapTest
> invoke os-SoapTest "begin"
> invoke os-Soaptest "finalize" returning os-SoapTest
>
> *> Strictly speaking the 'finalize' above is not required -
> *> it is replaced by the STOP RUN
>
> STOP RUN.
>
> *>--------------------------------------------------------------
>
>
> *>-----------------soaptest.cbl ------------------------------
> $set sourceformat"free"
> $set ooctrl(+p)
> *>------------------------------------------------------------
>
> *> Original Procedural program written by Peter E.C. Dashwood
> *> in May 2007 using Fujitsu dotNetCOBOL invoking Soap
>
> *> This class adapated by James J. Gavan for Net Express V 3.1.
> *> If using later versions of Net Express then REPOSITORY syntax
> *> can replace the 'Class-Control' entries below
>
> *>---------------------------------------------------------------
> Class-id. Soaptest.
> *> Soaptest inherits from Base.
>
> *> Where no inheritance is specified it defaults to Base
>
> Class-Control. *> olebase is class "olebase"
> oleexceptionmanager is class "oleexpt"
> Soaptest is class "soaptest"
> Mssoap is class "$OLE$MSSOAP.SoapClient30"
> .
>
> *> If having problems with OLE - you could use the N/E
> *> OleExceptionManager with a callback method - see N/E
> *> OO and OLE documentation
>
> *>--------------------------------------------------------------
> *> FACTORY.
> *> END-FACTORY.
> *>---------------------------------------------------------------
> OBJECT.
> *>---------------------------------------------------------------
> WORKING-STORAGE SECTION.
> 01 in-interface-block pic x(8197).
> 01 in-IB.
> 12 in-ws-return pic x(5).
> 88 in-ws-OK value '00000'. *> will contain SQLSTATE if
> *> there is a DB error
> 12 in-ws-message pic x(256). *> will contain SQLMSG if
> *> there is a DB error
> 12 in-ws-buffer pic x(2048). *> holds free format address
> *> this will be formatted on
>
> 12 in-ws-breakdown.
> 15 in-ws-streetNo pic x(20).
> 15 in-ws-POBoxNo pic x(15).
> 15 in-ws-RDNo pic x(8).
> 15 in-ws-street pic x(150).
> 15 in-ws-locality pic x(150).
> 15 in-ws-city pic x(50).
> 15 in-ws-lobby pic x(150).
> 15 in-ws-postCode pic x(4).
> 15 in-ws-addressType pic x(1).
> 15 in-ws-streetSDX pic x(4).
> 15 in-ws-localitySDX pic x(4).
> 15 in-ws-lobbySDX pic x(4).
> 15 in-ws-prologue pic x(100).
> 12 in-ws-interface pic x.
> 88 in-free-format-input value '1'.
> 88 fixed-field-input value '2'.
> 88 XML-input value '3'.
> 12 in-ws-streetMatchFlag pic x(1).
> 88 street-fuzzy value '0'.
> 88 street-exact value '1'.
> 12 in-ws-localityMatchFlag pic x(1).
> 88 locality-fuzzy value '0'.
> 88 locality-exact value '1'.
> 12 in-ws-repeatLocalityFlag pic x(1).
> 88 no-Locality value '1'.
> 88 repeatLocality value '0'.
> *> used if Locality = City
> 12 in-ws-ignoreInvalidPostcode pic x(1).
> 88 ignoreInvalidPostCode value '1'.
> 88 reportInvalidPostCode value '0'.
> *>stops if Post Code is invalid
> 12 in-ws-foreignFlag pic x(1).
> 88 foreign-address value '1'.
> *>stops if foreign address detected
> 88 NOT-foreign-address value '0'.
>
> 01 out-interface-block pic x(8197).
> 01 out-IB.
>
> 12 out-ws-return pic x(5).
> 88 out-ws-OK value '00000'.
> *> will contain SQLSTATE if
> *> there is a DB error
> 12 out-ws-message pic x(256). *> will contain SQLMSG if
> *> there is a DB error
> 12 out-ws-buffer pic x(2048).
> *> holds free format address data
> *> this will be formatted on return
> 12 out-ws-breakdown.
> 15 out-ws-streetNo pic x(20).
> 15 out-ws-POBoxNo pic x(15).
> 15 out-ws-RDNo pic x(8).
> 15 out-ws-street pic x(150).
> 15 out-ws-locality pic x(150).
> 15 out-ws-city pic x(50).
> 15 out-ws-lobby pic x(150).
> 15 out-ws-postCode pic x(4).
> 15 out-ws-addressType pic x(1).
> 15 out-ws-streetSDX pic x(4).
> 15 out-ws-localitySDX pic x(4).
> 15 out-ws-lobbySDX pic x(4).
> 15 out-ws-prologue pic x(100).
> 12 out-ws-interface pic x.
> 88 free-format-input value '1'.
> 88 fixed-field-input value '2'.
> 88 XML-input value '3'.
> 12 out-ws-streetMatchFlag pic x(1).
> 88 street-fuzzy value '0'.
> 88 street-exact value '1'.
> 12 out-ws-localityMatchFlag pic x(1).
> 88 locality-fuzzy value '0'.
> 88 locality-exact value '1'.
> 12 out-ws-repeatLocalityFlag pic x(1).
> 88 no-Locality value '1'.
> 88 repeatLocality value '0'.
> *> used if Locality = City
> 12 out-ws-ignoreInvalidPostcode pic x(1).
> 88 ignoreInvalidPostCode value '1'.
> 88 reportInvalidPostCode value '0'.
> *> stops if Post Code is invalid
> 12 out-ws-foreignFlag pic x(1).
> 88 foreign-address value '1'.
> *>stops if foreign address detected
> 88 NOT-foreign-address value '0'.
>
> *> OBJECTS.
>
> 01 objSoapClient object reference value null.
>
> *>--------------------------------------------------------------
> Method-id. "begin".
> *>--------------------------------------------------------------
> *>
> *> Interesting - I normally type :-
> *>
> *> invoke self (this instance) "startup-housekeeping"
> *>
> *> Guess the compiler knows I'm referring to 'self' !!!
>
> invoke "startup-housekeeping"
> invoke "main-logic"
> invoke "finalize-objects"
>
> End Method "begin".
> *>---------------------------------------------------------------
> Method-id. "startup-housekeeping".
> *>--------------------------------------------------------------
> WORKING-STORAGE SECTION. *> Only allowed in Net Express
>
> *>WSDL to connect to the remote host (in San Francisco)
>
> *> NOTE : The compiler will tell you if your value (66 below)
> *> doesn't equate to the size of the literal
>
> 01 WSDL-reference pic x(66) value
> z'http://primacomputing.co.nz/AVSWebService/AVSWebService.asmx?WSDL'.
>
> *> WSDL to connect to my IIS server on my new VAIO notebook
> *> machine over wireless LAN.
> *>
> *> 'http://bigblack/AVSWebService/AVSWebService.asmx?WSDL'.
> *>
> *>I have tested both of the above and they both work perfectly.
>
> invoke MSSOAP "new" returning objSoapClient
> invoke objSOAPClient "mssoapinit"
> using WSDL-reference
> End Method "startup-housekeeping".
> *>--------------------------------------------------------------
> Method-id. "main-logic".
> *>--------------------------------------------------------------
>
> move spaces to in-IB
> set in-free-format-input to TRUE
> *> move '97 21ST AVE TAURANGA' to in-ws-buffer *> A NZ address...
> move '48 35TH BLVD TOURONGA' to in-ws-buffer
>
> *> The commented address above is valid, whereas the second
> *> address being used is invalid
>
> move in-IB to in-interface-block
>
> *> Note that string parameters to COM objects must be 8197
> *> and must be elemental.
>
> invoke objSOAPClient "ValidateNZaddress"
> using in-interface-block *> input interface block
> returning out-interface-block *> output interface block
>
> *> Note that you could use just one block
> *> but you must reference it in and out because the
> *> Web Service expects in and out parameters
>
> invoke self "error-fix"
>
> *> Debugging Note
> *>
> *> Now is a good time to look at out-ws-breakdown and
> *> out-ws-buffer...
> *>
> *> If you are stepping through this in the debugger, note that each
> *> field has been filled in,
> *> (street number, street, locality, region, and postcode)
> *> and the ws-buffer area now contains a properly formatted address
> *> which complies with NZPO requirements, and has been converted
> *> to mixed case.
> *>
> *> out-ws-breakdown
> *> out-ws-buffer
>
> Exit Method. *> Exit-Method is only really required when you
> *> have a conditional EXIT. Here I'm using
> *> 'Exit Method' as an Animator breakpoint so that
> *> I can view the above two variables
>
> End Method "main-logic".
> *>--------------------------------------------------------------
> Method-id. "error-fix".
> *>--------------------------------------------------------------
> *>============== SOAP XML Stringing error fix
> *> There is currently a problem with SOAP stripping out certain
> *> characters in the returned string. This causes fields to be
> *> aligned incorrectly. The following is a quick fix and won't
> *> be required once the service is released.
> *>
>
> 01 J pic x(4) comp-5.
> 01 K pic x(4) comp-5.
>
> move 1 to K *> output buffer pointer
> perform
> varying J *> input buffer pointer (for this process)
> from 1
> by 1
> until K > function LENGTH (out-IB)
> move out-interface-block (J:1) to out-IB (K:1)
> add 1 to K
> if out-interface-block (J:1) = x'0A'
> move space to out-IB (K:1)
> add 1 to K
> end-if
> end-perform
>
> *>
> *>ALL of the above code would be replaced by:
> *>
> *> move out-interface-block to out-IB
> *>
> *>...once the COM server and SOAP wrapper are fixed. (I'm working
> *>on it... :-))
> *>
> End Method "error-fix".
> *>--------------------------------------------------------------
> method-id. "finalize-objects".
> *>---------------------------------------------------------------
>
> if ObjSoapClient <> null
> invoke ObjSoapClient "finalize" returning ObjSoapClient
> End-if
>
> End Method "finalize-objects".
> *>--------------------------------------------------------------
> END OBJECT.
>
> END CLASS SoapTest.
>
> *>---------------------------------------------------------------



This is really , Jimmy :-)

I was really pleased to see that my assessment was right and the mssoapinit
method didn't need the extra parameters. This works when the WSDL is
referenced from the web service itself, as we did.

It is a signal lesson in checking carefully what you get from the web; the
information offered was hopelessly out of date.

What I'd like to do is place the code in a 'downloads' directory on the
server, along with my Fujitsu version and any other versions that people
offer (maybe Java, C#, AcuCOBOL... whatever). As soon as I have time, I'll
write an article about the whole process and place that there too, so anyone
can see the story on accessing the service (or, indeed, any web service)
from COBOL, or anything else. If you have no objection to this, could you
mail me a zip of the MF project containing your code?

Finally, what was the response like? The first one would be a bit longer
because the DB buffers have to be loaded. Also, I currently use a new
instance of the service each time it is invoked and that takes time. I'm
looking into that; it gets a bit tricky with DB connections and connection
scope...

Thanks for spending the time to get this working, I'm sure a number of
people will use your code.

Pete


Pete Dashwood

2007-05-25, 3:55 am


"James J. Gavan" <jgavandeletethis@shaw.ca> wrote in message
news:qZi5i.214632$DE1.57499@pd7urf2no...
> Pete Dashwood wrote:
>
>
> Well you might not like it, but I would call your source 'Procedural' in
> that it is a PROGRAM source as opposed to a CLASS source, although you are
> still creating/accessing objects via invokes. I think the advantage of ALL
> classes is the ability to do a 'round robin' between the various classes
> because you can have an instance handle (object reference) to each. (My
> comment was not based on Micro Focus - they are silent on the topic).


OK, that's fair enough.

>
> Well of course the early M/F OO examples all did/and still have a Trigger
> program. The main functions are :-
>
> - Menu driven application - from the Trigger start the App(Business Logic)
> and the Master Menu. Return handles from both to the Trigger which passes
> them to the corresponding App and Menu instances


Yes, I've read Wil Price's book. :-)

Similar things can happen with Fujitsu. For example, you may have a .EXE
that invokes methods from a .DLL. (And, in my case at least, the .DLL is
usually a COM Server.)

Of course, by encapsulating functionality into a COM Server, you don't need
a Trigger; it can be dropped and used almost anywhere that supports OO, not
just COBOL. This gets over the old grizzle we've always had about Class
interoperability (or the lack of it) in COBOL. I have Java, C#, COBOL, and
ASP all using OO Class methods and properties that are written in COBOL.
COM empowers this; Web Services take it even further by making it global.
(In the World sense, not the programming sense... :-))

I don't think it really matters what you call it.

>
> - call "apigui" which kick starts GUIing
>
> This is the trigger for the Corrosion Testing application, which
> illustrates above :-
>
> *>--------------------ctbegin.cbl--------------------------
>
> PROGRAM-ID. ctbegin.
>
> CLASS-CONTROL. ctApplication is class "ctapp"
> ctMenu is class "ctmenu"
> EventManager is class "p2emgr"
> Module is class "module"
> .
>
> *>--------------------------------------------------------------
> OBJECT-STORAGE SECTION.
> copy "\copylib\sqlResult.cpy" replacing ==(tag)== by ==01 ws==.
> 01 CtResourceID pic x(10) value z"ctres.dll".
>
> 01 os-App object reference.
> 01 os-Desktop object reference.
> 01 os-EventManager object reference.
> 01 os-Menu object reference.
> 01 os-Resource object reference.
>
> PROCEDURE DIVISION.
>
> call "apigui"
> invoke EventManager "new" returning os-EventManager
> invoke os-EventManager "initialize"
> invoke os-EventManager "getDesktop" returning os-Desktop
> invoke Module "newZ" using CtResourceID
> returning os-Resource
>
> invoke ctApplication "new" returning os-App
> invoke ctMenu "new" using os-Desktop
> returning os-Menu
>
> invoke os-App "passHandles" using os-Desktop
> os-Menu
> os-Resource
> invoke os-Menu "passHandles" using os-Desktop
> os-EventManager
> os-App
> os-Resource
> invoke os-Menu "createMenu"
> invoke os-Menu "create"
> invoke os-App "checkFiles" returning ws-SqlResult
>
>
> if ResultOK
> invoke os-Menu "show"
> invoke os-EventManager "run"
> End-if
>
>
> STOP RUN.
>
> *>--------------------------------------------------------------
>
>
> Now if you look at current M/F Dialog System examples they all start with
> a 'Procedural' which also tends to be the Business Logic. As it is
> Procedural they use entry-points to get at different Sections to handle
> results of different GUI events.
>
>
> No objections. I'll send you a zip.


Thanks.

> Mere seconds. To keep it simple I'll have the SoapTrigger invoke my
> DateTime Class, (which I'll also send), to get the Date/Time (pic x 21)
> for start of Trigger and end of Trigger.
>
> PS: Would you refer to your SoapTest.cbl as a standalone or would you
> categorize it as a component ?


Definitely a standalone. It is really just a "harness" for testing the proxy
Class. However the web service, although being around 4000 lines of OO COBOL
code, I would consider to be a component. (I don't plan on maintaining this
code, once it has completed all of its testing.) I can't publish the code as
it is commercially sensitive, but I can tell you it has three main methods
in the Class, which are supported by other smaller methods:

(Note, I have no qualms about describing these methods publicly, because
they cannot be accessed directly. Using a web service you decide what will
be exposed and what won't...)

1. ParseOnly.

This deals with stripping a free format address into words, and attempting
to locate what is a street, a locality or lobby, a region, and a postcode.
In my naivety I figured a COBOL UNSTRING would be the caper... I crashed and
burned :-) Here's the code that sets the input buffer up so it CAN be
unstrung into words...

*
* Prepare the data buffer...
* Get all words, separated by a single space
*
move zero to ws-return
move spaces to stored-inrec
move 1 to K
perform
varying J
from 1
by 1
until J > function STORED-CHAR-LENGTH (ws-buffer)
if NOT (ws-buffer (J:1) ALPHABETIC OR ws-buffer (J:1)
NUMERIC)
AND NOT (ws-buffer (J:1) = '&'
OR ws-buffer (J:1) = '-'
OR ws-buffer (J:1) = '/'
OR (ws-buffer (J:1) = "'"
AND ws-buffer (J + 2:1) NOT = space))
move space to ws-buffer (J:1)
if ws-buffer (J:1) = space AND
Function UPPER-CASE (ws-buffer (J + 1:2)) = "S
"
move ws-buffer (J + 1:2) to ws-buffer (J:2)
end-if
*> removes punctuation and line breaks
*> but allows &,-, ' (not apostrophe) and /
*> must allow "O'Neill" but not "Neil's"
end-if
if ws-buffer (J:1) NOT = space
move ws-buffer (J:1) to stored-inrec (K:1)
add 1 to K
set expecting-space to TRUE
else
if expecting-space
move ws-buffer (J:1) to stored-inrec (K:1)
add 1 to K
set NOT-expecting-space to TRUE
end-if
end-if
end-perform
*
* stored-inrec should now be a string of words separated by one
space...
*

(nothing is ever as easy as you think... :-) Today, I would write this in C#
using Regular Expressions, but the COBOL above serves well.)

2. FIB - Fill in the blanks

This makes sure that any missing address elements are located and validated
if they can be.

3. FormatAddress.

Places a correctly formatted address (in compliance with NZPO requirements)
into the returned buffer. It is constructed from the decomposed elements
provided by FIB.

So, 3 Major methods, 4000 lines of COBOL code, but the web service exposes
only one method (ValidateNZaddress). This is a method of the service itself
(which is also a Class and gets its own object instantiated). The service is
written in C# but it can use the COBOL Class because the COBOL Class is a
COM server. (So objects from almost ANY environment (including DotNET) can
invoke it).

This is my point about components. Encapsulating functionality into a COM
component (or a Web Service) means you have, in effect, "future proofed" it.
As long as you need that functionality, it is available, anywhere you want
it, any time you want it, as "pluggable" functionality.

Pete.



Pete Dashwood

2007-05-25, 3:55 am


"James J. Gavan" <jgavandeletethis@shaw.ca> wrote in message
news:Z3n5i.215000$DE1.77290@pd7urf2no...
> Pete Dashwood wrote:
>
> Just in case you are itching to know runtimes based on following as
> modified, plus I also used your 'good address' :-
>
> *>----------------- soaptrigger.cbl ----------------------------
>
> *> Trigger PROCEDURAL program used here. Assume Soaptest was
> *> selected from a Mster Menu - then the Menu would invoke in a
> *> similar manner.
>
> Program-id. SoapTrigger.
>
> Class-Control. SoapTest is class "soaptest"
> DateAndTime is class "datetime"
> .
> WORKING-STORAGE SECTION.
> 01 os-SoapTest object reference value null.
> 01 os-DateTime object reference value null.
>
> 01 DateTime-start pic x(21).
> 01 DateTime-finish pic x(21).
>
> PROCEDURE DIVISION.
>
> invoke DateAndTime "new" returning os-DateTime
>
> invoke os-DateTime "getDateAndTime21"
> returning DateTime-start
> invoke SoapTest "new" returning os-SoapTest
> invoke os-SoapTest "begin"
> invoke os-DateTime "getDateAndTime21"
> returning DateTime-finish
>
> display "Soap Demo ccyymmddhhmmsshhGhhmm"
> display "Start of demo : " DateTime-start
> display "End of demo : " DateTime-finish
>
> STOP RUN.
>
> *>--------------------------------------------------------------
>
> Soap Demo Results :-
>
> Soap Demo ccyy mm dd hh mm ss hh G hhmm
> Start of demo : 2007 05 24 14 37 20 62 - 0700
> End of demo : 2007 05 24 14 37 21 89 - 0700
>
> Soap Demo ccyy mm dd hh mm ss hh G hhmm
> Start of demo : 2007 05 24 14 41 23 54 - 0700
> End of demo : 2007 05 24 14 41 24 60 - 0700
>
> Soap Demo ccyy mm dd hh mm ss hh G hhmm
> Start of demo : 2007 05 24 14 51 20 35 - 0700
> End of demo : 2007 05 24 14 51 21 78 - 0700


Thanks very much for that, Jimmy.

Always less than 1.5 seconds... acceptable. (I am working to improve it of
course.)

This matches the results I am getting here pretty closely, so the distances
don't seem to matter.

(I've seen local systems with worse performance than that, and some of those
were on mainframes (TSO...and CICS))

It's pretty amazing really that the Net can be that fast.

I'll be posting a batch demo to the site soon... :-)

Pete.

PS I read somewhere that it is necessary to have IIS installed in order to
run SOAP. I can't see why it would be, but can you confirm whether you have
it installed on your version of XP? (Home Edition doesn't have it, XP Pro
does not have it installed by default, you have to do it.)


Pete Dashwood

2007-05-31, 6:55 pm


"Alistair" <alistair@ld50macca.demon.co.uk> wrote in message
news:1180636643.671727.127390@k79g2000hse.googlegroups.com...
> On 24 May, 04:24, Richard <rip...@Azonic.co.nz> wrote:
>
> v3 was Event driven, as per VB.
>


No, that was PowerCOBOL V3.

Pete.


Pete Dashwood

2007-06-01, 9:55 pm


"Alistair" <alistair@ld50macca.demon.co.uk> wrote in message
news:1180716506.641544.60940@u30g2000hsc.googlegroups.com...
> On 1 Jun, 00:09, "Pete Dashwood" <dashw...@removethis.enternet.co.nz>
> wrote:
>
> Yep. I thought, after I had just sent the email, that someone
> (expletives deleted) would correct me on that.
>


Nothing personal... just in the interests of accuracy :-)

The expletives may well apply anyway :-)

Pete.


Sponsored Links







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

Copyright 2008 codecomments.com