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

RE: Question Re WEBFORM_SetVar



Bruce, your variable is a varying length field.
 
Varying length data needs to start 2 or 4 bytes after the field start. In pseudo hex, the field looks like this:
X'ffff' + 'your data'
Where ffff represents the length of the field. It can be either 2 bytes or 4 bytes but with correct coding we don't care. So the address you want to pass is the start of the variable plus the length of the length field. Hence, my suggestion that you use:
%addr(xmlData:*data)
This will find the start of "your data" and give that address to the procedure. Then the %len parameter will just be %len(xmlData). No need to add 2 to the address or to trim the data field. 

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Anthony, Bruce
Sent: Tuesday, February 10, 2015 5:23 PM
To: HTTPAPI and FTPAPI Projects
Subject: RE: Question Re WEBFORM_SetVar

Scott,

I guess the best way to explain why I added 2 is to look at the debug before adding 2 and after adding 2.

Here is a snippet of the debug before adding the 2:

HTTPAPI Ver 1.24 released 2012-01-23
OS/400 Ver V6R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_url_post(): 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: CALSB.ORG
DNS server found: 999.16.1.124
DNS server found: 999.15.1.124
https_init(): entered
-------------------------------------------------------------------------------------
Dump of local-side certificate information:

User-Agent: http-api/1.24
Content-Type: application/x-www-form-urlencoded
Content-Length: 563


senddoc(): entered
xmldata=%01%A3%3Ctxn%3E%3Cssl_merchant_id%3E999999%3C%2Fssl_merchant_id%3E%3Cssl_user_id%3Ewebpage%3C%2Fssl_user_id%3E%3Cssl_pin%3E4xxxxx%3C%2Fssl_pin%3E%3Cssl_test_mode%3Efalse%3C%2Fssl_test_mode%3E%3Cssl_transaction_type%3Eccsale%3C%2Fssl_transaction_type%3E%3Cssl_card_number%3E4111111111111111%3C%2Fssl_card_number%3E%3Cssl_exp_date%3E1215%3C%2Fssl_exp_date%3E%3Cssl_amount%3E1.01%3C%2Fssl_amount%3E%3Cssl_cvv2cvc2_indicator%3E1%3C%2Fssl_cvv2cvc2_indicator%3E%3Cssl_cvv2cvc2%3E123%3C%2Fssl_cvv2cvc2%3E%3Cssl_first_name%3ETimothy%3C%2Fssl_first_name%3E%3C%2Ftx
recvresp(): entered

Notice that the xmldata above starts with <txn> and ends with </tx    
The xml is not well formed.

Now look at the snippet after I add 2:

HTTPAPI Ver 1.24 released 2012-01-23
OS/400 Ver V6R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_url_post(): 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: CALSB.ORG
DNS server found: 999.16.1.124
DNS server found: 1999.15.1.124
https_init(): entered

User-Agent: http-api/1.24
Content-Type: application/x-www-form-urlencoded
Content-Length: 567


senddoc(): entered
xmldata=%01%A3%3Ctxn%3E%3Cssl_merchant_id%3E999999%3C%2Fssl_merchant_id%3E%3Cssl_user_id%3Ewebpage%3C%2Fssl_user_id%3E%3Cssl_pin%3E4xxxxx%3C%2Fssl_pin%3E%3Cssl_test_mode%3Efalse%3C%2Fssl_test_mode%3E%3Cssl_transaction_type%3Eccsale%3C%2Fssl_transaction_type%3E%3Cssl_card_number%3E4111111111111111%3C%2Fssl_card_number%3E%3Cssl_exp_date%3E1215%3C%2Fssl_exp_date%3E%3Cssl_amount%3E1.01%3C%2Fssl_amount%3E%3Cssl_cvv2cvc2_indicator%3E1%3C%2Fssl_cvv2cvc2_indicator%3E%3Cssl_cvv2cvc2%3E123%3C%2Fssl_cvv2cvc2%3E%3Cssl_first_name%3ETimothy%3C%2Fssl_first_name%3E%3C%2Ftxn%3E

Notice that the xmldata above starts with <txn> and ends with </txn>   
The xml is now well formed and receives a valid response.  
I obfuscated the merchant ID an pin.



-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Tuesday, February 10, 2015 8:33 AM
To: HTTPAPI and FTPAPI Projects
Subject: Re: Question Re WEBFORM_SetVar

Why are you adding 2 to the length?

On 2/10/2015 10:17 AM, Anthony, Bruce wrote:
> Mike,
>
> Thank you.  I had to make a minor change as follows:
>
> c                   callp     WEBFORM_setPtr(Form: 'xmldata'
> c                                     : %Addr(xmldata)
> c                                     : %len(%trimr(xmldata)) + 2)
>
> The above works great and you made my day!
>
> Thank you,
>
> Bruce
>

-----------------------------------------------------------------------
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
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------