[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: HTTPAPI, RPG and COBOL
Honestly I am not sure about what you try to accomplish. How many
callbacks to you use? What do you use the "endElement" callback for?
Actually it is used internally by the HTTPXMLR4 module:
endElement B export
endElement PI
root likeds(elemroot)
name * value
And what is the "Callback" procedure used for? Your example code has
been taken from the HTTPXMLR4 module. It is used to call the
user-defined end-element callback that has been specified at the
http_url_post_xml() statement.
p_callback s * procptr
Callback PR extproc(p_callback)
userdata * value
depth 10I 0 value
name 1024A varying const
path 24576A varying const
retval * value
Attrs * dim(32767)
const options(*varsize)
Usually you need to create a callback procedure with the following
interface:
D EndOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
In case your element values exceeds 64k, you need to call
http_XmlReturnPtr(*ON) and use the following callback interface:
D valDS_t ds template
D p_newval * inz(*null)
D len 10i 0 inz(0)
D EndOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D valDS likeds(valDS_t) const
D attrs * dim(32767)
D const options(*varsize)
Then you pass the procedure pointer of that procedure to the
http_url_post_xml() procedure. The parser calls your "Callback"
procedure whenever it encounters a closing element tag. Inside your
callback procedure you can use http_nextXmlAttr() to spin through the
list of attributes like this:
D i S 10i 0
D name S 1024a varying
D value S 65535a varying
i = 1;
DoW (http_nextXmlAttr(attrs: i: name: value);
// Do something with 'name' and 'value'.
// i is increment inside http_nextXmlAttr().
EndDo;
Thomas.
-----Urspr�he Nachricht-----
Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von
Salaheddine Zaki
Gesendet: Donnerstag, 28. Januar 2016 13:51
An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Betreff: HTTPAPI, RPG and COBOL
Hi everybody;
Based on HTTPAPI library of Scott Klement, and using the example of
calling the Web service CurrencyConvertor (accessible from
[1]http://www.webservicex.net), I developed a COBOL program (Similar to
one provided in the example
[2]http://scottklement.com/archives/ftpapi/200812/msg00014.html ) that
consuming a Local Web Service, except at the level of XML PARSER I
can't get the value of the attribute of the tag. Let me explain: the
XML PARSER parameters are:
LSAA-DUMMY: Pointer
LSAA-XML-DEPTH: Pointer
LSAA-NAME: The name of the XML tag
LSAA-PATH: The path tag
LSAA-VALUE: The value of the tag
LSAA-ATTRS: A pointer that's supposed containing a pointer table of the
attributes and values of each tag (eg <tag1 attr1 = "xxx"> "yyyy" </
tag1) -> This is where I have problem.
The XML PARSER is called after each callback of the RPG procedure. And
it's receives the expected parameters, except in case of a tag with
attribute (eg. attr1) the PARSER receives a null pointer (Eval pointer
gives "Identifier does not exist").
I think that the problem is at the passing/crossing of parameters
between programs.
Are Did anyone have already encountered this problem ?
For full clarification, here are the details of the problem :
1- The COBOL program "WSCALL" calls an RPG HTTP_URL_POST_XML
procedure, by passing some parameters like: the URL of the WS, the
TIMEOUT, CONTENT-TYPE, ACTION ... etc (see code).
CALL PROCEDURE
"HTTP_URL_POST_XML" USING BY REFERENCE WSAA-URL
BY VALUE WSAA-SOAP-POINTER
BY VALUE WSAA-SOAP-LEN
BY VALUE WSAA-STARTPROC-POINTER
BY VALUE WSAA-ENDPROC-POINTER
BY VALUE WSAA-OUTPUT-POINTER
BY VALUE WSAA-TIMEOUT
BY REFERENCE WSAA-USER-AGENT
BY REFERENCE WSAA-CONTENT-TYPE
BY REFERENCE WSAA-SOAP-ACTION
RETURNING WSAA-RETURN-CODE.
2- 2- After running and receiving / reading the XML response, and when
closing a tag (</ tag>) EXPORT RPG procedure is called, it makes a
callback by completing a structure:
Callback( root.userdata
: rootDepth(root)
: element.name
: elemPath(root: element)
: p_retval
: wwAttrAry
);
The structure is defined as follows:
endElement B export
endElement PI
root likeds(elemroot)
name * value
p_callback s * procptr
Callback PR extproc(p_callback)
userdata * value
depth 10I 0 value
name 1024A varying const
path 24576A varying const
retval * value
Attrs * dim(32767)
const options(*varsize)
qqq
3- Evaluating the wwAttrAry, the result is:
> EVAL wwAttrAry
WWATTRARY (1) = SPP: E9AC54183F05AF70
WWATTRARY (2) = SPP: E9AC54183F05AF90
WWATTRARY (3) = SPP: * NULL
WWATTRARY (4) = SPP: * NULL
WWATTRARY (5) = SPP: * NULL
.... etc.
WWATTRARY (500) = SPP: * NULL
Here is the result of a first table case: EVAL on the table :
wwAttrAry(1):C 100 ==> "v � Z�y GREEN"
the "v" is the name of the attribute, "GREEN" is its value.
4- Continuing the execution, the PARSER is called, only the LSAA-NAME,
LSAA-PATH and LSAA VALUE parameters are set.
Question :
1 - How i can get the right parameters return in my COBOL program (Get
all parameters, not only LSAA-NAME, LSAA-PATH and LSAA VALUE).
2 - How can i read the content of the table wwAttrAry case by case (get
the values not the pointers adresses)
Thank you so much for your potential returns.
Best regards.
--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only. Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a
criminal offence. Please delete if obtained in error and email
confirmation to the sender.
References
1. http://www.webservicex.net/
2. http://scottklement.com/archives/ftpapi/200812/msg00014.html
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------