Can someone post an example (or two) of how you would send XML via an HTTPS Post, either using http_post_page2() or HTTP_POST. This needs to take place from an Alpha web app.
Announcement
Collapse
The Alpha Software Forum Participation Guidelines
The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
Moderators may also rename posts and threads if they are too generic or do not property reflect the content.
Moderators may move threads if they have been posted in the incorrect forum.
Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.
The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.
Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.
Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.
Bonus TIPS for Successful Posting
Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.
When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.
The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.
When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.
A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.
If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.
When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.
Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
- Be professional in your conduct
- Be kind to others
- Be constructive when giving feedback
- Be open to new ideas and suggestions
- Stay on topic
Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
- Spam.
- Vulgar language.
- Quotes from private conversations without permission, including pricing and other sales related discussions.
- Personal attacks, insults, or subtle put-downs.
- Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
- Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
- Sexually explicit or violent material, links, or language.
- Pirated, hacked, or copyright-infringing material.
- Encouraging of others to engage in the above behaviors.
If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
- Remove the Post or Thread - the content is removed from the forum.
- Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
- Temporarily Ban the User - user is banned from forum for a period of time.
- Permanently Ban the User - user is permanently banned from the forum.
Moderators may also rename posts and threads if they are too generic or do not property reflect the content.
Moderators may move threads if they have been posted in the incorrect forum.
Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.
The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.
Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.
Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.
Bonus TIPS for Successful Posting
Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.
When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.
The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.
When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.
A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.
If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.
When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.
Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less
http_post_page2() or HTTP_POST
Collapse
X
-
Re: http_post_page2() or HTTP_POST
http_post_page2() uses a Microsoft ActiveX control that is not server-safe. Kevin Tucker posted a recent thread where he has the code to use Microsoft's server-safe ActiveX control.
You can't use http_post() directly because of the same issue that Kevin originally posted about - it uses the application/x-www-form-urlencoded content type. However you can use the lower-level http_fetch() and set the content type as desired:
Code:dim req as p dim resp as p req.host = "<your server>" req.page = "<your page>" req.method = "POST" req.body = "<your XML here>" req.header = "Content-Type: text/xml" resp = http_fetch(req)
Lenny Forziati
Vice President, Internet Products and Technical Services
Alpha Software Corporation
-
Re: http_post_page2() or HTTP_POST
Thank you Lenny,
1. req.page = <Page> means what?
2. Enterprise Appliciation Server right, not the client Alpha software.
3. Also, is it possible for me to just skip any xbasic function and use this format on an A5W page to send.
<form action="<mypage>" method=post>
<input type=hidden name="Lname" value = "Wood"
etc.
Comment
-
Re: http_post_page2() or HTTP_POST
Originally posted by Steve Wood View PostThank you Lenny,
1. req.page = <Page> means what?
Originally posted by Steve Wood View Post2. Enterprise Appliciation Server right, not the client Alpha software.
Originally posted by Steve Wood View Post3. Also, is it possible for me to just skip any xbasic function and use this format on an A5W page to send.
<form action="<mypage>" method=post>
<input type=hidden name="Lname" value = "Wood"
etc.
To have the client do all the work without your server as a middle-man, you could use AJAX techniques (essentially Kevin's code, but translated to JavaScript) to send the POST.
Lenny Forziati
Vice President, Internet Products and Technical Services
Alpha Software Corporation
Comment
-
Re: http_post_page2() or HTTP_POST
Great - now, so how do I take the XML response that comes from the server and parse the contents? I know its not a readable string. I have tried all of the scripts below, and no value is returned. But I conclude this is because the response is XML, and my attempt to capture as a string is not valid for "response".
bdy = "... my XML here ..."
url = "https://ssl.selectpayment.com/rtg/XMLGateway.aspx"
dim cc as c
cc = http_post_page2(ur,bdy,.t.)
?"response= " + cc
---------------------------------------------------------------
bdy = "... my XML here ..."
dim req as p
dim resp as p
req.host = "https://ssl.selectpayment.com"
req.page = "/rtg/XMLGateway.aspx"
req.method = "POST"
req.body = bdy
req.header = "Content-Type: text/xml"
resp = http_fetch(req)
?"response= " + resp.body
---------------------------------------------------------------
bdy = "... my XML here ..."
dim url as c
url = "https://ssl.selectpayment.com/rtg/XMLGateway.aspx"
obj = ole.create("Msxml2.SERVERXMLHTTP")
obj.setoption(2,13056) 'ignore SSL errors obj.open("POST", url, .f.) obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
obj.send(bdy)
?"response= " + obj.responseText
-------------------------
Comment
-
Re: http_post_page2() or HTTP_POST
I am very frustrated with this. I now believe that XML response IS just a text string and I should be able to parse with normal tools. What is happening is that http_post_page2() does not work with HTTPS. It fails with a null response every time. (This is acknowledged in another post, see below).
http_post_page2() DOES work just fine in an Interactive Window for HTTPS, just not from an A5W page. Lenny explains it in another post, but that post has no conclusive results.
And from my testing (which I know is almost always flawed :o until something or someone hits me over the head)... from my testing none of the scripts in my previous post do any better than the naked http_post_pages2() function. None of them return a string from the website if my target is a secure site with HTTPS.
Comment
-
Re: http_post_page2() or HTTP_POST
Resolved.
I wish I could find some difference between what I 'came up with' after hours of search and Lenny's code below (to support my 'frustration'), but they are the same.
For those interested in a real life script that calls out to a payment gateway and then returns xml, see below. The variables at the top of the script would be set by a Dialog component, and the line "if eval_valid("PayBill") refers to the Dialog's Submit button (or AdvancedButton).
The last line, ?obj.responseText would be used to store the response in a variable, then values parsed out using normal string functions.
All the transaction values are fake.
-----------------------
Code:<%a5 dim t_gatewayurl as c = "https://ssl.selectpayment.com/rtg/XMLGateway.aspx" dim t_inv as c dim t_storeid as c = "164" dim t_storekey as c = "LrTcbvU5mLo1EgbVVEZ+TW4ETThn" dim t_reqid as c = "req123" dim t_merchantid as c = "1060" dim t_location as c = "1060" dim t_transid as c = "FAKE2" dim t_description as c = "Payment request by Check" dim t_effdate as c = "2007-01-01" dim t_amount as c = "100.00" dim t_nameonacct as c = "Steve Wood" dim t_checkacct as c = "123" dim t_checkrtn as c = "111900659" dim t_paytype as c = "Checking" 'if eval_valid("PayBill") req = "<?xml version='1.0' encoding='utf-8' ?>" + crlf() + \ "<requests xmlns='http://www.selectpayment.com/RTGRequest.xsd'>" + crlf() + \ " <credentials>" + crlf() + \ " <storeID>"+t_storeid+"</storeID>" + crlf() + \ " <storeKey>"+t_storekey+"</storeKey>" + crlf() + \ " </credentials>" + crlf() + \ " <auth requestID='"+t_reqid+"' merchantID='"+t_merchantid+"' locationID='"+t_location+"' transID='"+t_transid+"' description='"+t_description+"'>" + crlf() + \ " <check origin='Internet'>" + crlf() + \ " <amount>"+t_amount+"</amount>" + crlf() + \ " <bankBillTo>" + crlf() + \ " <nameOnAccount>"+t_nameonacct+"</nameOnAccount>" + crlf() + \ " <bankInfo accountType='"+t_paytype+"'>" + crlf() + \ " <account>"+t_checkacct+"</account>" + crlf() + \ " <rtn>"+t_checkrtn+"</rtn>" + crlf() + \ " </bankInfo>" + crlf() + \ " </bankBillTo>" + crlf() + \ " <effectiveDate>"+t_effdate+"</effectiveDate>" + crlf() + \ " </check>" + crlf() + \ " </auth>" + crlf() + \ "</requests>" dim url as c dim body as c url = t_gatewayurl obj = ole.create("Msxml2.SERVERXMLHTTP") obj.setoption(2,13056) 'ignore SSL errors obj.open("POST", url, .f.) obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") obj.send(req) ?obj.responseText %>
Last edited by Steve Wood; October 20, 2007, 10:38 PM.
Comment
-
Re: http_post_page2() or HTTP_POST
http_fetch
As long as you have an enterprise license, you can use http_fetch(). The problem with your test is that .host should only be a hostname and you use the .ssl_on property to use HTTPS:
Code:Dim bdy as c = "test" dim req as p dim resp as p req.host = "ssl.selectpayment.com" req.ssl_on = .t. req.ssl_ValidateCert = .f. req.page = "/rtg/XMLGateway.aspx" req.method = "POST" req.body = bdy req.header = "Content-Type: text/xml" resp = http_fetch(req) ?"body: " + resp.body = body: <?xml version="1.0" encoding="utf-8"?> <responses error="true" resultCode="Error_Invalid_Format" responseMessage="The data at the root level is invalid. Line 1, position 1." />
Your example works for me. One potential problem however is that you are setting the content type to specify a urlencoded body, which you send in this test but you would not be sending if you are POSTing an XML document
Code:dim url as c dim body as c url = "https://ssl.selectpayment.com/rtg/XMLGateway.aspx" body = "test=foobar" obj = ole.create("Msxml2.SERVERXMLHTTP") obj.setoption(2,13056) 'ignore SSL errors obj.open("POST", url, .f.) obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") obj.send(body) ?"body:" + obj.responseText = body:<?xml version="1.0" encoding="utf-8"?> <responses error="true" resultCode="Error_Invalid_Format" responseMessage="The data at the root level is invalid. Line 1, position 1." />
http_post_page2()
This is not server safe - it will hang your server eventually and should be avoided for your particular use in an A5W page. But it will work OK from a desktop script:
Code:url = "https://ssl.selectpayment.com/rtg/XMLGateway.aspx" dim cc as c cc = http_post_page2(url,bdy) ?"body: " + cc = body: <?xml version="1.0" encoding="utf-8"?> <responses error="true" resultCode="Error_Invalid_Format" responseMessage="The data at the root level is invalid. Line 1, position 1." />
Lenny Forziati
Vice President, Internet Products and Technical Services
Alpha Software Corporation
Comment
-
Re: http_post_page2() or HTTP_POST
Great. So the one I finally got working, is the one I should avoid!
I will try to document this for other's use after I am done. The Help is not detailed enough in this area to point out what to do.
Please for now though - just tell me which method I should use in this case so I can focus on that one.
Specs:
- Sending XML, expecting XML response to the same page that sent the request.
- Have the Enterprise Alpha server.
- Transmission must be over SSL.
- Need to test from a desktop connection, then migrate to the server for test/final.
- My desktop does not have SSL, so my test needs to work with/without SSL on the testing machine.
Comment
-
Re: http_post_page2() or HTTP_POST
The one you got to work is fine. http_post_page2() is not server safe because it uses XMLHTTP instead of SERVERXMLHTTP that you are using.
You can either stick with what you are using or use http_fetch(). I prefer http_fetch() because it gives more flexibility. But your SERVERXMLHTTP has a responseXML property which will be a parsed XML document if the server sends back proper XML. You can work with that, if you know how, instead of using Xbasic to manually parse the response from http_fetch()
Lenny Forziati
Vice President, Internet Products and Technical Services
Alpha Software Corporation
Comment
-
Re: http_post_page2() or HTTP_POST
Update.
I have stopped using some code that is referenced a couple posts down in this thread for web services. The code block starts with ole.create("Msxml2.SERVERXMLHTTP").
It was causing my WAS to lock up frequently. It would lock up about three minutes AFTER the web services were completed. I never could figure out exactly why it locked up, it just did. The only error I could see was in the Xbasic Error Stack log and said something like "could not start the server".
I replaced it with the following, where "url" is the full URL to the web services, and req is my HTTP POST request as a string. An example value for url is "https://www.paypal.com/cgi-bin/webscr".
dim pm as p
dim pm.host as c = a5_split_url(url).protocol + "//" + a5_split_url(url).server
dim pm.page as c = a5_split_url(url).page
dim pm.port as n = 443
dim pm.method as c = "post"
dim pm.ssl_on as l = .t.
dim pm.body as c = req
resp = http_fetch(pm)
Comment
Comment