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

RE: Post to aspx (This time w files attached)



Thanks for your thorough response.  You hit all the nails on the head:  I am building a pipe-delimited file, writing to a physical file, converting with a CPYTOSTMF operation, and calling http_url_post to send it.  You are also correct about the incorrect use of (x'0a') - I have changed it to x'25'.  I tried your http-url-post-stmf example but kept getting 'The type of the parameter specified for the call does not match the prototype', so I backed off that change for now.   (But I will definitely try sending without creating a file next time - that is obviously more efficient.)   
  In answer to your point #3:  I am getting a zero-length file but as another of your mailing list subscribers pointed out, that empty file may be getting created on my side in anticipation of the returned data.  I thought I was expecting text data in return but I need to verify with the author of the aspx program.  Back to my side, after the post rc is equal to '1'.  
I am attaching the streamfile I create for the post along with a print of the httpapi_debug listing.  At this point in my http education I am not understanding what I am seeing on the debug listing.  

Julie Nichols| Summit Group
Programmer/Analyst
1100 Circle 75 Pkwy., Suite 1200 | Atlanta, GA 30339-3081
Direct line: 770-303-0432 | julie.nichols@xxxxxxxxxxxx
Fax: 770-303-0408


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, May 02, 2012 5:07 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: Post to aspx

Hiya Julie,

Thanks for all the info (including the Word doc with code snippets and 
screenshots.)  And thanks for joining the mailing list!  That helps me a 
lot!

Let me see if I understand your situation correctly:

1) You are building a pipe-delimited file in your RPG program.
2) You are writing that file to a physical file.
3) You are somehow (not shown in the sample) converting that physical 
file to a stream file.
4) You are calling http_url_post_stmf() to send it.

There are things you are doing in this process that I don't understand:

1) You are adding an ASCII LF character (x'0a') between each record of 
the data before writing it to the PF.  Although the LF is in ASCII, the 
remainder of your record is in EBCDIC.  Presumably your stream file 
conversion program is taking care of an EBCDIC->ASCII translation.  Does 
it know that your LF characters are already ASCII and shouldn't be 
translated a second time?

Usually when I see folks use a PF as an intermediary, they simply write 
one record per line of the text file, and let the conversion program 
take care of inserting the linefeeds to denote where the records end. 
It's strange to see that done manually.  But, even if you do want to do 
it manually (like you would if writing to the IFS directly) I would've 
expected you to use x'25', the EBCDIC linefeed character.  So your 
situation surprised me.  But, perhaps you're handling that in the 
"conversion" program, so I'm worried about nothing :-)


2) I don't know if you need your data to also be stored in a file, but 
if not, I wanted to let you know that you can send the string from your 
program directly with HTTPAPI.  For example:

Tlin = 'T|0|' + XFaddz + '|US|' + XSmth;
Vlin = 'V|' + WKvend + '|' + XTaddz + '|US';
Ilin = 'I|' + Wkvend + '|' + IBlitm +'|' + Xlngt + '|' + Xwdth +
     '|' + Xhgt + '|' + Xwgt + '|' + XDqty + '|' + Xeprc + '|pan';
Clin = 'C|1';
Data = Tlin + LF + Vlin + LF + Ilin + LF + Clin + LF;


filenm = '/ShippingCosts/httpShipRsp.txt';

rc=http_url_post_stmf('https://services.pm.summitmg.com:8443' +
                       '/FreightCosting/ProcessFreight.aspx'
                      : %addr(data:*data)
                      : %len(data)
                      : filenm
                      : HTTP_TIMEOUT
                      : HTTP_USERAGENT
                      : 'text/plain' );

(NOTE: You may have to change 'text/plain' to something else... I don't 
know what MIME type corresponds to the format you're sending, as I 
haven't seen that format before.)

This does the same thing as the post_stmf example you posted, but 
without the need for the PF or the STMF.

If you do it this way, I'd definitely change the definition of LF from 
to x'25', which is the EBCDIC equivalent of x'0a'.


3) You say you're getting a zero-length file. I'm unfamiliar with your 
application, so I don't know what sort of file you're expecting?  My 
question is:  Is HTTPAPI reporting an error?  Do you get rc=1, or 
something else?  Have you called http_error() to get an error message?


4) Have you tried creating a debug/trace file and looking at what gets 
sent/received?  If you don't know how to do that, there's a description 
under the heading "Creating Debug Logs" on the following page:

http://www.scottklement.com/httpapi/beta


Hope that helps provide some insight.



On 5/2/2012 2:51 PM, Nichols, Julie wrote:
>
>     I am trying to post package data to an aspx program and receive a
>     response (with shipping costs, etc) via a text file.  I am receiving a
>     file, but the file is empty.  Windows explorer shows the file with a
>     size but looking at the files' properties shows a 0 file size.  Am I
>     missing something major?  We have your HTTPAPI samples and I have
>     looked through them (albeit - with less than full understanding).  Can
>     one of the samples provide some illumination?
>
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------

