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

Re: Example 1 302 error



Hi Craig,

I hope you have good luck getting it to work through WebSense.

FWIW, I took your idea and wrote up a quick RPG program to get a quote. 
  This program just displays the quote as a *COMP message, but I thought 
it might interest you and others who like the "quote of the day" idea. 
Here's the code:

      H DFTACTGRP(*NO) BNDDIR('HTTPAPI')

       /copy HTTPAPI_H

      D Quote_t         ds                  qualified
      D                                     based(Template)
      D   msg                        500a   varying
      D   author                      50a   varying

      D endTag          PR
      D   quote                             likeds(quote_t)
      D   depth                       10I 0 value
      D   ns                        1024A   varying const
      D   name                      1024A   varying const
      D   path                     24576A   varying const
      D   value                    65535A   varying const
      D   attrs                         *   dim(32767)
      D                                     const options(*varsize)

      D soap            s           1024a   varying
      D url             s           1024a   varying
      D action          s           1024a   varying
      D Quote           ds                  likeds(Quote_t) inz
      D rc              s             10i 0
       /free

         http_debug(*ON);
         http_XmlStripCRLF(*ON);
         http_XmlNs(*ON);

         soap =
          '<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> +
           <SOAP-ENV:Envelope +
 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";  +
                xmlns:tns="http://swanandmokashi.com"; > +
           <SOAP-ENV:Body> +
                <tns:GetQuote /> +
           </SOAP-ENV:Body> +
           </SOAP-ENV:Envelope>';

         url = 'http://swanandmokashi.com/HomePage/+
                  WebServices/QuoteOfTheDay.asmx';
         action = 'http://swanandmokashi.com/GetQuote';

         rc = http_url_post_xml( url
                               : %addr(soap) + 2
                               : %len(soap)
                               : *null
                               : %paddr(endTag)
                               : %addr(quote)
                               : HTTP_TIMEOUT
                               : HTTP_USERAGENT
                               : 'text/xml'
                               : action );
         if (rc <> 1);
             http_crash();
         endif;

         http_comp( '"' + %trim(quote.msg) +
                    '"  -- ' + %trim(quote.author));

         *inlr = *on;

       /end-free

       *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       * endTag(): This is called by HTTPAPI for each ending XML tag
       *           that's received over the network
       *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      P endTag          B
      D endTag          PI
      D   quote                             likeds(quote_t)
      D   depth                       10I 0 value
      D   ns                        1024A   varying const
      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 ( ns = 'http://swanandmokashi.com' );
             select;
             when (name = 'QuoteOfTheDay');
                quote.msg = value;
             when (name = 'Author');
                quote.author = value;
             endsl;
          endif;
       /end-free
      P                 E


