[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: HTTPAPI / call webservice in base64binary-code



Hello Scott,

Thanks a lot for your answer. It helps me a lot.

Unfortunalety i have a little problem ( or way of thinking? ) in the base64 encoder. The result is not the same that I'm excepting:

To get a result which looks a little bit of an example I have i must first convert the string into ASCII-code. Is it right?
But as say the result isn't the same. Could the different codepage ( i'm working on a "german"-machine ) the reason?

This is the string i want to convert:
HDR              55ADD01                             459NVSL                      02136005571MSC ALESSIA... 

This is the base64-code i'm expecting:
SERSICAgICAgICAgICAgICA1NUFERDAxICAgICAgICAgICAgICAgICAgICAgICAgICAgICA0NTlODQpWU0wgICAgICAgICAgICAgICAgICAgICAgMDIxMzYwMDU1NzFNU0MgQUxFU1NJQSAgICAgICAg...

This is the base64-code my rpg-program gives me :(
SERSICAgICAgICAgICAgICA1NUFERDAxICAgICAgICAgICAgICAgICAgICAgICAgICAgICA0  NTlOVlNMICAgICAgICAgICAgICAgICAgICAgIDAyMTM2MDA1NTcxTVNDIE...


This source-code i use:

 ...
  * read streamfile  (fdO )                                                          
 C                   eval      len = read(fdO:%addr(rddata):%size(rddata))         
 C                   DOW       len = %size(rddata)                                 
 C                   MOVEA     rddata        W_CHAR(1)                            
 C     1             DO        54            I                                     
 C                   EVAL      W_CHAR(I) = CHG_EBC_ASC(W_CHAR(I))                      
 C                   ENDDO                                                         
 C                   MOVEA     W_CHAR(1)     rddata                                
 C                   EVAL      len3 = Base64_encode(                               
 C                         	            %addr(rddata):%size(rddata):             
 C                                        %addr(wrdataN):%size(wrdataN))           
  * write file in base64-code (fdN)
 C                   callp     write(fdN: %addr(wrdataN): %size(wrdataN))          
  * read next                                                                    
 C                   eval      len = read(fdO:%addr(rddata):%size(rddata))         
 C                   ENDDO                                                         
...


P CHG_EBC_ASC     B                                                  
D                 PI             1                                   
D   ZEICHEN                      1                                   
C                   Z-ADD     1             BUFLEN            5 0    
C                   MOVE      ZEICHEN       BUFFER            1      
C                   MOVEL     'QASCII'      SBTBL            10      
C                   MOVEL     'QSYS'        SBLIB            10      
C                   CALL      'QDCXLATE'                             
C                   PARM                    BUFLEN            5 0    
C                   PARM                    BUFFER            1      
C                   PARM                    SBTBL            10      
C                   PARM                    SBLIB            10      
C                   RETURN    BUFFER                                 
P                 E                                                  


Thanks again and many greetz from Germany
Marcus



 


-----Ursprüngliche Nachricht-----
Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von Scott Klement
Gesendet: Mittwoch, 9. Mai 2007 07:03
An: HTTPAPI and FTPAPI Projects
Betreff: Re: HTTPAPI / call webservice in base64binary-code

Hi Marcus,

I suggest that you follow these steps:

a) Create a temporary stream file in the IFS.  The http_tempfile() API in HTTPAPI will give you a unique, temporary, IFS filename.

b) Write the top of your SOAP message to the file.

c) Open the file you want to base64 encode in binary mode, read it 54 bytes at a time.  Feed it into a base64 encoder to produce 74 bytes of encoded data.  Write that to the temp stream file.

d) Repeat step c until you've sent the whole file to the IFS document.

e) Write the bottom of your SOAP message to the file.

f) Close the temporary stream file.

g) Call http_url_post_stmf() to send the temporary stream file to the web service.  Download the response into a second temporary stream file.

h) Delete the original temporary stream file.

i) Call http_parse_xml_Stmf() API to parse the newly downloaded XML stream file to get the response from the web service.

j) Once you're done, delete the 2nd stream file.

There are some base64 encode/decode routines at the following link:
http://www.scottklement.com/base64/

Let us know how it works out, or if you have any questions.


Marcus Schmidtke (Besitec IT DEBRE) wrote:
> Hello to all,
> 
> I'm not really used not to call webservices direct on our AS/400.  
> 
> But now we have to implement the call of a webservice of our client. I 
> have to insert a streamfile from ifs in base64binary-code in a soap 
> like this example:
> 
> <?xml version="1.0"?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><SOAP-ENV:Body><
> Ch
> eck xmlns="http://.../";>
> <fileName>file.txt</fileName>
> <fileContent> !!!here stream-file convert in base64binary!!!
> </fileContent>
> </Check></SOAP-ENV:Body></SOAP-ENV:Envelope>
> 
> Answer will also be a xml-file with base64binary-code included. 
> 
> Could you give a tip which example in LIBHTTP is the best to solve 
> this request?
> 
> Thanks and best regards
> Marcus

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------