-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codepage translation and problem processing response messages in COBOL program #31
Comments
Re 1. HTTP/HTTPS Enabler does not translate by default, you're correct in your assumption that your application would need to indicate conversion should be done using HWTHSET API, specifically the HWTH_OPT_TRANSLATE_REQBODY and/or HWTH_OPT_TRANSLATE_RESPBODY options https://www.ibm.com/docs/en/zos/2.5.0?topic=values-options-requests Re 2. with out exposing anything, is there anything you can share about the data content? and is the HTTP Status in the 200 range? |
Hi. I have been debugging this issue some more. Still can't get it to work. |
At a guess, the server you are connecting to may require connections use at least TLS 1.2, but the System SSL implementation that CWET relies upon allows TLS 1.0. The Slack example here shows how to set a minimum TLS level - use the HWTH_OPT_SSLVERSION key with the HWTH_SSLVERSION_TLSv12 value. The Slack example is written in Rexx, but hopefully this will translate easily enough into COBOL.
There's also possibly the need to set the HWTH-SSL-USE option to true - I can't remember if CWET will auto-detect an https:// URL. https://www.ibm.com/docs/en/zos/2.5.0?topic=values-options-connections There may also be a need to specify which ciphers are valid. Again, the Slack example shows how this is done:
If you need to start debugging the TLS connection further, then you may wish to enable SSL trace. The Slack example shows the property that is needed to be set.
See the comments around line 135 for guidance on how to format an SSL trace. I think that will also allow you to see what's on the wire.
@gorelikg - I hadn't appreciated we are lacking a TLS-enabled COBOL sample. I'll try to put one together, but that won't be this week. |
I think you're probably right with that. When developing my example, I used the Linux nc -l 0.0.0.0 38100 When that port is accessed from a web browser, I get the following output:
Obviously this relies on you having access to a Linux machine, plus having security authority to open up a port that's not protected by a firewall. |
@ian-burnett thank you and that would be amazing! @redwolfo Ian is exactly right, when you enable ssl (HWTH_OPT_USE_SSL = HWTH_SSL_USE) and don't provide a specific SSL version (HWTH_OPT_SSLVERSION), the ssl version defaults to what System SSL has as it's default which for the past few z/OS releases is TLS 1.0 other things to verify (if you don't have this already ...):
|
Hi. Thank you for the suggestions above. I really appreciate the assistance. I'm still struggling to get the Toolkit to work for us. As a proof of concept, I am now posting from batch a "hello world" message to a CICS region in the same LPAR where my batch job is running. Using debugging tools I can see that my message, including all headers, are received by the CICS test transaction and a response is created. The batch Toolkit response exit is receiving the response message from CICS and I am able to address the response area. Here is my challenge. In the sample program HWTHBDYX posted here (part of source data HWTHXCB1) field RESP-BODY-PTR has the address of my response data (with the TSO/Xpediter debugging tool I can see the area contents). I do not need any of the code in HWTHBDYX to do the JSON transform. All I need is to pass RESP-BODY-PTR back to the main program from where the HWTHRQST service was invoked. Any thoughts on that? My other question is, I would rather not have a separate program to handle the response body. Is it possible to set an option to direct the Toolkit to invoke a section or paragraph within the main program instead of a separate exit program (csect)? Thank you!! |
Oh, no. Don't do that. The RESP-BODY-PTR is only valid while the body exit is active. Once HWTHRQST returns, that RESP-BODY-PTR is toast, and the storage is unpredictable/undefined/dead and gone. The only way to preserve body data (using this non-streaming response body exit), is to copy it "somewhere" while the exit is active. In C, where the body exit may have visibility to the global C variables by name, the body exit can simply allocate some storage, copy the body into it, and then set a global pointer to the allocated storage. I don't know if COBOL has that notion, but I would not be surprised. Now there is a lot of value in being able to inspect the body in-situ, and to only surface bits and pieces of it. That is working as designed. If you have modest expectations with respect to a maximum body size, one approach I might suggest would be to pre-allocate a suitably sized buffer and then pass its address to the body exit in the USERDATA field. Then the body exit could simply copy (as much of) the body (as fits), leaving the body exit itself is as "thin" as humanly possible. Now, just FYI the streaming exit does behave very differently. Since you have to provide the storage for the response body, up front, it is up to you to decide what to do with the body storage when you are done. That's a very different model, but is the only option for very large or unbounded response streams. Hope this helps. |
Your explanation makes sense. I'm going to explore passing an area address in USERDATA. I'm just doing a proof of concept, but if we do decide to use the Toolkit, I will probably have to use the streaming model to retrieve large amounts of data. |
Web Enablement toolkit has the option to convert the request from EDCDIC to ASCII and response from ASCII to EDCDIC. you will need to set it during connection setup process, Reference: https://www.ibm.com/docs/en/zos/2.3.0?topic=enabler-httphttps-options-values |
I coded a COBOL program using as a guide the sample program HWTHXCB1 posted here to post messages from our batch z/OS environment to external servers.
I am having a series of issues receiving and and parsing the response data. I am not using the JSON parser included with the Toolkit. I only need the raw data coming back from the server.
I have a couple of questions:
When sending a message from the mainframe to an outside server (Windows, Unix), do I need to request that the outgoing request data be translated to ASCII or do the MVS services do that automatically? (I don's see HWTHXCB1 doing that. I do understand that the response coming back into the mainframe does need to be translated to EBCDIC.
Just for testing, I'm posting a restful service request to one of our CICS regions residing in the same LPAR where my batch job is running. Using a CICS debugging tool, I can see the message being processed and a response message sent back. When the message is received by the Toolkit response exit, the data received is not the output from the CICS service, not EBCDIC and not ASCII.
Any assistance I can get with this will be appreciated; specially question #1.
Thank you.
The text was updated successfully, but these errors were encountered: