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

First Timer: HTTPS And http_url_post_stmf - Issues



   Hello Everyone,



   First, I want to say what a fantastic resource I have found this site
   to be.  I am an ooollldd S/36, S/38, AS/400 green screener, so when I
   had a project handed to me that involved Web Services, I definitely
   had the deer in the headlights look on my face.



   It turned out that the HTTPAPI libraries had been loaded on our
   AS/400, but were not being utilized, so there was really no one here
   that could offer me a lot of help.  I have picked up quite a bit
   reading through these lists, but due to my lack of knowledge, I am
   still having issues.



   I am trying to consume web services through a service utilizing
   RESTful architecture.  I am building an XML file, formatted through
   Inovis TrustedLink, and placed on the IFS.  To execute a POST
   operation, I am utilizing the HTTP_URL_POST_STMF() API.  The site I am
   connecting to is an HTTPS, and they specify they are utilizing SSL,
   which can also be seen as their certificate info is present in the
   HTTP Debug file.  I have imported their certificate into DCM and
   believe I have it correctly setup and linked to my program.



   When the program is run, it connects to their site, but I am
   continually getting a "400 - Bad Request" error message in reply.
   However, if I download the XML file from the IFS, and send it as an
   e-mail attachment to the client, they are able to easily load it into
   their system with no issues.



   So, I am hoping someone can review the attached documents which
   include my program, debug file, response file, and upload file, and
   hopefully provide me some assistance.  I have removed any "private"
   data from the debug file to "protect the innocent".



   Looking forward to hearing from everyone.



   Thanks in advance for your help.



   Mike Schwartz

   Cengage Learning

   Independence, KY
     H DEBUG(*YES)
     H DFTACTGRP(*NO)
     H ACTGRP(*NEW)
     H BNDDIR('LIBHTTP/HTTPAPI')
     H BNDDIR('QC2LE')
      *
     FF597URL   IF   E           K DISK
      *
     D/COPY LIBHTTP/qrpglesrc,HTTPAPI_H
     D/COPY LIBHTTP/qrpglesrc,IFSIO_H
     D/COPY LIBHTTP/qrpglesrc,ERRNO_H
     D/COPY JDECPY,E98031L
      *
      *** System data structure for record locks.
     D StAtus         SDS           333
      *
      *** Work Fields.
     D APP_ID          C                   CONST('EDI_HTTPAPI')
     D Prm_Org         S              4
     D Prm_PnID        S             15
     D Prm_WsID        S             25
     D ##PID           S             10
     D ##VERS          S             10
     D msg             s             52A
     D rc              s             10I 0
      *
     D Wrk_RetCode     S             10I 0
      *                                                                       
      *** Entry parameters.
     C     *Entry        Plist
     C                   Parm                    ##PID
     C                   Parm                    ##VERS
      *
      *** Key lists.
     C     URLKey        Klist
     C                   Kfld                    Prm_Org
     C                   Kfld                    Prm_PnID
     C                   Kfld                    Prm_WsID
      *
      *** Initialize the program.
     C                   ExSr      Sub_Init
      *                                                                        
      *** Set debug to ON.
     C                   callp     http_debug(*ON)
      *                                                                        
      *** Retrieve and load Processing Options.
     C                   ExSr      Rtv_Proc_Opt
      *                                                                        
      *** Get the URL for the web service.
     C     URLKey        Chain     I597URL                            91
      *
     C                   If        *In91 = *Off
      *
      *** Initialize HTTPS.
     C                   eval      rc = https_init( APP_ID )

     C                   if        rc < 0
     C                   eval      msg = http_error(rc)
     C                   endif
      *
      *** Set the User ID authority for the request.
     C                   callp     http_setauth(
     C                             HTTP_AUTH_BASIC:
     C                             %trim(UlUid):
     C                             %trim(UlPwd))
      *
      *** Set CCSID's.
     C***                callp     http_SetFileCCSID(1209)
      *
      *** Post the web service request to the web site using a procedure
      *** from HTTPAPI.
     C                   Eval      Wrk_RetCode = http_url_post_stmf(
     C                             UlUrl:
     C                             %trim(UlIFSP):
     C                             %trim(UlIFSR))
      *
      *** If an error was returned, send it back to the calling program.
     C                   If        Wrk_RetCode <> 1
     c                   eval      msg = http_error
     C                   EndIf
      *
     C                   EndIf
      *
      *** End the program.
     C                   Move      *On           *InLr
      *                                                                        *
      *** Initialize global fields.                                          ***
     C     Sub_Init      BegSr
     C                   EndSr
      *                                                                        *
      *** Retrieve Processing Options.                                       ***
     C     Rtv_Proc_Opt  BegSr
      *
     C                   exsr      c98031
      *
      *** Load EDI Organization Code
     C                   movel     @op(1)        Prm_Org
      *
      *** Load EDI Trading Partner ID to process
     C                   movel     @op(2)        Prm_PnID
      *
      *** Load Web Service ID Code to process
     C                   movel     @op(3)        Prm_WsID
      *
     C                   EndSr
      *                                                                        *
      *** Standard initialization subroutine.                                ***
     C     *INZSR        BegSr
     C                   EndSr
      *
     C/COPY JDECPY,C98031L
      *

HTTPAPI Ver 1.17 released 2006-09-23

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
https_init(): entered
-------------------------------------------------------------------------------------
Dump of local-side certificate information:
-------------------------------------------------------------------------------------
http_setauth(): entered
http_url_post_stmf(): entered
getting post file size...
opening file to be sent...
opening file to be received
http_persist_open(): entered
http_long_ParseURL(): entered
-------------------------------------------------------------------------------------
Dump of server-side certificate information:
-------------------------------------------------------------------------------------
Cert Validation Code = 0
-----BEGIN CERTIFICATE-----
****************************************************************
-----END CERTIFICATE-----
Serial Number: 00
Common Name: test.testsite.com
Country: US
State/Province: State
Locality: City
Org Unit: Company
Org: test
Issuer CN: test.testsite.com
Issuer Country: US
Issuer State/Province: State
Issuer Locality: City
Issuer Org: Company
Issuer Org Unit: test
Unknown Field: 03
Unknown Field: 20080429135641
Unknown Field: 20090429135641
Unknown Field: 1.2.***.******.1.1.4

Protocol Used: TLS Version 1
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /rest/v1/publisher                                    HTTP/1.1
Host: test.testsite.com
User-Agent: http-api/1.17
Content-Type: text/xml
Expect: 100-continue
Content-Length: 257
Authorization: Basic ************************


recvresp(): entered
HTTP/1.0 400 Bad Request
Connection: close
Content-Type: text/html
Content-Length: 349
Date: Wed, 15 Apr 2009 18:09:36 GMT
Server: lighttpd


SetError() #13: HTTP/1.0 400 Bad Request
recvdoc parms: identity 349
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
 <head>
  <title>400 - Bad Request</title>
 </head>
 <body>
  <h1>400 - Bad Request</h1>
 </body>
</html>

SetError() #13: HTTP/1.0 400 Bad Request
http_close(): entered
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
 <head>
  <title>400 - Bad Request</title>
 </head>
 <body>
  <h1>400 - Bad Request</h1>
 </body>
</html>
<?xml version="1.0"?>                                                                                                               <request><publisher action="insert"><publisher_sid>1234567</publisher_sid><name>Publisher Name</name></publisher></request>
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------