--Hi David,
Thanks for the trace file. What is happening looks like this:
1) HTTPAPI extracts the host name from your URL. For example, if the URL contains http://www.rrd.com/test1/test2 it will extract www.rrd.com
2) HTTPAPI passes this (www.rrd.com, or whatever the name was) to the operating system function gethostbyname().
3) Under the covers, the operating system will query your name servers, by sending a DNS request to 10.79.131.126, 172.24.8.126 and 172.24.14.21 as configured on your system.
What's happening is that gethostbyname() is returning NULL, which means that it could not find the domain name, the servers didn't respond, or there is no address for that host name, or some similar error.
You mentioned "The DNS answer a ping and returns the correct IP". Can you expound on that? Do you mean that on the command line of the same IBM i partition, you are typing PING RMTSYS('www.rrd.com') (or whatever the host name happens to be) and it's working and correctly returning the IP address of the host?
If so, I can only guess that you have some sort of a typo in the one that you are passing to HTTPAPI -- because that doesn't make much sense. In both cases, the operating system is looking up the host name via the same underlying routine. Why would it work from PING vs. HTTPAPI? I can only guess there's a typo.
Or, another problem might be that the parameter list has a mismatch. (Especially since you're using the 1980's *ENTRY PLIST syntax, which is very prone to this problem.) Perhaps the URL is getting corrupted during parameter passing? If you run your program in debug, immediately before calling http_url_post_raw, what is the contents of PR_Destination?
-- Scott Klement sk@xxxxxxxxxxxxxxxxOn 11/24/2020 6:52 PM, David Hanneman wrote:
LIBHTTP release 1.23Looking for some help with this error message: "SetError() #2: Host name look up failed'
The DNS answer a ping and returns the correct IP.
The trace is not showing any activity going to the destination.
I am using http_url_post_raw. I cloned EXAMPLE05 and tweaked the PARMS to it look like this:
--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi
* * Generic HTTP POST STMF program using Scott Klement's LIBHTTP 1.23 * uses the "raw" versio of http_url_post(). The advantage is * that data is received directly into a variable in the program * instead of writing it to the IFS. * ** Program accepts 6 Parms ** 1. Standard 2E 7 byte return code. Blank = Ran Ok, Non-Blank is an error ** 2. Output error message 52 bytes ** 3. Destination URL 512 bytes ** 4. Content-Type 256 bytes ** 5. Input Data 32766 bytes ** 6. Output Data 32766 bytes ** Compile Options: ** Put LIBHTTP at the top of the *LIBL ** ** CRTBNDRPG PGM(W2GEND/WODSAUR0) ** SRCFILE(W2SRCD/QRPGLESRC) ** DFTACTGRP(*NO) ** ACTGRP(*NEW) ** DBGVIEW(*SOURCE) ** REPLACE(*YES) ** TGTRLS(*CURRENT) ** ** TURNOVER: ** TEST: Compile once in D and use CSCD option ** PROD: CSCD option - DO NOT RECOMPILE! *--------------------------------------------------------------* * IMB LIBHTTP copies required to run Post API procedures. *--------------------------------------------------------------* H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI') D/copy qrpglesrc,httpapi_h D incoming PR 10I 0 D descriptor 10I 0 value D data 8192A options(*varsize) D datalen 10I 0 value * D rc s 10I 0 D msg s 52A D CRLF C CONST(x'0d25') D data S 1024A D retdata S 32766A D retlen S 10I 0 D nextpos S 10I 0 inz(1) * C *ENTRY PLIST C PARM PR_Return_Code 7 C PARM PR_Error_Msg 52 C PARM PR_Destination 512 C PARM PR_Content_Typ 256 C PARM PR_Send 32766 C PARM PR_Return 32766 /free *inlr = '1'; https_init(*blanks: *ON: *ON: *ON: *ON: *ON); http_debug(*ON); data = %trimr(PR_Send) + CRLF; rc=http_url_post_raw(%trim(PR_Destination) + %trim(PR_Content_Typ) : %addr(data) : %len(%trimr(data)) : 1 : %paddr('INCOMING')) ; if rc <> 1; msg = http_error; dsply msg; return; endif; // convert the data we just received to EBCDIC if retlen > 1; callp http_xlate(retlen: retdata: TO_EBCDIC); PR_Return=%trimr(retdata); endif; // now the returned data is in the 'retdata' string. // run this program in debug and display retdata.... you'll see... return; /end-free P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P* this procedure will receive the raw data received P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P incoming B D incoming PI 10I 0 D descriptor 10I 0 value D data 8192A options(*varsize) D datalen 10I 0 value C* Make sure we don't overflow the string: c eval retlen = (nextpos + datalen) - 1 c if retlen > %size(retdata) c eval datalen=datalen-(retlen-%size(retdata)) c endif C* If there is nothing to write, return THAT... c if datalen < 1 c return 0 c endif C* Here we add any data sent to the end of our 'retdata' string: c eval %subst(retdata: nextpos) = c %subst(data:1:datalen) c eval nextpos = nextpos + datalen c* We always return the amount of data that we wrote. Note C* that if http-api sees that we didn't write as much data as C* it sent us, it'll abort the process with an error message. c return datalen P E
PGM DCL VAR(&CRLF) TYPE(*CHAR) LEN(2) VALUE(X'0D25') DCL VAR(&PR_RETCD) TYPE(*CHAR) LEN(7) VALUE(' ') DCL VAR(&PR_ERROR_M) TYPE(*CHAR) LEN(52) VALUE(' ') DCL VAR(&PR_DESTINA) TYPE(*CHAR) LEN(512) + VALUE('https://10.79.164.62') DCL VAR(&PR_CONTENT) TYPE(*CHAR) LEN(256) + VALUE('text/xml') DCL VAR(&PR_SEND) TYPE(*CHAR) LEN(32766) VALUE(' ') DCL VAR(&PR_RDATA) TYPE(*CHAR) LEN(32766) + VALUE(' ') DCL VAR(&PR_SEND01) TYPE(*CHAR) LEN(100) + VALUE('<s:Envelope + xmlns:s="http://schemas.xmlsoap.org/soap/en+ velope/">') DCL VAR(&PR_SEND02) TYPE(*CHAR) LEN(100) + VALUE(' <s:Body>') DCL VAR(&PR_SEND03) TYPE(*CHAR) LEN(100) + VALUE(' <UpdateStatus + xmlns="RRD.Web.Services.VTServices">') DCL VAR(&PR_SEND04) TYPE(*CHAR) LEN(200) + VALUE(' <contract + xmlns:d4p1="http://schemas.datacontract.org+ /2004/07/RRD.Web.Services.VTServices" + xmlns:i="http://www.w3.org/2001/XMLSchema-i+ nstance">') DCL VAR(&PR_SEND05) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:AdditionalParam1 + i:nil="true" />') DCL VAR(&PR_SEND06) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:AdditionalParam2 + i:nil="true" />') DCL VAR(&PR_SEND07) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:AdditionalParam3 + i:nil="true" />') DCL VAR(&PR_SEND08) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:FileId i:nil="true" />') DCL VAR(&PR_SEND09) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:FileName i:nil="true" />') DCL VAR(&PR_SEND10) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:OrderIdList + xmlns:d5p1="http://schemas.microsoft.com/20+ 03/10/Serialization/Arrays">') DCL VAR(&PR_SEND11) TYPE(*CHAR) LEN(100) + VALUE('<d5p1:string>297108819H</d5p1:string+ >') DCL VAR(&PR_SEND12) TYPE(*CHAR) LEN(100) + VALUE('</d4p1:OrderIdList>') DCL VAR(&PR_SEND13) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:RequestText>Order + Download</d4p1:RequestText>') DCL VAR(&PR_SEND14) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:StatusName>Canceled</d4p1:Stat+ usName>') DCL VAR(&PR_SEND15) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:System>WBS</d4p1:System>') DCL VAR(&PR_SEND16) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:TransactionDateTime>2020-06-03+ T15:18:36.000</d4p1:TransactionDateTime>') DCL VAR(&PR_SEND17) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:System>WBS</d4p1:System>') DCL VAR(&PR_SEND18) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:TransactionDateTime>2020-06-03+ T15:18:36.000</d4p1:TransactionDateTime>') DCL VAR(&PR_SEND19) TYPE(*CHAR) LEN(100) + VALUE('<d4p1:UserId>Jaime + Balsavich</d4p1:UserId>') DCL VAR(&PR_SEND20) TYPE(*CHAR) LEN(100) + VALUE(' </contract>') DCL VAR(&PR_SEND21) TYPE(*CHAR) LEN(100) + VALUE('</UpdateStatus>') DCL VAR(&PR_SEND22) TYPE(*CHAR) LEN(100) + VALUE(' </s:Body>') DCL VAR(&PR_SEND23) TYPE(*CHAR) LEN(100) + VALUE('</s:Envelope>') CHKOBJ OBJ(HTTPAPIR4) OBJTYPE(*SRVPGM) AUT(*OBJEXIST) MONMSG MSGID(CPF9801) EXEC(ADDLIBLE LIB(LIBHTTP) + POSITION(*LAST)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND01) *CAT + &CRLF) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND02) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND03) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND04) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND05) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND06) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND07) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND08) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND09) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND10) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND11) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND12) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND13) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND14) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND15) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND16) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND17) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND18) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND19) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND20) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND21) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND22) *CAT &CRLF)) CHGVAR VAR(&PR_SEND) VALUE(%TRIM(&PR_SEND) *CAT + (%TRIM(&PR_SEND23) *CAT &CRLF)) WODSAUR0 PR_RETURN_(&PR_RETCD) + PR_ERROR_M(&PR_ERROR_M) + PR_DESTINA(&PR_DESTINA) + PR_CONTENT(&PR_CONTENT) PR_SEND(&PR_SEND) + PR_RETURN(&PR_RDATA) ENDPGM
-- _______________________________________________ Ftpapi mailing list Ftpapi@xxxxxxxxxxxxxxxxxxxxxx http://scottklement.com/mailman/listinfo/ftpapi