× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Paul,

You will see the link in another email about the article that has the copy member with the prototypes. All of the commented lines are just because this is a proof of concept version and when I was troubleshooting in debug I simplified the program for my benefit. At some point soon I will clean it up and uncomment most of those lines before I create a production version. Retlen is defined 10i 0 and correct that the write is writing to the ifs, it is in an if statement because it returns a value indicating if it was successful or not. All the IFS routines I got from Scott Klement's site at http://www.scottklement.com/presentations/ - see the one RPG and the IFS, there is a presentation there explaining them.

Scott


-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of PReid@xxxxxxxxxxxx
Sent: Thursday, December 12, 2013 1:20 PM
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] Advice on how to process xsd:base64Binary XML element retrieved from a web service.

Thanks Scott... I have a few questions about your code.

It looks as if several of your lines of code are commented out...is that correct???
//callp EscErrno(errno);
//dsply ('RANDRTVLOG Write PDF Error: ' + errno
//eval err = errno;
//callp EscErrno(err);

I see where you open a new file on the IFS - where do you write to it. Is it the
"if write(fd: %addr(PDFData) : retlen)" - this looks like it's
checking for an error???

What size should is define "retlen"?

I cannot find "apr_base64_decode" anywhere in the code I downloaded from Scott...is this maybe an IBM API?

___________________________________________________________
Paul Reid
Application Developer III
Erb Group of Companies | 290 Hamilton Road | New Hamburg, Ontario | N3A
1A2
Phone: 519.662.6133 ext. 2363
Web: http://www.erbgroup.com/



From: Scott Mildenberger <SMildenberger@xxxxxxxxxxxxxxxxxx>
To: "Web Enabling the IBM i (AS/400 and iSeries)"
<web400@xxxxxxxxxxxx>
Date: 12/12/2013 02:46 PM
Subject: Re: [WEB400] Advice on how to process xsd:base64Binary XML
element retrieved from a web service.
Sent by: web400-bounces@xxxxxxxxxxxx



Paul,

I just recently did this using HTTPAPI where one of the elements was a pdf
file Base64 encoded. This is just a proof of concept program so not
complete but it does decode the element and save to a file in the IFS.
Below is the code in the 'incoming' procedure, my element was in 'PDFData'
hence the if at the top. The apr_base64_decode procedure is in a copy
member APR_B64_H that I think I got from Scott K's website but not sure as
there are no comments identifying its origin. The prototype for the
procedure I use is listed at the bottom. I use the same post procedure
that you have. If you have questions on the below let me know, this was
the first time I have done this but using the examples it all worked fine.

if name = 'PDFData';
PDFData = value;

// Base64 decode

TmpValue = %subst(PDFData : 1 : %len(value));
retlen = apr_base64_decode(PDFData : TmpValue);

// Store PDFData to an ifs file.
unlink('/home/SCOTT/log.pdf');
eval fd = open('/home/SCOTT/log.pdf':
O_WRONLY+O_CREAT+O_CODEPAGE:
S_IRUSR + S_IWUSR + S_IXUSR
+ S_IRGRP + S_IXGRP
+ S_IROTH + S_IXOTH : 819);
if fd < 0;
//callp EscErrno(errno);
//dsply ('RANDRTVLOG Write PDF Error: ' + errno
endif;


if write(fd: %addr(PDFData): retlen)
< retlen;
//eval err = errno;
callp close(fd);
//callp EscErrno(err);
endif;

callp close(fd);

ENDIF;

Prototype:

D apr_base64_decode...
D pr 10i 0 extproc('apr_base64_decode')
D plain_dst 65535a options(*varsize)
D coded_src * value options(*string)


Scott Mildenberger


-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of PReid@xxxxxxxxxxxx
Sent: Thursday, December 12, 2013 11:43 AM
To: web400@xxxxxxxxxxxx
Subject: [WEB400] Advice on how to process xsd:base64Binary XML element
retrieved from a web service.

Hello everyone. I've posted this exact same email - pretty much - on Scott
Klement's FTPAPI/HTTPAPI mailing list, however I'm not getting any
response back, so I thought I'd report my problem here.

I am not very experienced with Web Services so bear with me. I did a fair
bit of research on the various forums before posting, but I failed to find
a good example of what I am looking for. I'm hoping that someone can help,
possibly with an example.

I am predominately an RPG programmer. We are running an IBM Power 7 at
V7R1, and I have Scott Klements's HTTPAPI V1.24 downloaded and installed.
I am using HTTPAPI to consume another Web Service and it works
beautifully.

My latest challenge it that I have consume a Web Service that includes an
element in the XML response that is data type xsd:base64Binary and I'm not
really sure how to do it. The WSDL for this web service is:
https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/OTSWebSvcs.wsdl

The WIKI for this Web Service is:
https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequeue
The method that I must consume is named DEQUEUE2.

I have created an RPG program that POSTS a request to the Web Service
using the following HTTPAPI subprocedure:

rc = http_url_post_xml(
'https:
//www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(rate)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: 'http://www.qualcomm.com/dequeue2');

I am receiving rc = 1 which I believe means that I am successfully
receiving an XML response. FYI - The procedure "Incoming" was copied from
Scott Klement's EXAMPLE11.

The response XML is as follows.
<soapenv:Body>
<dequeue2Response>
<dequeue2Return>
<count>6</count>
(transactions>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48dHJjaz4=
</transactions>
<transactionIdOut>58744654</transactionIdOut>
</dequeue2Return>
</dequeue2Response>
</soapenv:Body>

The "transactions" element is xsd:base64Binary and I don't know how to
decode it. I have downloaded Scott's BASE64R4 service program and I
suspect I'd use procedure BASE64_DECODE, but I'm not sure how to use it.
Also...according to the wiki the "transactions" element could be as large
as "Approximately 1mb" although I'm not really sure what they mean by
approximately??? I'm not sure how to handle something that big.

The "count" and "transactionIdOut" and not encoded and I need the data in
them in addition to the encoded data.

I understand that I may not even be using the correct post procedure
(remember I'm not that experienced) and in the interim I am going to try
some of Scott's other procedures.

Any help or examples on how to get this data would be much appreciated.
Thanks!
___________________________________________________________
Paul Reid
Application Developer III
Erb Group of Companies | 290 Hamilton Road | New Hamburg, Ontario | N3A
1A2
Phone: 519.662.6133 ext. 2363
Web: http://www.erbgroup.com/
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list To post a message email: WEB400@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.