1
votes

I have to make a request to a SOAP webservice and I was using the following code with success.

$client = new SoapClient('http://myhost.foo/ws/ws.asmx?WSDL', 
    array('cache_wsdl' => false,
          'trace' => false,
          'exceptions'=>false,
          'soap_version' => SOAP_1_2));

$params['method']['param'] = $somedata;
$params['method']['clientIP'] = $_SERVER['REMOTE_ADDR'];

$result = $client->__soapCall('method', $params);

I started to receive the following error these days, at the first line of code:

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load 
from 'http://myhost.foo/ws/ws.asmx?WSDL' : Start tag expected, 
'<' not found

Trying to debug the problem, I tested the webservice with wget and the response is correct.

wget http://myhost.foo/ws/ws.asmx?WSDL --post-file=post.xml 
--header="Content-Type: text/xml" -O response.xml

I'd like to know what I am doing wrong on this line: $client = new SoapClient('http://myhost.foo/ws/ws.asmx?WSDL', array('cache_wsdl' => false, 'trace' => false, 'exceptions'=>false, 'soap_version' => SOAP_1_2));

EDIT:

If I get the WSDL content and put on a xml file and use it locally, everything works.

$client = new SoapClient('wsdl.xml', array(
    'location'=> 'http://myhost.foo/ws/ws.asmx', 
    'uri'=> 'http://tempuri.org/', 
    'soap_version' => SOAP_1_2, 
    'trace' => true, 
    'cache_wsdl' => WSDL_CACHE_NONE, 
    'keep_alive' => false));
1

1 Answers

0
votes

If the issue just started, it suggests something has changed on the datasource side.

I'd suggest making sure that there wasn't a change of SSL Certificate or data format. wget would still work in this case, whereas SOAP would not.