Craig Jacobsen wrote:
> Scott,
> 
> Scott,
> 
> It is a redirect to Websense (I think).  I had to run EXAMPLE 1 and
> quickly get the session id it was assigned.  When I put my userid and
> password in, it went right to your site at
> HTTP://www.scottklement.com/rpg/socktut/tutorial.pdf
> 
> I'll add the redirect with authentication and that should work.
> 
> Thanks for everyone's help,
> 
> Craig
> 
> -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott
> Klement
> Sent: Monday, May 12, 2008 1:53 PM
> To: HTTPAPI and FTPAPI Projects
> Subject: Re: Example 1 302 error
> 
> Hi Craig,
> 
> A 302 is a 'redirect'  It's typically sent by an HTTP server that wants 
> a browser to connect to a different link.   In HTTPAPI, you'd handle 
> that as follows:
> 
>     rc = http_url_post( ... whatever ... );
> 
>     if rc=302;
>        url = http_redir_loc();
>        rc = http_url_get( url . . .  );
>     enddo;
> 
> Basically, the url_post() call asked for a redirect, so you do a URL get
> 
> to the location it has asked to redirect to.   the http_redir_loc() 
> routine will return the location they requested a redirect to.
> 
> I agree with Mike that this particular redirect appears to be 
> redirecting you to a local machine -- so I suspect it's some sort of a 
> deal where you have to sign in before you can access the Internet. 
> Sometimes these are implemented as proxies, but sometimes they're 
> implemented using reverse NAT or a similar tool to make them
> transparent.
> 
> But that part is just a guess.  the only part I really know at this 
> point is that it's sending you a redirect, and it's telling you that the
> 
> URL to redirect to is 
> http://172.27.3.12:15871/cgi-bin/authenticate.cgi?ws-session=3774914013
> 
> I can't go to that page to see what it is -- it's a private IP address 
> that would only be available from within your network.  But, if you 
> follow the redirect, as I explained above, you should be able to 
> download the HTML for that page, and hopefully it'll give you a good 
> idea of what the page is...
> 
> 
> Craig Jacobsen wrote:
>> I saw some of the earlier posts and wanted to incorporate some news on
>> our Intranet site.  I am already getting the weather from the Weather
>> message file (thanks Scott) and am calling another program that uses
>> soap to get a quote of the day
>> ('http://swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx')
>> which is successful and runs during the page creation in Net.Data.  I
>> tried the rss feed to iseries and got the 302 error.  I made the
> change
>> that Scott suggested to go to another news service and got the same
>> error.  I saw I was getting the 302 error at http_url_get so I tried
>> Example 1 which also uses http_url_get to Scott's web site which I
> know
>> is OK.  I am failing at the do_get subprocedure in the service program
>> and getting a return code of 302.
>>
>>
>> Here is the debug log:
>> HTTPAPI Ver 1.23 released 2008-04-24
>>
>> OS/400 Ver V5R2M0
>>
>>  
>>
>> New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819.
> ProtLoc=0
>> http_url_get(): entered
>>
>> http_persist_open(): entered
>>
>> http_long_ParseURL(): entered
>>
>> DNS resolver retrans: 2
>>
>> DNS resolver retry  : 2
>>
>> DNS resolver options: x'00000136'
>>
>> DNS default domain: urlmutual.com
>>
>> DNS server found: 172.27.3.3
>>
>> DNS server found: 172.27.3.5
>>
>> http_persist_get(): entered
>>
>> http_long_ParseURL(): entered
>>
>> do_get(): entered
>>
>> GET /rpg/socktut/tutorial.pdf HTTP/1.1
>>
>> Host: www.scottklement.com
>>
>> User-Agent: http-api/1.23
>>
>>  
>>
>>  
>>
>> recvresp(): entered
>>
>> HTTP/1.0 302 Moved
>>
>> Location:
>>
> http://172.27.3.12:15871/cgi-bin/authenticate.cgi?ws-session=3774914013 
>> Pragma: no-cache
>>
>> Cache-Control: no-cache
>>
>>  
>>
>>  
>>
>> SetError() #13: HTTP/1.0 302 Moved
>>
>> recvdoc parms: identity 0
>>
>> header_load_cookies() entered
>>
>> recvdoc(): entered
>>
>> SetError() #0:
>>
>> SetError() #13: HTTP/1.0 302 Moved
>>
>> http_close(): entered
>>
>>
>> Any help would be appreciated,
>>
>> Craig
>>  ************End of Data********************
>>
>>
>>
>>
>> Confidentiality Notice: This e-mail message, including any
> attachments, is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information. Any unauthorized
> review, use, disclosure or distribution is prohibited. If you are not
> the intended recipient, please contact the sender by reply e-mail and
> destroy all copies of the original message.  Unless expressly stated in
> this e-mail, nothing in this message or any attachment should be
> construed as a digital or electronic signature.
> -----------------------------------------------------------------------
>> 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
> -----------------------------------------------------------------------
> 
> Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.  Unless expressly stated in this e-mail, nothing in this message or any attachment should be construed as a digital or electronic signature.
> -----------------------------------------------------------------------
> 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
-----------------------------------------------------------------------