Soap Issue - SoapFault exception: [Client] looks like we got no XML document - soap

Ive looked at similar errors and i think its most likely due to a BOM character but to be honest most of the other coding is in a different context and i just dont understand it, im not that familiar with soap and just use it to pull the data then format it in php.
My code is simple:
$activityClient = xpmClient::getModuleInstance('activity', $remoteSessionId, 'xxx.5pmweb.com');
$filter = new stdClass();
$count = 300;
$offset = 0;
$activityList = $activityClient->getList($filter, $offset, $count);
Now the server error shows:
> PHP Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in xxx/caching.php:59\nStack trace:\n
\#0 xxx/caching.php(59): SoapClient->__call('getList', Array)\n
\#1 xxx/caching.php(59): xpmClient->getList(Object(stdClass), 0, '371')\n
\#2 /xxx/reports.php(296): include('/xxx/...')\n
\#3 {main}\n thrown in /xxx/caching.php on line 59
Line 296 on report.php is an include for the caching.php file, line 59 of that file is
$activityList = $activityClient->getList($filter, $offset, $count);
This worked for months without issue so im not sure what changed today. Any ideas how to strip the BOM and still get my data into $activityList as an object so i can access the information?
edit//
The preg replace doesnt work, i guess thats because once i call $activityList the server gives a fatal error and doesnt process anything after that so im trying to fix it AFTER its broke rather than before.
How would i go about doing __getLastResponse()
Ive read the manual but dont understand how to structure it, im pretty sure i need a try catch for the reasons i said preg replace didnt work but i tried a few variations and its doing nothing, im pretty sure the structure is wrong, any pointers or ideas?

I don't know why would BOM cause this but if you want to strip bom here you go
function strip_bom( $str ) {
return preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $str );
}

The Soap server you are using is broken. Have you checked manually trying to call it?

Related

neo4jphp: Cannot instantiate abstract class Everyman\Neo4j\Transport

