You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by "Dr. Klemens Waldhör" <Wa...@t-online.de> on 2002/07/31 07:29:13 UTC

Perl and Xindice XMLRPC - exception handling

Hi,

I have written a Perl module which - basoed on the Frontier::Client
module realises all the methods available in the Xindice XMLRPC module.
The problem I have now is that in case of exceptions thrown the module
(resp. The calling application) terminates with a Java error. See below:

Fault returned from XML RPC Server, fault code 0: java.lang.Exception:
java.lang
.Exception: Collection name must begin with a '/'

(I do not understand this error anyway as the collection givenis
supplied with staring '/', but anyway ...).

Now this behaviour is obviously something which does not like if using
the module. I tried to catch this in an eval block, but it did not work.

Any idea how I can resolve this so that the module methods return an
error code instead ?

Methods look like this

sub queryCollection
{
	my $self = shift;
	my $query = shift;
	my $method= 'db.queryCollection';
	my $type = "XPath";
	my @args = ($self->{COLLECTION}, $type, $query, {X =>
"http://www.xmldb.org/xpath"});
	my $result = $self->{SERVER}->call($method, @args);
	return $result;
}

Or

sub dropCollection
{
	my $self = shift;
	eval
	{
		my $method= 'db.dropCollection';
		my @args = ($self->{COLLECTION});
		my $result = $self->{SERVER}->call($method, @args);
		$self->{COLLECTION} = "";
		return $result;
	};
	$self->{ERROR} = -1;
	$self->{ERRORMSG} = $@;	
}

Thanks for your help !

Klemens


RE: Perl and Xindice XMLRPC - exception handling

Posted by David Viner <dv...@yahoo-inc.com>.
what is the value of $self->{COLLECTION} ?

perhaps you modify one function to say:
sub queryCollection
{
	my $self = shift;
	my $query = shift;
	my $method= 'db.queryCollection';
	my $type = "XPath";
	my @args = ($self->{COLLECTION}, $type, $query, {X =>
"http://www.xmldb.org/xpath"});
	warn "collection is ".$self->{COLLECTION};
	my $result = $self->{SERVER}->call($method, @args);
	return $result;
}

that value must begin with '/'.

dave


-----Original Message-----
From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
Sent: Tuesday, July 30, 2002 10:29 PM
To: xindice-users@xml.apache.org; xindice-dev@xml.apache.org
Subject: Perl and Xindice XMLRPC - exception handling


Hi,

I have written a Perl module which - basoed on the Frontier::Client
module realises all the methods available in the Xindice XMLRPC module.
The problem I have now is that in case of exceptions thrown the module
(resp. The calling application) terminates with a Java error. See below:

Fault returned from XML RPC Server, fault code 0: java.lang.Exception:
java.lang
.Exception: Collection name must begin with a '/'

(I do not understand this error anyway as the collection givenis
supplied with staring '/', but anyway ...).

Now this behaviour is obviously something which does not like if using
the module. I tried to catch this in an eval block, but it did not work.

Any idea how I can resolve this so that the module methods return an
error code instead ?

Methods look like this

sub queryCollection
{
	my $self = shift;
	my $query = shift;
	my $method= 'db.queryCollection';
	my $type = "XPath";
	my @args = ($self->{COLLECTION}, $type, $query, {X =>
"http://www.xmldb.org/xpath"});
	my $result = $self->{SERVER}->call($method, @args);
	return $result;
}

Or

sub dropCollection
{
	my $self = shift;
	eval
	{
		my $method= 'db.dropCollection';
		my @args = ($self->{COLLECTION});
		my $result = $self->{SERVER}->call($method, @args);
		$self->{COLLECTION} = "";
		return $result;
	};
	$self->{ERROR} = -1;
	$self->{ERRORMSG} = $@;
}

Thanks for your help !

Klemens



AW: Perl and Xindice XMLRPC - exception handling

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
Thanks !

Problem solved.

In some days I will make the module available to the public. Need to
docu it :-)

But I have too admit that yours is much more elaborate, mine is very
simple and just implemented for the purposes I needed it.

Klemens

-----Ursprüngliche Nachricht-----
Von: Graham Seaman [mailto:graham@seul.org] 
Gesendet: Mittwoch, 31. Juli 2002 10:45
An: xindice-dev@xml.apache.org
Cc: xindice-users@xml.apache.org
Betreff: Re: Perl and Xindice XMLRPC - exception handling


On Wed, 31 Jul 2002, Dr. Klemens Waldhör wrote:

