Search code examples
phpwcfsoap-client

Im trying to consume a WCF service with PHP but it does not return the result i want where do i go wrong


PHP CODE is below

$soap = new SoapClient
("http://www.eservices.gov.bw/TolisExternalService/TolisPostService.svc
?singleWsdl",
array('soap_version' => 'SOAP_1_2',
     'location'=>'http://www.eservices.gov.bw/TolisExternalService/TolisPostService.svc'));

 $params = array(
    'licenceNo' => '2018/TEL/E/003'
    );   


$response= $soap->UpdateLevyPayment('$params');
$values = $response->GetAnnualFeeDueDetailsResult;;
var_dump($values);

WCF CODE

link for WCF service:http://www.eservices.gov.bw/TolisExternalService/TolisPostService.svc


Solution

  • You can try with this:

    <?php
    // SOAP
    $soap = new SoapClient(
        "http://www.eservices.gov.bw/TolisExternalService/TolisPostService.svc?singleWsdl",
        array(
            'soap_version' => 'SOAP_1_2',
            'location'=>'http://www.eservices.gov.bw/TolisExternalService/TolisPostService.svc')
        );
    
    
    // List functions
    echo 'Functions: '.'</br>';
    $functions = $soap->__getFunctions();
    foreach($functions as $item) {
        echo $item.'</br>';
    }
    echo '</br>';
    
    // List types
    echo 'Types: '.'</br>';
    $types = $soap->__getTypes();
    foreach($types as $item) {
        echo $item.'</br>';
    }
    echo '</br>';
    
    // Consume SOAP
    $params = array(
        'licenceNo' => '2018/TEL/E/003'
    );   
    $values = $soap->GetAnnualFeeDueDetails($params);
    print_r($values);
    ?>
    

    Notes: Tested with PHP 7.1