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

RE: RE: How can i get XML result after execution of 'http_url_post_xml'



If I understand correctly, you would like to parse the xml for an error message. Something like:

<xml><webservice1><oops>You sent me data I don't know what to do with!</oops></webservice1></xml>

Assuming <oops> will not be present when you get valid data, you can parse the file in the IFS using the included EXPAT parser or XML-INTO. Based on EXAMPLE11.

D num             s             10I 0        
D global_error    s               n   inz(*off)
D global_error_message...
D                 s           1024A

   Global_error = *off;
   Global_error_message = *blanks;
   // **************************************************** 
   //   parse the XML from the temp file.                  
   // **************************************************** 
                                                        
   if (http_parse_xml_stmf( filename                       
                          : HTTP_XML_CALC                  
                          : *null                          
                          : %paddr(Incoming)               
                          : *null ) < 0 );                 
      PrintLine = http_error();                            
      except;                                              
      unlink(filename);                                    
      return;
   elseif global_error;
      Big_xml_oops(global_error_message);
   Else;
      // good data let's send it off someplace else.                                              
   endif;

...

P Incoming        B                                           
D Incoming        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) 

/free                                                        
    if (name = 'oops');                                   
      // Signal error back by flipping global error flag;
      global_error = *on;
      global_error_message = value;                                         
    endif;                                                    
/end-free            
P                 E   



-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Patrick Goovaerts
Sent: Thursday, December 13, 2012 9:51 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: FW: RE: How can i get XML result after execution of 'http_url_post_xml'

Hi Mike,

Thx for the info.  I managed to get the response-XML into an IFS file using the 'HTTP_URL_POST' routines.

But now I face another problem.
For 'error handling' I need to check the XML-response data for the existence of some specific text.  So, I can parse the responsefile using XML-INTO but, given the amount of different webservices to be executed AND the possibility that the responsefile returns other data (if correct, valid XML-data results are sent but if not correct, sometimes an HTTP message is returned) it is again a hell of a job for coding this.

So, I want to inspect the returned XML-data for specific texts before forwarding the XML to the different applications which will process the data.  That allows me to give some error codes to the apps to avoid this kind of checking to be executed in each application separately...

Problem:
Because the data is returned as 1 string without any delimeters (CRLF), I cannot use CPYFRMSTMF to get the data.  I don't know how large the data will be and I already noticed that the data can be larger then 66000 characters...

Question:
Is it possible to get an XML response with 'CRLF' after each element?
I tried to use the statement
http_XmlStripCRLF(*OFF);
but is does not work either.

(created another thread for this statement too).


Regards,


Patrick Goovaerts
Systems & Development

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