简体   繁体   中英

PHP Soap Client Random Errors

I have a major headache here. Basically I have a script which works with a soap service to retrieve details about consignments. Running the script locally using xampp works perfectly and without error, however on my clients actual production server sometimes it will work and sometimes it will throw an exception stating that either it can't parse the wsdl file or it can't connect to the host.

Each time I have gotten these errors I go and check the service is actually running and each and every time I do that it's just fine.

I've tried setting the following options at the top of the script file:

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
libxml_disable_entity_loader(false);

What I have noticed is that if I get more than three exceptions thrown during the scripts execution the server will return a 500 internal error. Does anyone have any suggestions on what could be causing these problems?

Here Is one of the error messages and I will add more as I re-test the script:

SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.ukmail.com/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl' : failed to load external entity "https://api.ukmail.com/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl

 SoapFault exception: [HTTP] Error Fetching http headers

The server has OpenSSL Enabled so that shouldn't be a problem.

Just tried downloading and using the wsdl file locally with the same results. I've pretty much ran out of options on this one so far.

I eventually gave up with php's built in soap client and decided to try sending and receiving the requests via curl which actually worked faster than the built-in functions strangely enough, but after so many queries i still ended up with the 500 internal server error. I eventually had to break the process down so that the serivce was only queried in chunks of twenty at a time when needed.

Just so you know, this error was most likely down to the port not being specified. This is why it was producing such ad hoc behaviour on more recent versions of PHP / Soap.

$soapClient = new SoapClient('https://api.ukmail.com:443/Services/UKMAuthenticationServices/UKMAuthenticationService.svc?wsdl', $params);

It would listen for the response on port 80 rather than 443. Adding :443 to the url solved it for me.

The 500 error that was being produced was SOAP PHP fault parsing WSDL: failed to load external entity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM