views:

17

answers:

1

Hi,

I have implemented a WCF service hosted on Windows Service. I want to consume it with PHP. Everything works OK for now, but problem is when I stop my win. service.

Consuming it with .NET application I get EndpointNotFoundException. But using PHP I get HTTP Error 500.0 - Internal Server Error

This is my PHP code:

<?php
header('Content-Type: text/plain');
try
{ 
    $client = new 
        SoapClient( 
            "http://localhost:8000/TestService/service?wsdl" 
        );      

    $webService = $client->CheckStatus();       
    $wsResult = $webService->CheckStatusResult;
    print  $wsResult;
} 
catch (Exception $e) 
{
    print  "Caught exception: " .  $e->getMessage(). "\n";
} ?>

My question is: how to check if endpoint is accessible, because error I described occurs after timeout. I want to quickly check this, and not get internal server error

A: 

If the service is not accessable, the service will be unable to connect. That time that it takes to give up is (I believe) based on the setting default_socket_timeout in php.ini. Try setting that to something lower and you should get a failure sooner than the timeout as it is now.

My apologies if you are trying to say that the exception is not getting properly caught.

Mitch