mercredi 6 mai 2015

PHP how to consume a remote https WCF webservice

Im trying to consume a WCF webservice using get or post with php , it is a great example, it works locally but I need to make it work remotelly.

The code is a great test example because it allows you to see both the get and post requests.

This is a model of the url (not the real one).

http://ift.tt/1dNt0pO

This is the error from the server

The exception message is 'Invalid value for 'encryptedTicket' parameter.'

What should I do to solve it? It seems there is not to much written about this.

The code below

<?php
echo 'Call the service using GET <br>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ift.tt/1dNt0pO".
                    "");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

print_r($result);
echo '<br>';

echo '<br>Call the service using POST <br>';


$transmitObject = array("fname" => "MASTER", "lname" => "POGI");




$jsonObject = json_encode($transmitObject);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ift.tt/1dNt0pO");
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonObject);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
print_r($result);
?>

Aucun commentaire:

Enregistrer un commentaire