maybe a simple question but for me as starter with Neo4j a hurdle. I installed the neo4jphp with composer in the same directory as my application. Vendor-Subfolder has been created and the everyman/neo4j folder below is available. For a first test I used this code snippet from the examples:
spl_autoload_register(function ($className) {
$libPath = 'vendor\\';
$classFile = $className.'.php';
$classPath = $libPath.$classFile;
if (file_exists($classPath)) {
require($classPath);
}
});
require('vendor/autoload.php');
use everyman\Neo4j\Client,
everyman\Neo4j\Transport;
$client = new Client(new Transport('localhost', 7474));
print_r($client->getServerInfo());
I always stumple upon the error
Fatal error: Cannot instantiate abstract class Everyman\Neo4j\Transport
Googling brought me to a comment from Josh Adell stating
You can't instantiate Everyman\Neo4j\Transport, since it is an abstract class. You must instantiate Everyman\Neo4j\Transport\Curl or Everyman\Neo4j\Transport\Stream depending on your needs
So I thought I just need to alter the use-statements to
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl;
but this doesnt work, debugging shows, that the autoloader only get "Transport.php" instead of "everyman\Neo4j\Transport\Curl.php". For "Client.php" its still working ("vendor\everyman\Neo4j\Client.php") so I am guessing that the use-statement is wrong or the code is not able to handle an additional subfolder-structure.
Using
require('phar://neo4jphp.phar');
works fine but I read that this is deprecated and should be replaced by composer / autoload.
Anyone has a hint what to change or had the same problem?
Thanks for your time,
Balael
Curl is the default transport. You only need to instantiate your own Transport object if you want to use Stream instead of Curl. If you really want to instantiate your own Curl Transport, the easiest change to your existing code is to modify the use statement to be:
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl as Transport;
Also, you don't need to register your own autoload function if you are using the Composer package. vendor/autoload.php does that for you.
Thanks Josh, I was trying but it seems I still stuck somewhere. I am fine with using the default CURL - so I shrinked the code down to
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());`
The folder structure is main (here are the files and the composer.json with the content
{
"require": {
"everyman/Neo4j": "dev-master"
}
}
and in the subfolder "vendor" we have the "autoload.php" and the subfolder everyman with the related content. When I run the file I come out with
Fatal error: Class 'Everyman\Neo4j\Client' not found
which does not happen when I have the autoloadfunction. I guess I made a mistake somewehere - can you give me a hint?
Thanks a lot, B
Hmmm... I was just trying around and it seems the Transport CLASS is not needed in the use-statement and the class instantiation. This seems to work:
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Client();
print_r($client->getServerInfo());
also valid for having a dedicated server/port:
$client = new Everyman\Neo4j\Client('localhost', 7474);
If you have more input I would be happy to learn more - thanks, all input & thoughts are very appreciated.
Balael

Proper format for log4j2.xml RollingFile configuration

I am getting the following exception in my glassfish 4 application that uses log4j2:
SEVERE: ERROR StatusLogger Invalid URL C:/glassfish4/glassfish/domains/domain1/config/log4j2.xml java.net.MalformedURLException: Unknown protocol: c
I have the following section in my log4j2.xml:
<RollingFile name="RollingFile" fileName="C:/glassfish4/glassfish/domains/domain1/logs/ucsvc.log"
filePattern="C:/glassfish4/glassfish/domains/domain1/logs/$${date:yyyy-MM}/ucsvc-%d{MM-dd-yyyy}-%i.log">
I understand that if it's looking for a URL, then "C:/glassfish4/..." is not the correct format.
However, the rolling file part actually works: I see a log file and the rolled log files where I expect them.
If I change to a URL (e.g. file:///C/glassfish4/...) that doesn't work at all.
So should I ignore the exception? (everything seems to be working ok). Or can someone explain the correct format for this section of the configuration?
I have not yet fully determined why it is that the config file works for me as well as the OP, but, I can confirm that changing the path reference to a file:// url solves the problem (ie: gets rid of the error/warning/irritant).
In my IntelliJ Run/Debug configurations, for VM options, I have:
-Dlog4j.configurationFile=file://C:\dev\path\to\log4j2.xml
I can confirm that '\' are translated to '/' so, no worries there.
EDIT:
Okay, the whole thing works because they (the apache guys) try really hard to load the configuration and they do, in fact, load from the file as specified via the c:\... notation. They just throw up a rather misleading exception before continuing to try.
In ConfigurationFactory::getConfiguration:
**source = getInputFromURI(FileUtils.getCorrectedFilePathUri(config));**
} catch (Exception ex) {
// Ignore the error and try as a String.
}
if (source == null) {
final ClassLoader loader = this.getClass().getClassLoader();
**source = getInputFromString(config, loader);**
The first bolded line tries to load from a URL and fails, throwing the exception. The code then continues, pops into getInputFromString:
try {
final URL url = new URL(config);
return new ConfigurationSource(url.openStream(), FileUtils.fileFromURI(url.toURI()));
} catch (final Exception ex) {
final ConfigurationSource source = getInputFromResource(config, loader);
if (source == null) {
try {
**final File file = new File(config);
return new ConfigurationSource(new FileInputStream(file), file);**
Where it tries to load the config again, fails and falls into the catch, tries again, fails and finally succeeds on the bolded lines (dealing with a File).
Okay, the code lines I wanted in emphasize with bold are actually just wrapped in **; guess the site doesn't permit nested tags? Anyway, y'all get the meaning.
It's all a bit of a mess to read, but that's why it works even though you get that nasty-looking (and wholly misleading) exception.
Thanks Jon, i was searching all over.. this helped!
This is on Intellij 13, Tomcat 7.0.56
-Dlog4j.configurationFile=file://C:\Surendra\workspace\cmdb\resources\elasticityLogging.xml
The problem is not the contents of your log4j2.xml file.
The problem is that log4j2 cannot locate your log4j2.xml config file. If you look carefully at the error, the URL that is reported as invalid is C:/glassfish4/glassfish/domains/domain1/config/log4j2.xml: the config file.
I'm not sure why this is. Are you specifying the location of the config file via the system property -Dlog4j.configurationFile=path/to/log4j2.xml?
Still, if the application and logging works then perhaps there is no problem. Strange though. You can get more details about the log4j configuration by configuring <Configuration status="trace"> at the top of your log4j2.xml file. This will print log4j initialization details to the console.

Exceptions from parsing unquoted cookies in Apache2

I'm using Apache2::Cookie (i.e. Apache2 with mod_perl) to parse cookies.
my %cookies = Apache2::Cookie->fetch;
do_something($cookies{"cookie1"});
This code has been running in production for years without any problems. I just learned that a cookie with particular formatting causes this to throw an exception Expected token not present. The cookie in question is generated by client-side JavaScript:
document.cookie = "val=a,b"
Apache2::Cookie appears to not like the comma.
I can catch this error with eval, but the cookie retrieval is done in lots of places in the code (yes, it could have been factored out, but frankly the code is so simple there was no need). In any case, it's there now and I have to track down and catch the exception for this cookie that I didn't set and I don't need.
Is there an easier way to get rid of this exception than refactoring dozens of calls to Apache2::Cookie->fetch? Either by redefining Apache2::Cookie::fetch, or by setting a global flag for libapreq to not puke on this (there isn't any I could find), or some other bright idea I'm missing.
(yes, it could have been factored out, but frankly the code is so simple there was no need).
I would take this opportunity to fix this oversight, instead of making another
If you insist, you could learn something from CGI::Cookie
sub fetch {
my $class = shift;
my $raw_cookie = get_raw_cookie(#_) or return;
return $class->parse($raw_cookie);
}
sub get_raw_cookie {
my $r = shift;
$r ||= eval { $MOD_PERL == 2 ?
Apache2::RequestUtil->request() :
Apache->request } if $MOD_PERL;
return $r->headers_in->{'Cookie'} if $r;
die "Run $r->subprocess_env; before calling fetch()"
if $MOD_PERL and !exists $ENV{REQUEST_METHOD};
return $ENV{HTTP_COOKIE} || $ENV{COOKIE};
}
I faced the same issue and you can find the solution here :
“Expected token not present” error in my Apache log

Zend_Pdf - load utf-8 pdf document

I'm currently trying to load a PDF document using the Zend_Pdf::load($filename) method and I'm getting
Error occured while 'xxx.pdf' file reading.
So I see in Zend_Pdf_Parser::_construct there is this block
while ($byteCount > 0 && !feof($pdfFile)) {
$nextBlock = fread($pdfFile, $byteCount);
if ($nextBlock === false) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception( "Error occured while '$source' file reading." );
}
$data .= $nextBlock;
$byteCount -= strlen($nextBlock);
}
if ($byteCount != 0) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception( "Error occured while '$source' file reading." );
}
After debugging, I can tell that strlen($nextBlock) is not returning the right value (based on $nextBlock = fread($pdfFile, $byteCount); )
If I use mb_strlen($nextBlock,'8bit') instead this block passes right. Now I'm getting another error
Pdf file syntax error. 'startxref' keyword expected
So now I look into Zend_Pdf_StringParser:readLexeme() and I can see that again there is a problem with singlebyte vs. multibyte string functions (strlen etc.)
So does anybody have a clue what's going on with Zend_Pdf, if this is general bug or I'm just missing something?
I never used Zend_PDF because it has very few potential. I advise you to integrate into your project TCPDF! ;)
I experienced the same error and it turned out to be a bug in Zend Guard. Apparently my version of the PHP encoder turns the ASCII NP form feed character (\f) inside string literals into the backslash (\) and the f characters (\\f).
The obfuscated version of
print bin2hex("\f");
outputs
5c66
instead of the expected
0c
This behavior causes Zend_Pdf_StringParser to parse 'startxre' instead of 'startxref' in readLexeme, causing the error you described.
If you are using a different version of the encoder or no encoder at all, then this may not be the cause of the problem (try reproducing it on a different PHP version).

mod_perl headers_in not working

I'm using mod_perl 2 with Apache 2.2.3 on Red Hat 5.2, and I'm trying to access the request headers, but the Apache2::RequestRec headers_in method (or rather, its return value) is not behaving the way I would expect.
Code fragment:
$logger->warn('version ' . $mod_perl::VERSION);
$logger->warn('r ' . $r);
my $headers = $r->headers_in;
$logger->warn('headers ' . $headers);
my $accept = $headers->get('Accept');
$logger->warn('got $accept');
$logger->warn($accept);
gives the following log output:
WARN version 2.000004
WARN r Apache2::RequestRec=SCALAR(0x2ae0598e9ef0)
WARN headers APR::Table=HASH(0x2ae06cad15a0)
with execution appearing to halt as soon as any access to the APR::Table is attempted.
The tied interface for APR::Table had the same effect - i.e. changing the get('Accept') line to:
my $accept = $headers->{Accept};
gives exactly the same log output.
According to the above linked documentation:
This table is available starting from the PerlHeaderParserHandler phase
So I would expect my code, running in the PerlResponseHandler phase, to be able to access the headers.
Does anyone have any ideas what I'm doing wrong?
Edit: Using Data::Dumper hasn't really clarified matters at all.
Code:
use Data::Dumper;
$logger->warn(Dumper($r));
my $headers = $r->headers_in;
$logger->warn($headers);
$logger->warn(Dumper($headers));
$logger->warn('have dumped $headers');
Output:
WARN $VAR1 = bless( do{\(my $o = '47143456365192')}, 'Apache2::RequestRec' );
WARN APR::Table=HASH(0x2ae071b06fd0)
So it seems that trying to get into $headers even through Data::Dumper results in the execution halting.
Edit: Attempting to set one of the headers fails as well.
$logger->warn('reset accept');
$r->headers_in->{'Accept'}= 'everything';
$logger->warn('post set accept');
stops log output at the
WARN reset accept
point. I tried the set(Accept => 'everything') alternative as well, with the same result.
Is there anything in the apache logs? It seems if your code stops executing there should be an error somewhere saying why.
Problem found:
I needed to add
use APR::Table;
somewhere. Kind of weird that it was happily able to create an APR::Table object though.
Have you tried getting the Accept header without assigning the header object to $header:
my $accept = $r->headers_in->get('Accept');
This works in my code running in the PerlResponseHandler phase.