View previous topic :: View next topic
|
Author |
Message |
elixir1986
New User
Joined: 10 Nov 2015 Posts: 45 Location: USA
|
|
|
|
Was asked how to access web services/website from mainframes?
I mentioned about accessing using z/OS connect for webservices but interviewer was interested to know other avenues. I searched forum and tried executing some REXX to get to a webservice/website but no success.
Accessing web
Code: |
cmd = "curl -k https://jsonplaceholder.typicode.com/posts/1 2>/dev/null"
address USS
"USSCMD COMMAND('"cmd"') STEM(RESPONSE)"
if RESPONSE.0 > 0 then do
do i = 1 to RESPONSE.0
say " " RESPONSE.i
end
end
|
response is below,
Code: |
response:
4 *-* "USSCMD COMMAND('"cmd"') STEM(RESPONSE)"
+++ RC(-3) +++
|
Connect to website
Code: |
===> Scroll ===> CSR
/* rexx */
/*Make a connection to an http server, read the result and exit. */
Host = 'www.ibm.com'
Port = '8080'
srv = Socket('Initialize', 'httpd')
srv= Socket('Socket')
parse var srv src sockid
srv = Socket('Ioctl',sockid,'FIONBIO','OFF' )
srv = Socket('Gethostbyname',Host)
parse var srv src hostip
srv = Socket('Setsockopt',sockid,'SOL_SOCKET','SO_REUSEADDR','ON')
srv = Socket('Setsockopt',sockid,'SOL_SOCKET','SO_LINGER','OFF')
srv = Socket('Setsockopt',sockid,'SOL_SOCKET','TCP_NODELAY','OFF')
srv = Socket('Connect',sockid,'AF_INET' Port hostip)
parse var srv src .
If src > 0
then do
Say 'Unable to connect to' host':'port
Say 'Socket connect error:' srv
exit src
End
Exit 0
|
response
Code: |
Unable to connect to [url=https://your_URL.com]www.ibm.com:8080[/url]
Socket connect error: 60 ETIMEDOUT Connection timed out
|
Any constructive feedback is welcome! |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
REST APIs , Db2 JDBC , CICS Transaction Gateway (CTG) and CICS HTTP WEB requests .. there are other if you host on Linux but overall it depends on requirements.. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
If you are trying to get your code to work... can you manually PING those sites? That is, try to make sure it is a network problem, rather than a rexx problem. |
|
Back to top |
|
|
elixir1986
New User
Joined: 10 Nov 2015 Posts: 45 Location: USA
|
|
|
|
Pedro wrote: |
If you are trying to get your code to work... can you manually PING those sites? That is, try to make sure it is a network problem, rather than a rexx problem. |
I'm able to manually ping... |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
Quote: |
I'm able to manually ping...
|
By ping you mean from command prompt or from Mainframe.
Does
Code: |
TSO PING wwwdotwebsitedotcom |
work? |
|
Back to top |
|
|
|