[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
XML Error
Hi,
This is my first time using HTTPAPI for an interface. I am working on
building some prototypes that will allow us to send Credit Card
transactions to a processing company. I have patterned my test
program after the Example 14 source.
However, with my program I am getting a
java.lang.nullpointerException message when I try the post.
In looking at the request XML string there does not appear to be any
errors, (in fact I can copy the xml string and execute a ReST post via
postman and I get back a valid response)
I'm sure I'm just missing something simple, but I can't seem to figure
out what is wrong.
Any assistance or guidance you can provide is much appreciated.
Thanks
Alan Frentz
Here is the program source code......
H DFTACTGRP(*NO) BNDDIR('LIBHTTP/HTTPAPI':'QC2LE') ACTGRP(*NEW)
H Option( *SrcStmt: *NoDebugIO )
H DatFmt(*USA)
H TimFmt(*HMS)
*
* This demonstrates using HTTPAPI's functions to submit an
* xml request to a webpage.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*%* See CMPSRC documentation for explanation of % comments.
*%p DFTACTGRP(*NO) ACTGRP(QILE) +
*%p BndDir(LIBHTTP/HTTPAPI QC2LE SRVDIR)
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
D/copy qrpglesrc,httpapi_h
* ---------------------------------------------
* Procedures
* ---------------------------------------------
D addTag PR 1024A varying
D tag 128A varying const
D text 1024A value
D gsub PR 1024A varying
D inp 1024A varying const
D from 128A varying const
D to 128A varying const
D StartOfElement PR
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D attrs * dim(32767)
D const options(*varsize)
D EndOfElement PR
D UserData * value
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)
* Stand-alone field definitions
D data s 256000 varying
D dataFixed s 256000
D dataLen s 10I 0
D msg s 52A
D nextpos S 10I 0 inz(1)
D ok s 1N
D rc s 10I 0
D reqXML s 4096A varying
D retdata S 32766A
D retlen S 10I 0
D URL s 256A varying
D xmldata s 9000000
d Count s 10I 0
d activity ds qualified
d array dim(100)
d Response 4096A overlay(array:*next)
* Named constants for readability
D TRUE C *On
D FALSE C *Off
D DEBUG_LOG C *On
D CRLF C CONST(x'0D25')
* Test gateway and server (comment this or the live gateway)
D SERVER C
'https://demo.myvirtualmerchant.com/-
D
VirtualMerchantDemo/processxml.do'
D MerchantID C '007994'
D User_ID C 'webpage'
D User_PIN C 'INGKQT'
C/Free
http_debug(DEBUG_LOG);
http_XmlStripCRLF(*ON);
// Initialize request XML with tags which are always sent
reqxml = 'xmldata=' +
'<txn>' +
addTag('ssl_transaction_type' : 'ccgettoken' ) +
addTag('ssl_merchant_id' : MerchantID ) +
addTag('ssl_user_id' : User_ID ) +
addTag('ssl_pin' : User_PIN ) +
addTag('ssl_show_form' : 'false');
// setup cardholder information
reqXML = %Trim(reqXML) +
addTag('ssl_first_name' : 'Mickey Mouse');
reqXML = %Trim(reqXML) +
addTag('ssl_avs_address' : '100 Disney Lane');
reqXML = %Trim(reqXML) +
addTag('ssl_city' : 'DisneyWorld' ) +
addTag('ssl_state' : 'FL' ) +
addTag('ssl_avs_zip' : '12345' );
// tags for the CC number and expiration date
reqXML = %Trim(reqXML) +
addTag('ssl_card_number' : '4111111111111111' ) +
addTag('ssl_exp_date' : '0119' ) +
addTag('ssl_cvv2cvc2_indicator' : '0');
// tags for saving token
reqXML = %Trim(reqXML) + addTag('ssl_get_token' : 'Y');
reqXML = %trim(reqXML) + addTag('ssl_add_token' : 'Y');
// Add in the description
reqXML = %Trim(reqXML)
+ addTag('ssl_description': 'Test get token' );
// send the customer number
reqXML = %Trim(reqXML) +
addTag('ssl_customer_number' : '8888888');
// Now wrap up the XML request
reqXML = %Trim(reqXML) + '</txn>' + CRLF;
// Send POST
clear retdata;
dataLen = %len( %trimr( reqXML ));
dataFixed = %subst( reqXML : 1 : dataLen );
URL = Server;
rc = http_url_post_xml(%trimR(URL)
: %addr(reqXML) + 2
: %len( %trimR( reqXML ))
: %paddr(StartofElement)
: %paddr(EndOfElement)
: *NULL );
if rc <> 1;
msg = http_error;
else;
msg = '';
endif;
// do something with the valid response
*inlr = *on;
/End-free
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P* this procedure formats a XML tag
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P addTag B
D addTag PI 1024A varying
D tag 128A varying const
D text 1024A value
D tagData S 1024A varying
c/Free
// Initialize to trimmed version of data to send
tagData = %trim(text);
// Now escape characters sensitive to XML tags
tagData = gsub( tagData: '&': '&' );
tagData = gsub( tagData: '<': '<' );
tagData = gsub( tagData: '>': '>' );
tagData = gsub( tagData: '"': '"' );
tagData = gsub( tagData: '''':''' );
// Now build up tagged data
tagData = '<' + tag + '>' + tagData + '</' + tag + '>';
tagData = '<' + tag + '>' + tagData + '</' + tag + '>';
return tagData;
/End-free
P E
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P* this procedure performs a global string substitution
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P gsub B
D gsub PI 1024A varying
D inp 1024A varying const
D from 128A varying const
D to 128A varying const
D outText S 1024A varying
D i S 10I 0
D fromLen S 10I 0
D toLen S 10I 0
c/Free
// Initialize output text to input text
outText = inp;
fromLen = %len(from);
toLen = %len(to);
// Now repeatively look for substring to replace
i = %scan( from: outText: 1 );
dow (i > 0);
select;
when i = 1;
outText = to + %subst( outText: fromLen + 1 );
when (i + fromLen) >= %len( outText );
outText = %subst( outText: 1: i - 1 ) + to;
other;
outText = %subst( outText: 1: i - 1 ) + to +
%subst( outText: i + fromLen );
endsl;
i = %scan( from: outText: i + fromLen );
enddo;
return outText;
/End-free
P E
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P* this procedure will be executed at the beginning of each element
P* received back i.e. start of tag
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P StartOfElement B
D StartOfElement PI
D UserData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
if path = 'txn';
count = count + 1;
endif;
// make sure we found at least one transaction
if Count = 0;
count = count + 1;
endif;
/end-free
P E
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P* this procedure will be executed at the beginning of each element
P* received back i.e. start of tag
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P EndOfElement B
D EndOfElement PI
D UserData * value
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)
/free
select;
when path = '/txn';
activity.Response(count) = value;
Other;
activity.Response(count) = value;
endsl;
/end-free
P E
And here is the debug log
HTTPAPI Ver 1.29 released 2015-02-23
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R1M0
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: sullivangift.com
DNS server found: 24.220.0.11
DNS server found: 24.220.0.10
https_init(): entered
QSSLPCL = *TLSV1.2 *TLSV1.1 *TLSV1
SSL version 2 support disabled
SSL version 3 support disabled
Old interface to TLS version 1.0 support enabled
TLS version 1.0 support enabled
TLS version 1.1 support enabled
TLS version 1.2 support enabled
-----------------------------------------------------------------------
--------------
Dump of local-side certificate information:
-----------------------------------------------------------------------
--------------
Nagle's algorithm (TCP_NODELAY) disabled.
SNI hostname set to: demo.myvirtualmerchant.com
Serial Number: 3F:94:3B:4A:01:B3:B4:49:4A:30:54:38:FA:46:BB:53
Common Name: demo.myvirtualmerchant.com
Country: US
State/Province: Georgia
Locality: Atlanta
Org Unit: Elavon Inc
Org: SYSTEMS
Issuer CN: Symantec Class 3 Secure Server CA - G4
Issuer Country: US
Issuer Org: Symantec Corporation
Issuer Org Unit: Symantec Trust Network
Version: 3
not before: 20160113180000
Unknown Field: 18:00:00 13-01-2016
not after: 20170114175959
Unknown Field: 17:59:59 14-01-2017
pub key alg: 1.2.840.113549.1.1.11
Protocol Used: TLS Version 1.2
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /VirtualMerchantDemo/processxml.do HTTP/1.1
Host: demo.myvirtualmerchant.com
User-Agent: http-api/1.29
Content-Type: text/xml
Content-Length: 693
senddoc(): entered
xmldata=<txn><ssl_transaction_type>ccgettoken</ssl_transaction_type><ss
l_merchant_id>007994</ssl_merchant_id><ssl_user_id>webpage</ssl_user_id
><ssl_pin>INGKQT</ssl_pin><ssl_show_form>false</ssl_show_form><ssl_firs
t_name>Mickey Mouse</ssl_first_name><ssl_avs_address>100 Disney
Lane</ssl_avs_address><ssl_city>DisneyWorld</ssl_city><ssl_state>FL</ss
l_state><ssl_avs_zip>12345</ssl_avs_zip><ssl_card_number>41111111111111
11</ssl_card_number><ssl_exp_date>0119</ssl_exp_date><ssl_cvv2cvc2_indi
cator>0</ssl_cvv2cvc2_indicator><ssl_get_token>Y</ssl_get_token><ssl_ad
d_token>Y</ssl_add_token><ssl_description>Test get
token</ssl_description><ssl_customer_number>8888888</ssl_customer_numbe
r></txn>
recvresp(): entered
HTTP/1.1 200 OK
Date: Mon, 28 Mar 2016 13:11:32 GMT
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Expires: 0
Content-Length: 151
Set-Cookie: JSESSIONID=0000M9iUUPFBVgFLHsdRzwn--xg:14j4qkv92; HTTPOnly;
Path=/; Secure
Content-Type: text/xml;charset=ISO-8859-1
Content-Language: en-US
X-Frame-Options: SAMEORIGIN
SetError() #13: HTTP/1.1 200 OK
recvresp(): end with 200
recvdoc parms: identity 151
header_load_cookies() entered
cookie_parse() entered
cookie = JSESSIONID=0000M9iUUPFBVgFLHsdRzwn--xg:14j4qkv92; HTTPOnly;
Path=/; Secure
cookie attr JSESSIONID=0000M9iUUPFBVgFLHsdRzwn--xg:14j4qkv92
cookie attr HTTPOnly=
cookie attr Path=/
cookie attr Secure=
recvdoc(): entered
SetError() #0:
<txn>
<errorCode>UNKNOWN</errorCode>
<errorName>UNKNOWN ERROR</errorName>
<errorMessage>java.lang.NullPointerException</errorMessage>
</txn>
http_close(): entered
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------