I am trying to access a webservice through PHP. The webservice returns a byte array with a jpeg image, which is then shown on a webpage.
Today the service is accesses by a C# call, like so
ImgService i = new ImgService();
The credentials are set like this:
i.Credentials = new System.Net.NetworkCredential(username, password, domain);
Access to webservice:
byte[] result = null;
result = i.GetThumbNail(raceId, startNum, seasonId, height, width, true);
Response.ContentType = "image/jpeg";
Response.BinaryWrite(result);
The service is working fine in C# but now I need to access it through PHP and the only image I am getting is "missing.jpg". I am not sure if this means that the credentials are wrong or if something else is wrong, but I feel very unsure about the credentials part.
This is the PHP code without any credentials:
$client = new SoapClient("http://www.example.com/imgService.asmx?WSDL");
$result = $client->GetThumbNail($args['race'], $args['startnumber'], $args['year'], 0, 0, true);
$image_data = $result->GetThumbNailResult;
echo '<img src="data:image/jpeg;base64,'.base64_encode($image_data).'">';
I have also tried using calls like this:
$headers = array(
'username' => 'user',
'password' => 'pass',
'domain' => 'domain'
);
$header = new SoapHeader("http://tempuri.org/", 'UserCredentials', $headers, false);
$client->__setSoapHeaders($header);
$result = $client->GetThumbNail(parameters);
Both versions gives me the same missing.jpg and no error message. I feel I would get an error if the service did not accept the call?
Did not manage to solve this problem with the old web service, so I ended up creating a new HttpHandler doing the same thing the old service did. Oh well...