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).

https://anyweb.com/anyservice.svc/GetShops

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, "https://anyweb.com/anyservice.svc/GetShops".
                    "");
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, "https://anyweb.com/anyservice.svc/GetShops");
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);
?>

Answers


The value or maybe datatype you are posting for encryptedTicket is wrong Read their docs and see what is expected to be received by their web service for that field


Need Your Help

Equivalent of open_memstream for MSVC

c visual-c++ posix

I am using open_memstream in a library of mine, but I would like to port this library to MSVC. It seems there are no equivalent function available, but is there something similar enough?

Getting labels to show

php mysql

I have 3 MySQL tables: