1

I have a php file in which a webservice is called with soapclient method. This file works properly when i run it independently. But when it is called from another php file, following line leads php file to die and does not show any error.

$client = new SoapClient("http://x.x.x.x/x/Send?wsdl");

I have used try-catch to find out the error , but it does not show anythings and remaining codes are not executed.

$number     = $_GET['number'];
$msg        = $_GET['msg'];
$scode      = $_GET['scode'];
$id         = $_GET['id'];

if(!is_array($number)){
    $number = array($number);
}

if(!is_array($msg)){
    $msg = array($msg);
}

if(!is_array($scode)){
    $scode = array($scode);
}

if(!is_array($id)){
    $id = array($id);
}

$client = new SoapClient("http://x.x.x.x:xxx/x/Send?wsdl");

try{
$response = $client->function(
                    array(
                        'xxxxx'      => 'xx',
                        'xxxxx'      => 'xx',
                        'xxxxx'      => 'xx',
                        'xxxxx'      => xxx,
                        'xxxxx'      => $msg,
                        'xxxxx'      => $number,
                        'xxxxx'      => $scode,
                        'xxxxx'      => $id
                    ));
        return $response;
    }
    catch(Exception $e)
    {
        return $e->getMessage();
    }
Hedi
  • 322
  • 4
  • 17
  • try changing `return` to `echo` or `print_r($response);` | `print_r($e->getMessage())` when you calling it from another php file. – Noman Jan 26 '16 at 07:25
  • return only works with in function or method . – Noman Jan 26 '16 at 07:26
  • I tryed it before , but all lines after new soapCilent do not execute. – Hedi Jan 26 '16 at 07:28
  • have you checked for `error_logs` ? what error you getting ? try adding `error_reporting(E_ALL);` on top of main file. – Noman Jan 26 '16 at 07:30
  • it shows : PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xx.xx.x.x:xxxx/x/Send?wsdl' : failed to load external entity "http://xx.xx.x.x:xxxx/x/Send?wsdl" – Hedi Jan 26 '16 at 07:39
  • Its seems you may need to pas user agent. look this thread http://stackoverflow.com/questions/21861077/soap-error-parsing-wsdl-couldnt-load-from-but-works-on-wamp – Noman Jan 26 '16 at 07:47
  • @Noman Thanks for your help but the link could not help. This file is executed independently without problem on server. The problem is that this webservice can not be called from another php file on the same server. – Hedi Jan 26 '16 at 08:27

0 Answers0