> Hi,
> 
> I have written a Perl module which - basoed on the Frontier::Client 
> module realises all the methods available in the Xindice XMLRPC 
> module. The problem I have now is that in case of exceptions thrown 
> the module (resp. The calling application) terminates with a Java 
> error. See below:
> 
> Fault returned from XML RPC Server, fault code 0: java.lang.Exception:

> java.lang
> .Exception: Collection name must begin with a '/'
> 
> (I do not understand this error anyway as the collection givenis 
> supplied with staring '/', but anyway ...).
> 
> Now this behaviour is obviously something which does not like if using

> the module. I tried to catch this in an eval block, but it did not 
> work.
> 
> Any idea how I can resolve this so that the module methods return an 
> error code instead ?

I don't know about the Frontier module in particular, but the eval
SHOULD 
work. You could try 
http://sourceforge.net/projects/xml-simpledb
or at least the driver for Xindice in that (XML/DB/Database/Xindice.pm)
which uses RPC::XML (with calls wrapped in evals) and see if that gives
you the same problem. The driver is for Xindice1.0, NOT the version in 
CVS. Though in my case, I'm not converting the exceptions to error
codes, simply passing them up the chain by die-ing again after they've
been 
caught.

Graham
(As far as I know, no-one but me has ever used this package so you are 
very likely to find other things wrong with it. If you do, please mail
me off-list, so as not to clutter up the lists!)




Re: Perl and Xindice XMLRPC - exception handling

Posted by Graham Seaman <gr...@seul.org>.
On Wed, 31 Jul 2002, Dr. Klemens Waldhör wrote:

> Hi,
> 
> I have written a Perl module which - basoed on the Frontier::Client
> module realises all the methods available in the Xindice XMLRPC module.
> The problem I have now is that in case of exceptions thrown the module
> (resp. The calling application) terminates with a Java error. See below:
> 
> Fault returned from XML RPC Server, fault code 0: java.lang.Exception:
> java.lang
> .Exception: Collection name must begin with a '/'
> 
> (I do not understand this error anyway as the collection givenis
> supplied with staring '/', but anyway ...).
> 
> Now this behaviour is obviously something which does not like if using
> the module. I tried to catch this in an eval block, but it did not work.
> 
> Any idea how I can resolve this so that the module methods return an
> error code instead ?

I don't know about the Frontier module in particular, but the eval SHOULD 
work. You could try 
http://sourceforge.net/projects/xml-simpledb
or at least the driver for Xindice in that (XML/DB/Database/Xindice.pm)
which uses RPC::XML (with calls wrapped in evals) and see if that gives
you the same problem. The driver is for Xindice1.0, NOT the version in 
CVS. Though in my case, I'm not converting the exceptions to error codes,
simply passing them up the chain by die-ing again after they've been 
caught.

Graham
(As far as I know, no-one but me has ever used this package so you are 
very likely to find other things wrong with it. If you do, please mail me
off-list, so as not to clutter up the lists!)




Re: Perl and Xindice XMLRPC - exception handling

Posted by Graham Seaman <gr...@seul.org>.
On Wed, 31 Jul 2002, Dr. Klemens Waldhör wrote:

> Hi,
> 
> I have written a Perl module which - basoed on the Frontier::Client
> module realises all the methods available in the Xindice XMLRPC module.
> The problem I have now is that in case of exceptions thrown the module
> (resp. The calling application) terminates with a Java error. See below:
> 
> Fault returned from XML RPC Server, fault code 0: java.lang.Exception:
> java.lang
> .Exception: Collection name must begin with a '/'
> 
> (I do not understand this error anyway as the collection givenis
> supplied with staring '/', but anyway ...).
> 
> Now this behaviour is obviously something which does not like if using
> the module. I tried to catch this in an eval block, but it did not work.
> 
> Any idea how I can resolve this so that the module methods return an
> error code instead ?

I don't know about the Frontier module in particular, but the eval SHOULD 
work. You could try 
http://sourceforge.net/projects/xml-simpledb
or at least the driver for Xindice in that (XML/DB/Database/Xindice.pm)
which uses RPC::XML (with calls wrapped in evals) and see if that gives
you the same problem. The driver is for Xindice1.0, NOT the version in 
CVS. Though in my case, I'm not converting the exceptions to error codes,
simply passing them up the chain by die-ing again after they've been 
caught.

Graham
(As far as I know, no-one but me has ever used this package so you are 
very likely to find other things wrong with it. If you do, please mail me
off-list, so as not to clutter up the lists!)