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

Re: [Ftpapi] (HTTPAPI) help sending xml file and receiving completed message



HI Scott,

Thanks for the prompt response, appreciated.

The URL-encoding (application/x-www-form-urlencoded) is an instruction from TNT - ExpressConnect integration doco seen below and included in the requirement is an example of the _javascript_ instructions/code that can be used :

Open a socket connection to the following address and port number.
Domain Name iConnection.tnt.com
IP Address 164.39.122.33
Port 81
Send the following lines, data between quotes. N.B. 1 blank line should be sent after Content-length line.
"POST ShipperGate2.asp HTTP/1.0"
"Accept: */*"
"User-Agent: ShipperGate_socket/1.0";
"Content-type: application/x-www-form-urlencoded";
"Content-length: X"; (replace X with the length of data plus 7 for “xml_in=”)
""
"xml_in=XML document" (this is the content of message)
XML document is the XML corresponding to the specified format (see later section).
Once the above data has been sent, read from the socket until no more data is available. The data returned will consist of some header information followed by a blank line, and then the shipping return code. This unique code is your key with which you can retrieve the various XML documents that your shipping request has produced.
The return string will look like this: COMPLETED:nnnnnnnn
where nnnnnnn is a unique number.


 
_javascript_ that performs the full five-call ‘conversation’ with the TNT server, sending in the returned access code to retrieve the separate XML documents.
<%@ Language=JScript %>
<%
function SendXml(xml_in) {
// Send XML to TNT gateway
httpOb.Open("POST", "http:// ‘iconnection.tnt.com :81/shippergate2.asp", false);
httpOb.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
httpOb.Send("xml_in="+escape(xml_in));
// Retrieve response from TNT Gateway
var HttpResult = httpOb.responseText;
return(HttpResult);
}
var xml_in = Request.Form("xml_in")
// Create instance of Microsoft XML Http Protocol object
var httpOb = Server.CreateObject("Microsoft.XMLHTTP");
// Retrieve access code from TNT Gateway
var AccessCode=SendXml(xml_in);
AccessCode=AccessCode.substring(9);

Having reviewed my colleague's SSIS method of sending the xml data to TNT, the only difference we could find in the code is that he includes a translate to UTF-8, so I changed the content type to a "text/xml; encoding=utf-8" but got the exact same results. The only other difference was that he is sending the data from a PC, and included in the TNT ExpressConnect integration doco is a section on the security/connection requirements and need for having a compatibility between the browser certificate and the TNT certificate (details below) and I was wondering if we may be missing something for the AS400 to be able to emulate a valid browser/certificate for the connection/handshake that is causing the error even before it proceeds to processing the XML data that is sent? If so how would we tell HTTPAPI which certificate to use as part of the POST?

 8. Security/connectivity requirements
The SSL site certificate for https://express.tnt.com will expire on 8th Oct 2012 this will also affect Express Connect. Currently our root certificate, against which the site certificate is validated, uses 1024-bit RSA encryption but this level of encryption is being replaced with a new 2048-bit minimum level of encryption. When renewing our site certificate, our certificate authority, VeriSign, will sign the certificate with their new 2048-bit RSA public root certificate. To operate with our 2048-bit site certificate you must be running a 2048-bit root certificate on your browser. If your browser encryption certificate does not match TNT’s root encryption certificate, problems will result and SSL errors may occur.
Q1. How does the new SSL root certificate get provided?
This 2048-bit RSA public root certificate is something that the operating system providers, such as Microsoft or Apple, provide as part of their operating system software. The certificates are updated with the regular specific browser updates and operating system service pack updates. Internet Explorer v7 and v8 come with the new certificate as well as Windows Vista and Windows 7. Windows XP running Service Pack 3 also loads the new 2048- bit root certificate. The root certificate can also be downloaded from the web - see Q6 below.


thanx again for all your help.

Peter Moore
Just Group Ltd
658 Church St, Richmond, VIC 3121 Australia
phone: +61 3 9420 0634
email: peter.moore@xxxxxxxxxx
www.justgroup.com.au




