You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jan Delannoy <ja...@gmail.com> on 2005/05/25 18:45:33 UTC

namespace prefix question

Hi,

I'm using an Axis generated stub class to call a web service. The
generated messages use namespace prefixes like ns1, ns2, ns3, etc.
even when it's the same namespace.  Can I force Axis to use a
namespace prefix of my choice for a given namespace? I'm using Axis
1.2 final.

Many thanks,
Jan

Re: namespace prefix question

Posted by Jan Delannoy <ja...@gmail.com>.
Yes, in theory they are equivalent.  The problem is I'm using a kind
of scripting tool that allows me to define variables using XPath
expressions, but for some reason this tool expects an explicit
namespace prefix... So I can only see two solutions: 1) make the
namespaces explicit using an intermediary XSLT transformation, or 2)
make Axis generate explicit namespaces.  I'd rather go for 2...

Regards,
Jan


On 5/27/05, Tom Oinn <tm...@ebi.ac.uk> wrote:
> Jan Delannoy wrote:
> > Hi again,
> 
> > I would really appreciate it if someone could help me out with this,
> > even just letting me know that this isn't possible would already be
> > helpfull...
> 
> As far as I can tell the two fragments you show above are equivalent -
> is there any particular reason you want one form rather than the other?
> If you load either into any sensible XML object model you'll get
> identical results I believe, or am I missing something...?
> 
> Tom
>

Re: namespace prefix question

Posted by Tom Oinn <tm...@ebi.ac.uk>.
Jan Delannoy wrote:
> Hi again,

> I would really appreciate it if someone could help me out with this,
> even just letting me know that this isn't possible would already be
> helpfull...

As far as I can tell the two fragments you show above are equivalent - 
is there any particular reason you want one form rather than the other? 
If you load either into any sensible XML object model you'll get 
identical results I believe, or am I missing something...?

Tom

Re: namespace prefix question

Posted by Jan Delannoy <ja...@gmail.com>.
Hi again,

Another question about namespaces in Axis: can I force Axis to use
explicit namespace prefixes instead of default namespaces? What I
would like is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:product="http://www.example.com/product">
    <soapenv:Body>
        <product:GetProduct >TEST1234</product:GetProduct>
    </soapenv:Body>
</soapenv:Envelope>

instead of:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <GetProduct xmlns="http://www.example.com/product">TEST1234</GetProduct>
    </soapenv:Body>
</soapenv:Envelope>

This last message is what Axis is generating for me now.

I would really appreciate it if someone could help me out with this,
even just letting me know that this isn't possible would already be
helpfull...

Many thanks,
Jan

PS: My old question (see below) is also still open...


On 5/25/05, Jan Delannoy <ja...@gmail.com> wrote:
> Hi,
> 
> I'm using an Axis generated stub class to call a web service. The
> generated messages use namespace prefixes like ns1, ns2, ns3, etc.
> even when it's the same namespace.  Can I force Axis to use a
> namespace prefix of my choice for a given namespace? I'm using Axis
> 1.2 final.
> 
> Many thanks,
> Jan
>

Re: namespace prefix question

Posted by Jan Delannoy <ja...@gmail.com>.
Thanks, Mark.  I'm afraid your suspicion is correct, though.  I looked
into this SerializationContext class and it looks like the right place
indeed, except that there doesn't seem to be a way to configure this
SerializationContext using the createCall - invoke way of calling a
service... Looks like I'll have to go with the XSLT transformation for
now.

Regards,
Jan


On 5/26/05, Mark Ford <ma...@active-endpoints.com> wrote:
> The only place where I've seen something like this is in the
> SerializationContext.getPrefixForURI(String uri, String defaultPrefix). When
> calling this, you'll get the existing prefix mapped to the namespace or the
> default prefix you passed in. If you passed null for the default and there
> is no existing mapping, then you'll get a generated prefix of the form "ns"
> + counter.
> 
> This worked out well for me since I'm using the axis serialization classes
> directly as opposed to generated stubs. I'm not sure if it's much help to
> you though.
> 
> -----Original Message-----
> From: Jan Delannoy [mailto:janpiano@gmail.com]
> Sent: Wednesday, May 25, 2005 12:46 PM
> To: axis-user@ws.apache.org
> Subject: namespace prefix question
> 
> Hi,
> 
> I'm using an Axis generated stub class to call a web service. The generated
> messages use namespace prefixes like ns1, ns2, ns3, etc.
> even when it's the same namespace.  Can I force Axis to use a namespace
> prefix of my choice for a given namespace? I'm using Axis
> 1.2 final.
> 
> Many thanks,
> Jan
> 
> 
>

RE: namespace prefix question

Posted by Mark Ford <ma...@active-endpoints.com>.
The only place where I've seen something like this is in the
SerializationContext.getPrefixForURI(String uri, String defaultPrefix). When
calling this, you'll get the existing prefix mapped to the namespace or the
default prefix you passed in. If you passed null for the default and there
is no existing mapping, then you'll get a generated prefix of the form "ns"
+ counter.

This worked out well for me since I'm using the axis serialization classes
directly as opposed to generated stubs. I'm not sure if it's much help to
you though.

-----Original Message-----
From: Jan Delannoy [mailto:janpiano@gmail.com] 
Sent: Wednesday, May 25, 2005 12:46 PM
To: axis-user@ws.apache.org
Subject: namespace prefix question

Hi,

I'm using an Axis generated stub class to call a web service. The generated
messages use namespace prefixes like ns1, ns2, ns3, etc.
even when it's the same namespace.  Can I force Axis to use a namespace
prefix of my choice for a given namespace? I'm using Axis
1.2 final.

Many thanks,
Jan