ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

HTTPAPI http_string in-fo

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTPAPI http_string in-fo

    Hi
    in the last LIBHTTP that we ahve downloaded we see that in the EXAMPLE16 was used http_string instead of http_url_post_xml ...
    questions:
    1- with http_string is not possible to get the RC parameter Or similar ; if i have some error in the Xml, i receive CPFxxxx
    2- always with http_string, is not possible to read the response in case of error .. (i.e. if my web service ask a password and the password is expired .. i receive CPFxxx and i'm not able to understand the problem)
    3- Pheraps is better continue to use http_url_post_xml to call web service ??

    thanks in advance


  • #2
    You can still use http_url_post_xml if you prefer, it is still fully supported.

    If you prefer to use http_string() that will work as well. Just monitor for the error, and use http_error() to get the error message or response code.

    Code:
    monitor;
       http_string(parameters here)
    on-error;
       errorMsg = http_error(*omit: responseCode);
    end-error;
    
    if responseCode = 401;
       // got 401 unauthorized header
    endif;

    Comment


    • #3
      Scott thanks for your reply
      other help if possible ..
      with http_string (if the web service call fails ..) i can't get the xml respone document ? if yes , how ?
      other ..
      premise i'm not familiar with callback procedure..
      in the http_url_post_xml example i find the call to the incomig procedure

      rc = http_url_post_xml(
      'http://www.webservicex.net/CurrencyConvertor.asmx'
      : %addr(SOAP) + 2
      : %len(SOAP)
      : *NULL
      : %paddr(Incoming)
      : %addr(rate)
      : HTTP_TIMEOUT
      : HTTP_USERAGENT
      : 'text/xml'
      : 'http://www.webserviceX.NET/ConversionRate');

      with this procedure interface :

      P Incoming B
      D Incoming PI
      D rate 8F
      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)

      my doubt is : how http_url_post_xml know, which parameter have to use/pass when call Incoming ? if CurrencyConvertor returns other data besides to rate (for example last quotation data or description currency) how can i get this other values ? what the rule/meaning of %addr(rate) in the http_url_post_xml parameters ?

      thanks in advance and sorry for the last point (callback clarafication )

      thanks in advance anyway

      Gio

      Comment


      • #4
        If you'd like to receive the response document when there's an error, http_string is the wrong routine. Use http_req() instead.

        If you wish to receive multiple values from the callback from http_url_post_xml, pass a data structure or return them in global variables.

        Comment

        Working...
        X