Re: Web Services and COBOL (Fairly long post, but I don't have time to write a proper article on it)



Round of applause!!!

Really good stuff, Jimmy.

Some comments below...

"James J. Gavan" <jgavandeletethis@xxxxxxx> wrote in message
news:EY85i.214410$6m4.184311@xxxxxxxxxxxx
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 cool, 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


.



Relevant Pages

  • Re: Web Services and COBOL (Fairly long post, but I dont have time to write a proper article on it)
    ... Menu driven application - from the Trigger start the App ... interoperability in COBOL. ... invoke EventManager "new" returning os-EventManager ... However the web service, although being around 4000 lines of OO COBOL ...
    (comp.lang.cobol)
  • Re: Web Services and COBOL (Fairly long post, but I dont have time to write a proper article on it)
    ... I initially downloaded SOAP but doing that Registry check found I already had it. ... I went with the Class format - same as you did but now your paragraphs become methods. ... invoke SoapTest "new" returning os-SoapTest ... invoke objSOAPClient "ValidateNZaddress" ...
    (comp.lang.cobol)
  • Web Service - Invoke button missing?
    ... I've inherited a Web Service from a developer who is no longer ... Invoke button has disappeared. ... Now it says "The test form is only available for requests ... I suppose I could go to our web server and ...
    (microsoft.public.dotnet.languages.csharp)
  • SOAP Zugriff auf SAP WAS / Xml-Namespace
    ... SAP-WebApplicationService, und dort eine Methode, über SOAP ... der server, von dem ich nach dem abarbeiten von 'Invoke' aus/in meiner ... und ich bekomme hier zwar auch ein objektarray mit zwei elementen ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Web Service does not display SQL Data
    ... > web service via Visual Studio .Net using VB. ... > The service seems to work fine, displaying the option to 'Invoke' ... However once I click 'Invoke' I receive ... > an error HTTP 500 'The page cannot be displayed'. ...
    (microsoft.public.dotnet.framework.webservices)