Skip to main content
israelp20923262
Known Participant
March 22, 2024
Question

How to use socket to make calls to https server and get xml as a response.

  • March 22, 2024
  • 1 reply
  • 1005 views

Hello.
I am trying to use socket in javascript to replace calls that I have like the following

 

PMString pmsAux("GET /Trebol/getIPLocal.do");
pmsAux.Append("?sessionId=");
pmsAux.Append("indesign");
pmsAux.Append(" HTTP/1.0");
pmsAux.Append ("\r\n");
pmsAux.Append("Cookie:");
pmsAux.Append("JSESSIONID=");
pmsAux.Append(jSessionId);
pmsAux.Append ("\r\n\r\n");


in c++ that also use a socket library to use HTTPS. The response returned by the server is in XML. Can someone help me or tell me if there is any example of calls to a server over HTTPS that receive an XML response.
Greetings.

This topic has been closed for replies.

1 reply

Community Expert
March 24, 2024

I hope something here helps - I'm not an expert in this area at all. There are people here who are far better at this than I am.

 

 

example.com should bbe your hostname

jSessionId should the actual value
data variable shout output when response completes
Node.js might simplify the process 


Maybe this is a bit easier then dealing with sockets, if in a browser the HTPPs requests have security restrictions and it might be better to Fetch API or XMLHttpRequest 

 

Again - I'm not an expert - I'm learning things every day and this has been an interesting one for me.

I'm looking forward to the replies too.

const https = require('https');

const options = {
  hostname: 'example.com',
  port: 443,
  path: '/Trebol/getIPLocal.do?sessionId=indesign',
  method: 'GET',
  headers: {
    'Cookie': `JSESSIONID=${jSessionId}`
  }
};

const req = https.request(options, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log(data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.end();

 

israelp20923262
Known Participant
March 25, 2024

Hi Eugene.
First of all, thank you for your response.
What I need is how to use the socket object of the indesign javascrip sdk and in your example I think what you are using is nodejs.
As I said before, thanks for your response but it's not what I'm looking for.

 

Legend
March 25, 2024

You could call out to javascript from your c++ PlugIn.

P.