Question
· Jul 17, 2017

Connecting to a web service

Hi,

I am new to coding web services and trying to connect to an API that returns its format in xml or json.

I have a class as follows.. when I run I get back a 6059 in my status - Unable to open TCP/IP socket to server

Can someone help me identify what I am missing?  Thanks

Class Common.WebDownload Extends (%RegisteredObject, %XML.Adaptor)
{

ClassMethod Connect()
{
  Set aa=##class(%Net.HttpRequest).%New()
  Set aa.Server="https://www.actualwebaddresshere.com"
  Set aa.Location="/service/actual location path and my API key here/"
  Set aa.ContentType="text/xml"
  set bb=aa.Get()
  break
}

Method Get(location As %String = "", test As %Integer = 0, reset As %Boolean = 1) As %Status
Discussion (12)1
Log in or sign up to continue

HTTP Status 301 means Moved Permanently, which happens when you request a resource and the server redirects you to another (usually equivalent), since you said it's asking to use HTTPS, I suppose you haven't configured a SSL configuration on the Caché side.

Create a new SSL Configuration mark Enabled, select Type to Client, Peer certificate verification level to None, and Protocols to TLS.

Or simply fill the Name and Description, anything else is default... click Test to see if it works and Save it.

Now after instantiating the %Net.HttpRequest, you pass your instance.SSLConfiguration = "Your SSL Configuration Name" and instance.Https = 1.

This is the minimal you usually need to do to have a working SSL aware client.

Thanks Rubens... I have tried that and even in just testing the config I get the error 

ERROR #989: SSL connection failed, make sure server address and port (not url) is specified

I changed the Protocols from TLS to SSL and get the same... I have tried to port 80 and port 443.

I have an email into the site too to see if they can assist.

For server address I am just putting  https://www.fantasyfootballnerd.com

that is the actual address... didn't want to put it out there and kill them with traffic, it is a small service... but this may help solve I would think if you have the actual address.

If you mean testing using the SSL configuration in the Portal, when you click Test, it asks you for your server name and port. This follows the same pattern as %Net.HttpRequest, which means: don't provide the protocol http:// or https://, only your address: fantasyfootballnerd.com

For a use case, we have service hosted on AWS using HTTPS and it connects succesfully, but only if I strip the protocol from the address. Here's a feedback from our service when using the Test button (it's portuguese though ...)

Conexão SSL bem sucedida <- Indicates success on connecting.
Protocolo: TLSv1/SSLv3
Ciphersuite:ECDHE-RSA-AES128-GCM-SHA256
Peer:  <- No peer certification defined, so it's empty...
Requisição: GET / HTTP/1.0 <- Request done using HTTP 1.0 protocol 
Resposta: <- Response is an empty body.