CURL-PHP to Java-HTTPComponents

L

LMario

Somebody can help to me to rewrite to next CURL PHP code to Java HTTPComponents:

$process = curl_init('https://www.test.com/directory');
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', 'charset=utf-8'));
curl_setopt($process, CURLOPT_POSTFIELDS, $sob->saveXML());
curl_setopt($process, CURLOPT_SSLCERT, '123456789.cer');
curl_setopt($process, CURLOPT_SSLCERTPASSWD, "123456789");
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_POST, true);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
$answer = curl_exec($process);
curl_close($process);
 
J

Jim Gibson

LMario said:
Somebody can help to me to rewrite to next CURL PHP code to Java
HTTPComponents:

$process = curl_init('https://www.test.com/directory');
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: text/xml',
'charset=utf-8'));
curl_setopt($process, CURLOPT_POSTFIELDS, $sob->saveXML());
curl_setopt($process, CURLOPT_SSLCERT, '123456789.cer');
curl_setopt($process, CURLOPT_SSLCERTPASSWD, "123456789");
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_POST, true);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
$answer = curl_exec($process);
curl_close($process);

If you google for "java curl", the first three hits are pretty much
your question. No idea if the answers are any good.
 
L

LMario

Yes, you're right, but it seems the answers are incomplete because they do not handle the authentication nor the sending of string data (variable $sob) to the server nor SSL verification.

I hope somebody can help me with my post.
 
J

Joerg Meier

Yes, you're right, but it seems the answers are incomplete because they do not handle the authentication nor the sending of string data (variable $sob) to the server nor SSL verification.
I hope somebody can help me with my post.

Show us what you've got that doesn't do what you want. For debugging, I can
recommend Wireshark, which would let you compare request A with request B
to see where your Java one doesn't look like the PHP one.

Liebe Gruesse,
Joerg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,560
Members
45,035
Latest member
HoTaKeDai

Latest Threads

Top