Scott Klement <sk@xxxxxxxxxxxxxxxx>
Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

03/04/2017 08:48 PM

Please respond to
FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

To
FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
cc
Subject
Re: [Ftpapi] (HTTPAPI) help sending xml file and receiving completed message





Hello Peter,

Can you explain why you are telling it that your data is in the format of an HTML form that has been URL-encoded?  (application/x-www-form-urlencoded). The data that you're sending does not appear to conform to the format of a URL encoded form, it appears that you are simply sending an XML document as-is with no additional encoding.

The error message "bad request / invalid url" is coming from the web service, not from HTTPAPI.  It could mean many different things.  So that is not very helpful to me -- it might be helpful to the people who provide the service? 

But, I would start by looking at their documentation (and/or the working example that your colleague has) and see exactly how they expect the document to be sent.  Once we understand what they are expecting, we can advise you on how to make HTTPAPI work that way.

-SK


On 4/3/17 2:26 AM, Peter.Moore@xxxxxxxxxx wrote:
Hi All,

I am new to HTTPAPI, so please forgive my ignorance/lack of knowlege. I need to send an xml data via a secure url to TNT in the UK and once they have received the data and verified the content, their system will return a character string with a 'COMPLETExxxxxxx' message. Now I have written a program utilising the code below, but the only response I get is; " <h1>Bad Request (Invalid URL)</h1>  " Now my colleague has successfully managed to manually send the same xml data to the same url/port etc. and receive the correct response using SSIS. Any advice/help with what I may be doing wrong or what I may be missing would be greatly appreciated.


My code:


https_strict(*ON);      
http_use_cookies(*OFF);  

http_debug(*on: '/tmp/whm0491-debug.txt');                  

                                                           
                callp     http_long_parseURL(#url          
                                            : service      
                                            : userid        

                                            : pass          

                                            : host          

                                            : port          

                                            : path );      
 host=%xlate(lo:up:host);                                  
                                                           
                callp     http_xproc( HTTP_POINT_CERT_VAL  
                                    : %paddr(cert_val) );  
   rc = http_url_post_stmf( #url                                        
                          : #fromPath                                    

                          : #resultPath                                  

                          : #TIMEOUT                                    
                          : 'ShipperGate_socket/1.0'                    
                          : 'application/x-www-form-urlencoded' );      
                                                                         

 if (rc <> 1);                                                                                                          
    #msg = http_error();                                                
endif;

     

The Debug log:


 ************Beginning of data**************  

HTTPAPI Ver 1.33 released 2016-12-06                                              

NTLM Ver 1.4.0 released 2014-12-22                                                

OS/400 Ver V6R1M0                                                                
                                                                                 
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0          
http_long_ParseURL(): 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                                                    
DNS resolver retrans: 2                                                          
DNS resolver retry  : 2                                                          
DNS resolver options: x'00000136'                                                
DNS default domain: justgroup.internal                                            

DNS server found: 10.0.0.21                                                      
DNS server found: 10.0.1.21

https_init(): entered                                        
QSSLPCL = *OPSYS                                              

SSL version 2 support disabled                                

SSL version 3 support disabled                                

Old interface to TLS version 1.0 support enabled              

Support for TLS 1.0 unavailable.                              

Support for TLS 1.1 unavailable.                              

Support for TLS 1.2 unavailable.                              

--------------------------------------------------------------

Dump of local-side certificate information:                  
--------------------------------------------------------------

Nagle's algorithm (TCP_NODELAY) disabled.                    
(GSKit) Identifier value is not valid.                        

ssl_error(701): (GSKit) Identifier value is not valid.        

SNI hostname error: (GSKit) Identifier value is not valid.    

NOTE: SNI errors are not usually fatal.                      
--------------------------------------------------------------

Dump of server-side certificate information:                  

------------------------------------------------------------------

Cert Validation Code = 0                                          

-----BEGIN CERTIFICATE-----                                      
MIIGFjCCBP6gAwIBAgIQQGMG281+fMYQYk2cCN1IYjANBgkqhkiG9w0BAQsFADB+  

MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd  

BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxLzAtBgNVBAMTJlN5bWFudGVj  

IENsYXNzIDMgU2VjdXJlIFNlcnZlciBDQSAtIEc0MB4XDTE2MTIwOTAwMDAwMFoX  

DTE4MDExNjIzNTk1OVowgZwxCzAJBgNVBAYTAkdCMRUwEwYDVQQIDAxXYXJ3aWNr  

c2hpcmUxEzARBgNVBAcMCkF0aGVyc3RvbmUxKTAnBgNVBAoMIFROVCBFeHByZXNz  

IFdvcmxkd2lkZSBVSyBMaW1pdGVkMRgwFgYDVQQLDA9UTlQgRXhwcmVzcyBJQ1Mx  

HDAaBgNVBAMME2ljb25uZWN0aW9uLnRudC5jb20wggEiMA0GCSqGSIb3DQEBAQUA  

A4IBDwAwggEKAoIBAQDZWHcuQAcmuSh/NFEPwMGKxChpugCBvZUagc1Qm7oawRMZ  

aeelxZMTsApzQ09fkShHVs2l0Ti/P4ppksKP3D3LKyv7koxajre3945JLyVTaN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BdXZ02/Ot19ph4wDQYJKoZIhvcN
AQELBQADggEBAE7/f2UB2F+HflK1VEHx6zJYc8AUo4sAJiVAu+CxGvv7rV3fwWzt
bDuyctyIMFCPlZo0PVI1tJdhFKrJjReplFZy4Mb3pnymaQ3C886w0JJBLfv2n23E
TI2xThbVnalrUzBkQkyVC3p2KhOQ/wdGYwWrAa8slClOUCPC6gv6RcOBUtH5chmG
No9EPTkFtFPoXSapfe/jlVXupU/KBeUr3PQNW3O9OfuTnLByEy8XWOs0ik7IQXqw
9/d2CkrRjf21DL8kXbWr28EK++eF8VA8BSZjOCB/0TTD6Y8jr19Ni503Uo2kksB6
Xt968zFYfLyT+8aVjGt8Tm+HFxUZi17bI2M=                            
-----END CERTIFICATE-----                                    
Serial Number: 40:63:06:DB:CD:7E:7C:C6:10:62:4D:9C:08:DD:48:62

Common Name: iconnection.tnt.com                              

Country: GB                                                  
State/Province: Warwickshire                                  

Locality: Atherstone                                          

Org Unit: TNT Express Worldwide UK Limited                    

Org: TNT Express ICS                                          

Issuer CN: Symantec Class 3 Secure Server CA - G4            
Issuer Country: US                                            

Issuer Org: Symantec Corporation                              

Issuer Org Unit: Symantec Trust Network                      
Version: 03                                                  
not before: 20161209110000                                    

not after: 20180117105959                                    
pub key alg: 1.2.840.113549.1.1.11                            

                                                             
Protocol Used: TLS Version 1.0  

http_persist_post(): entered                                                            

http_persist_req(POST) entered.                                                        
http_long_ParseURL(): entered                                                          
http_long_ParseURL(): entered                                                          
do_oper(POST): entered                                                                  

POST ShipperGate2.asp HTTP/1.1                                                        
Accept: */*                                                                            
User-Agent: ShipperGate_socket/1.0                                                      

Content-Type: application/x-www-form-urlencoded                                        
Content-Length: 26322                                                                  
                                                                                       
sendraw(): entered                                                                      

xml_in=<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>                      

<!DOCTYPE ESHIPPER SYSTEM '
http://iconnection.tnt.com:81/ShipperDTD2.0/EshipperIN2.dtd'>
<ESHIPPER>                                                                              

 <LOGIN>                                                                                

  <COMPANY>Sm********</COMPANY>

  <PASSWORD>TNT*****</PASSWORD>                      

  <APPID>EC</APPID>                                  

  <APPVERSION>2.2</APPVERSION>                      
 </LOGIN>                                            

 <CONSIGNMENTBATCH>                                  

  <SENDER>                                          
   <COMPANYNAME>Smiggle UK Limited</COMPANYNAME>    
   <STREETADDRESS1>c/o ACS</STREETADDRESS1>          

   <STREETADDRESS2>Thurrock Park Way</STREETADDRESS2>

   <STREETADDRESS3>Tilbury RM18 7HZ</STREETADDRESS3>
   <CITY>Tilbury</CITY>                              

   <PROVINCE>.</PROVINCE>                            

   <POSTCODE>RM18 7HZ</POSTCODE>                    
   <COUNTRY>GB</COUNTRY>                            
   <ACCOUNT>0015*****</ACCOUNT>                      

   <CONTACTNAME>Shane Smith</CONTACTNAME>            

   <CONTACTDIALCODE>00441</CONTACTDIALCODE>          

   <CONTACTTELEPHONE>375400000</CONTACTTELEPHONE>
<CONTACTEMAIL></CONTACTEMAIL>                      
<COLLECTION>                                        

<COLLECTIONADDRESS>                                
 <COMPANYNAME>Smiggle UK Limited</COMPANYNAME>      

 <STREETADDRESS1>c/o ACS</STREETADDRESS1>          
 <STREETADDRESS2>Thurrock Park Way</STREETADDRESS2>
 <STREETADDRESS3>Tilbury RM18 7HZ</STREETADDRESS3>  

 <CITY>Tilbury</CITY>                              
 <PROVINCE>.</PROVINCE>                            
 <POSTCODE>RM18 7HZ</POSTCODE>                      

 <COUNTRY>GB</COUNTRY>                              

 <CONTACTNAME>Shane Smith</CONTACTNAME>            
 <CONTACTDIALCODE>00441</CONTACTDIALCODE>          
 <CONTACTTELEPHONE>375******</CONTACTTELEPHONE>    
</COLLECTIONADDRESS>                                

<SHIPDATE>03/04/2017</SHIPDATE>                    
<PREFCOLLECTTIME>                                  
 <FROM>1400</FROM>        
   <TO>1700</TO>                                                  

  </PREFCOLLECTTIME>                                              

  <ALTCOLLECTTIME>                                                

  <FROM/>                                                        
  <TO/>                                                          
  </ALTCOLLECTTIME>                                              
  <COLLINSTRUCTIONS>Collection from Warehouse</COLLINSTRUCTIONS>  

  </COLLECTION>                                                  
 </SENDER>                                                        

 <CONSIGNMENT>                                                    

  <CONREF>50042196</CONREF>                                      
  <DETAILS>                                                      
   <RECEIVER>                                                    
    <COMPANYNAME>Smiggle</COMPANYNAME>                            

    <STREETADDRESS1>UNIT 7, LEVEL 3, DUNDRUM</STREETADDRESS1>    
    <STREETADDRESS2>TOWN CENTRE, SANDYFORD RD</STREETADDRESS2>    

    <STREETADDRESS3> </STREETADDRESS3>                            

    <CITY>DUBLIN 16</CITY>                                        

   <PROVINCE>IE</PROVINCE>                                  
  <POSTCODE/>                                              
  <COUNTRY>IE</COUNTRY>                                    
  <VAT/>                                                    

  <CONTACTNAME>Store Manager</CONTACTNAME>                  

  <CONTACTDIALCODE>001</CONTACTDIALCODE>                    

  <CONTACTTELEPHONE>000000001</CONTACTTELEPHONE>            

  <CONTACTEMAIL/>                                          
 </RECEIVER>                                                

 <DELIVERY>                                                
  <COMPANYNAME>Smiggle</COMPANYNAME>                        

  <STREETADDRESS1>UNIT 7, LEVEL 3, DUNDRUM</STREETADDRESS1>
  <STREETADDRESS2>TOWN CENTRE, SANDYFORD RD</STREETADDRESS2>

  <STREETADDRESS3> </STREETADDRESS3>                        

  <CITY>DUBLIN 16</CITY>                                    

  <PROVINCE>IE</PROVINCE>                                  
  <POSTCODE/>                                              
  <COUNTRY>IE</COUNTRY>                                                              
  <VAT/>                                        
  <CONTACTNAME>Store Manager</CONTACTNAME>      
  <CONTACTDIALCODE>001</CONTACTDIALCODE>        
  <CONTACTTELEPHONE>000000001</CONTACTTELEPHONE>
  <CONTACTEMAIL/>                                

 </DELIVERY>                                    
 <CONNUMBER></CONNUMBER>                        
 <CUSTOMERREF>0_0</CUSTOMERREF>                  

 <CONTYPE>N</CONTYPE>                            

 <PAYMENTIND>S</PAYMENTIND>                      

 <ITEMS>1</ITEMS>                                

 <TOTALWEIGHT>10.000</TOTALWEIGHT>              
 <TOTALVOLUME>.062</TOTALVOLUME>                
 <CURRENCY/>                                    
 <GOODSVALUE/>                                  
 <INSURANCEVALUE/>                              
 <INSURANCECURRENCY/>                            

 <SERVICE>15N</SERVICE>                                                

    <OPTION/>                                        

    <DESCRIPTION>Box No 50042196</DESCRIPTION>      
    <DELIVERYINST>Deliver to Store</DELIVERYINST>    

    <CUSTOMCONTROLIN/>                              
    <HAZARDOUS>N</HAZARDOUS>                        
    <UNNUMBER/>                                      

    <PACKAGE>                                        

     <ITEMS>1</ITEMS>                                

     <DESCRIPTION>Box No 50042196</DESCRIPTION>      

     <LENGTH>.55</LENGTH>                            

     <HEIGHT>.39</HEIGHT>                            

     <WIDTH>.29</WIDTH>                              

     <WEIGHT>10.000</WEIGHT>                        
    </PACKAGE>                                      
   </DETAILS>                                        

  </CONSIGNMENT>                                    
 </CONSIGNMENTBATCH>      

 <ACTIVITY>                          

  <CREATE>                          
   <CONREF>50042196</CONREF>        
  </CREATE>                          

  <RATE/>                            

  <BOOK/>                            

  <SHIP/>                            

  <PRINT/>                          
  <SHOW_GROUPCODE/>                  

 </ACTIVITY>                        
</ESHIPPER>                          

                                     

recvresp(): entered                  

HTTP/1.1 400 Bad Request            
Content-Type: text/html              

Date: Mon, 03 Apr 2017 06:29:25 GMT  

Connection: close                    

Content-Length: 34        
         
SetError() #13: HTTP/1.1 400 Bad Request    
recvresp(): end with 400                    
recvdoc parms: identity 34                  
recvdoc(): entered                          
SetError() #0:                              
recvdoc(): Receiving 34 bytes.              
<h1>Bad Request (Invalid URL)</h1>          
SetError() #13: HTTP/1.1 400 Bad Request    
http_close(): entered                        

 ************End of Data********************                                                                                  

thanx

Peter Moore
Just Group Ltd
658 Church St, Richmond, VIC 3121 Australia
phone: +61 3 9420 0634
email:
peter.moore@xxxxxxxxxx
www.justgroup.com.au


______________________________________________________________________
"This communication is confidential and is intended only for the person(s) to whom it is addressed. If you receive it in error please inform sender as soon as possible and destroy all forms of it that you control. The information may not necessarily be authorised by Just Group Ltd or any of its subsidiary companies. Such should not be taken as a communication of the Just Group unless from a responsible and authorised executive acting in their official capacity. Should this e-mail contain any inappropriate material please inform the HR Division of the Just Group Ltd (03) 9420 0200."
______________________________________________________________________




______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit
http://www.symanteccloud.com
______________________________________________________________________
--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi


______________________________________________________________________
"This communication is confidential and is intended only for the person(s) to whom it is addressed. If you receive it in error please inform sender as soon as possible and destroy all forms of it that you control. The information may not necessarily be authorised by Just Group Ltd or any of its subsidiary companies. Such should not be taken as a communication of the Just Group unless from a responsible and authorised executive acting in their official capacity. Should this e-mail contain any inappropriate material please inform the HR Division of the Just Group Ltd (03) 9420 0200."
______________________________________________________________________

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi