We have a SOAP service that receives files as byte content. This service works fine for small files, but is failing for files ~25MB or larger. In the case of large files, the SOAP call executes but returns null. It literally returns nothing--no error message, no message at all. My associate indicated that the server is generating a 500 internal server error, which somehow gets back to the client but disappears in my testing. Tracing the code indicates that the handle() method of the code is not throwing an eror but also not doing anything at all--not calling the service's authorization method nor the method that puts the file to the server.
What is the likely cause of this problem, and how can I resolve it?
I think the client that calls the soap stop the service before having the answer.
Try to increase the value of default_socket_timeout in your php.ini.
You can also increase the value of max_execution_time
I hope it will help you. :)
Related
I'm using PHP to make SOAP request. I do have information of the web service from the third party. Basically what they have give me:
The full URI request ( http://xx.xx.xx.xx:xxxxxx/some/services/BasicDo )
Username & Password
I am pretty new however I could understand a bit how PHP SOAP things work. However in the example I found the URL called is something like http://xx.xx.xx.xx/services/myservice?wsdl which is not really same with what I have with me. Additional question here is what should I ask them? Perhaps what is the name of wsdl file?
Also so far I have this code with me:
try{
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
}
catch(SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
But from the console, I received status 500 Internal Server Error. I don't know how this can be, I am expecting something from the catch block. Somebody please clarify me this. Thank you in advance.
Unfortunately, it seems like no matter what you try (e.g. passing array('exceptions' => 0), SoapClient() will throw an uncatchable E_ERROR on network connection issues. This bug is still present as high up as PHP 5.5.4 (REF).
Summary:
Test script:
$client=#new SoapClient('garbage',array('exceptions'=>FALSE));
echo 'OK';
Expected result: We should see "OK",
Actual result:
If we use register_shutdown_function to display the contents of error_get_last(), we get:
Array
(
[type] => 1
[message] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'garbage' : failed
to load external entity "garbage"
)
To explain why you suddenly get this error without changing anything on your system, and to explain why SoapClient works on your local machine and not on your production system, it is most likely a firewall issue.
Here is what another person reported that solved his problem:
I solved my problem. It was actually an issue with my firewall. The
firewall was dropping packets sent via PHP, but via curl or wget were
not being dropped. I added a rule for all traffic from that server and
increased the packet drop length and everything is working great now!
Advice:
My best advice at this time to write some code in the same PHP file that checks if the SOAP service url resolves and loads properly before calling the SoapClient.
Add these codes at head of the file to see where the error happen
ini_set('display_errors','1');
error_reporting(E_ALL);
I am not sure what the issue may be but I did the following to debug this issue when I encountered it
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
Things you can do:
Create a PHP file. Name it anything. Write the following code there:
ini_set('display_errors','On');
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
var_dump($client);
exit;
Run the file.
Chances are this will show you the required exception.
In my case, Our server used a proxy which I had not passed in the parameters due to which I was getting the issue.
Let us know how it goes.
Thanks
First you need to make sure you have access to the SOAP server.
From the machine that is running your php script try to access the wsdl file and check if it is valid.
you can for example use wget http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl then open the saved file and see what you are getting. Is it a valid wsdl?
Once you have sorted out our access, then you need to read the documentation here and here. You may need to authenticate differently or pass other options.
As for why the catch block is not picking up your exception, you are only catching SoapFault. The 500 internal server error can be caused by anything.
I really appreciate all of the answers given. I am actually working with another party which I don't have any access on the remote side. My job is to make SOAP request to the server. However it turned out that there is NO web service available for me. So I ended up using cURL to send raw POST of SOAP request. :-)
i got a script which creates a list implementation of messages being sent between users.
Everything works fine, till the amount of messages rises up to about 77.000.
For every message a object will be created and every object has a reference to the next message object.
I enabled error reporting and increased the memory limit - I don't get any errors and the http status code is a 200 Ok, even if the developer console tells me that the request failed.
If you have verified that it is not a memory limit issue, this could be a limitation of PHP....similar to this question:
How to Avoid PHP Object Nesting/Creation Limit?
If you need to work with 77 000 objects in the same PHP script - it is something wrong with the architecture, php is not right choice for such calculations (even if it can handle this under some circumstances)
to track this particular error try to set in php.ini:
display_errors=1
display_startup_errors=1
error_reporting=-1
log_errors=1
memory_limit=to any reasonable value
max_input_time=to any reasonable value
max_execution_time=to any reasonable value
report_memleaks=1
error_log=writable path
consider using xdebug extension
don't forget to restart apache after changing proper php.ini (you can have different php.ini for apache and cli)
check if any set_error_handler or set_exception_handler functions are called in your code
I have a web app that allows the user to upload a pdf and it will then email it to us via swiftmailer. With some pdfs, the process fails.
I can verify that it crashes the php script, yet returns no php error. There's a 500 error from the server, but normally if there's a 500 error, php has a log of what the error was.
I have also verified that it crashes at the
$mailer->send($message);
line
Oddly, only some pdfs crash it, and those same pdfs work fine on the development server with identical code.
What could be causing php to crash without an error message?
After running several tests, I found that error logging was happening some of the time, but not others. I didn't figure out why that was so, however, I tried renaming the php-errors.log file so php would start with a new, fresh log file, and now errors are getting logged properly. I don't know why that worked, but I'll take it.
FYI, I've run into two things that can cause a PHP crash without an error message:
Script timeouts - A timeout may prevent an error message from being returned; in my particular case the script was waiting for an SMTP response when the timeout happened, which may have been why I didn't get a timeout message. Try changing your max_execution_time value in php.ini to 300 (5 minutes) and see if you can get an actual error message.
Folder permissions - I've encountered a case where insufficient folder permissions resulted in the script just halting without providing an error.
In the case of 2, I wrapped a try/catch clause around the line that was causing the halt, and I finally got an Exception to show up explaining about the permissions problem. That may be worth trying as a general response to silent crashes.
As part of the registration process on a website, I have added mail confirmation. But for some reason, the mail function throws an Internal server error in there.
The strange thing is that if I create a test script, with the exact same email (all the same parameters) it works fine, and sends the email.
The mail is sent from a function in a Class, in case that helps. I didn't post the code because it isn't really relevant, even if I try mail('email#email.com','subject','email'); it fails with the 500 error!
The server error logs don't show anything at all, anyone knows what may cause such a problem?
Technology:
The server is running php through mod_fastcgi, although this problem also happens if I switch to mod_suphp.
Updates:
UPDATE:
I'll try to explain this better, the mail function works perfectly if called from another file, with the same parameters. The problem here is something that combined with the mail function causes an error 500. The rest of the file where it's called is fine too, if I comment the mail function everything works. The way it gets called is an AJAX request to a file that calls a function where the mail is sent (Just in case this helps)
UPDATE 2:
In response to answers so far, here is more information I did not share previously:
OS: CentOS release 5.8
When I say error 500, I mean that the server returns only an HTTP 500 status code.
The server does not show anything in any error log
The most important thing is that if I create a file called test.php, with only mail('address#domain.com','Subject','Message'), it works just fine. When called from this other file, 500 status code returned.
What I am asking is if anyone knows, probably from experience, what could be causing this.
UPDATE 3:
Someone had the same problem yesterday: PHP's mail() function causes a 500 Internal Server Error only after a certain point in the code
UPDATE 4:
After some testing, I have discovered that the 500 stats code is only returned when the script is called via AJAX. If I create a file called test.php, and I simply place the mail function and test it, it works. Calling it via AJAX doesn't, any ideas?
Your question is very confused.
You've not said what operating system you are running on, nor provided details of the configuration: on MSWindows php's mail function acts as an SMTP client. On POSIX OS's (including Linux) it executes a command program to send the email. The SMTP client needs to know the server and port to connect to. The POSIX function needs the config to tell it which program to run.
You keep refering to a 500 error - do you mean an HTTP 500 status code at the browser?
What does the log for the mail program / server show? If this is a posix platform, try changing the php.ini to run a shell script to log actions and parameters.
With the amount of input you have provided, it is very hard to tell, how that error occured.
Error: 500 are Interval Server Errors and can have more than one reasons for occuring.
A malformed php cgi script
An invalid directive in an .htaccess or other config file
Limitation imposed by file system and server software.
May be you are attachcing a file to be to be sent
Missing Line Breaks (\r\n) in the headers
Try every solution listed from this cPanel Forums
After some more hours of testing I have found the problem!
I was using window.location to redirect the user to a new page after the AJAX call was completed, in it's callback function.
Apparently if you modify it after an AJAX call to a php script that uses the mail() function, the server returns a 500 status code in the request
I am getting an error with nusoap and/or SugarCRM. Here is the error:
XML error parsing SOAP payload on line 1: Mismatched tag
I get that in the $soapclient->error_str response. Not exactly sure what this error means or where it is located and I could use some help. So here is the background, I am working in SugarCRM with the included nusoap class and have an external site accessing the soap interface. The weird thing is that I have working copy running locally and this error only occurred when I uploaded it to my linux server.
I now I have a low reputation but if you give a working answer I will accept it. And also, I have researched the error with no luck. Any help would be much appreciated. If you need me to post any code, just let me know.
MORE INFO:
I am using SugarCRM CE 6.2.1. My soap entry point is http://server/sugar/soap.php. Here is my instation of the nusoap client.
$soapclient = new nusoap_client('http://server/sugar/soap.php');
Here is an example of a call made to the soap client
$result = $soapclient->call('update_existing_contact', array($session_id, $data));
However the error is the same for every call.
Also I get the same error when I try to use the sugar/examples/SoapTest.php so I don't think it is the client.
Like I said earlier the thing that is the most weird is that the problem only occurs on my server even when it is the same code.
I would try to use e.g. SoapUI to test the web service. If that works, you know it's most likely a problem with the client. Some other suggestions for debugging
Look in the web server log (Is the call getting through OK)
Enable the SugarCRM logging and set the level to debug
Either enable PHP error output or make PHP log errors to a log file
Use e.g. SoapUI to test SOAP call
See question 5396302 for a thorough SOAP example
Check the SugarCRM SOAP documentation