HTTPAPI Ver 1.23 released 2008-04-24
OS/400 Ver V7R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
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: SUMMIT
DNS server found: 10.100.1.206
DNS server found: 10.110.1.132
DNS server found: 10.100.1.220
https_init(): entered
-------------------------------------------------------------------------------------
Dump of local-side certificate information:
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Dump of server-side certificate information:
-------------------------------------------------------------------------------------
Cert Validation Code = 6000
-----BEGIN CERTIFICATE-----
MIIE+TCCA+GgAwIBAgIDRE2+MA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
UzEQMA4GA1UECBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UE
ChMRR29EYWRkeS5jb20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0
ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2Vj
dXJlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzAe
Fw0wODA0MTExNTMwMTNaFw0xMzA0MTExNTMwMTNaMFsxGjAYBgNVBAoTESoucG0u
c3VtbWl0bWcuY29tMSEwHwYDVQQLExhEb21haW4gQ29udHJvbCBWYWxpZGF0ZWQx
GjAYBgNVBAMTESoucG0uc3VtbWl0bWcuY29tMIGfMA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VGuBXPdqF5OWWqc2iYlXPx4ltiSMNLwUIpjmHxPdCEKzoU/XubcfBoLQVKgNyq
qX2uajxTJ7BZIQ5ozWF5dWY1EPXThymQJfQVU+5mSU1UWZuVh+NALRr8uFK54iIK
Slsr9fKS3iznEZGxkMo1ELD3X/uj02PZJXAyeOI=
-----END CERTIFICATE-----
Serial Number: 44:4D:BE
Common Name: *.pm.summitmg.com
Org Unit: *.pm.summitmg.com
Org: Domain Control Validated
Issuer CN: Go Daddy Secure Certification Authority
Issuer Country: US
Issuer State/Province: Arizona
Issuer Locality: Scottsdale
Issuer Org: GoDaddy.com, Inc.
Issuer Org Unit: http://certificates.godaddy.com/repository
Version: 03
not before: 20080411113013
not after: 20130411113013
pub key alg: 1.2.840.113549.1.1.5

Protocol Used: TLS Version 1
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /FreightCosting/ProcessFreight.aspx HTTP/1.1
Host: services.pm.summitmg.com:8443
User-Agent: http-api/1.23
Content-Type: text/xml
Expect: 100-continue
Content-Length: 1169


recvresp(): entered
HTTP/1.1 100 Continue


SetError() #13: HTTP/1.1 100 Continue
sendraw(): entered
ãOðOóððøð@@@@@@@OäâOñðð
åOôðôñð@@@Oóðóóù@@@@@@@Oäâ
ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???
ÃOñ@
%ãOðOóððøð@@@@@@@OäâOñðð
åOôðôñð@@@Oóðóóù@@@@@@@Oäâ
ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???
ÃOñ@
%ãOðOóððøð@@@@@@@OäâOñðð
åOôðôñð@@@Oóðóóù@@@@@@@Oäâ
ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???
ÃOñ@
%ãOðOóððøð@@@@@@@OäâOñðð
åOôðôñð@@@Oóðóóù@@@@@@@Oäâ
ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???
ÃOñ@
%ãOðOóððøð@@@@@@@OäâOñðð
åOôðôñð@@@Oóðóóù@@@@@@@Oäâ
ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???
ÃOñ@
%ãOðOóððøð@@@@@@@OäâOñðð%åOôðôñð@@@Oóðóóù@@@@@@@Oäâ%ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???%ÃOñ@%%ãOðOóððøð@@@@@@@OäâOñðð%åOôðôñð@@@Oóðóóù@@@@@@@Oäâ%ÉOôðôñð@@@Oñøðñò÷@@@@@@@@@@@@@@@@@@@O@@@@ðððððððùO@@@@ðððððððôO@@@@ðððððððóOððððððððKòòððOðððñõOðððòô÷õððO???%ÃOñ@%%
recvresp(): entered
HTTP/1.1 200 OK
Date: Thu, 03 May 2012 14:42:16 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 1288


SetError() #13: HTTP/1.1 200 OK
recvdoc parms: identity 1288
header_load_cookies() entered
recvdoc(): entered
SetError() #0:


<!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";>
<head><title>

</title>
   <style type="text/css">
      p
      {
         line-height: 1em;
         margin: 0;
      }
   </style>
</head>
<body>
   <form method="post" action="ProcessFreight.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZOR5MvzEmLImIorEOQpVvG+9HQ+ugWKHaJuloRCCxk2c" />

   <div>
      <h2>
         Usage:</h2>
      <div>
         <pre>
            Example code go
         </pre>
      </div>
      <h3>
         Input</h3>
      <p>
         {1} T|IsResidential|ZipCode|Country|Methods</p>
      <p>
         {1+} V|VendorId|ZipCode|Country</p>
      <p>
         {1+} I|vendorId|itemId|Length|width|height|weight|quantity|value|passthru|ship-alone(Y|N)</p>
      <p>
         {0+} C|IsVerbose(0|1)</p>
      <br />
      <br />
      <h3>
         Output</h3>
      <p>
         {0+} P|VendorId|Package #|Weight|Value|Err#|ErrText - Only if IsVerbose=1</p>
      <p>
         {1+} S|VendorId|Method|Cost|Err#|ErrText</p>
      <br />
      <br />
   </div>
   </form>
</body>
</html>

http_close(): entered
T|0|30080       |US|100?V|40410   |30339       |US?I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan?C|1 ?
T|0|30080       |US|100?V|40410   |30339       |US?I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan?C|1 ?
T|0|30080       |US|100?V|40410   |30339       |US?I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan?C|1 ?
T|0|30080       |US|100?V|40410   |30339       |US?I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan?C|1 ?
T|0|30080       |US|100?V|40410   |30339       |US?I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan?C|1 ?
T|0|30080       |US|100
V|40410   |30339       |US
I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan
C|1 

T|0|30080       |US|100
V|40410   |30339       |US
I|40410   |180127                   |    00000009|    00000004|    00000003|00000000.2200|00015|000247500|pan
C|1 

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------