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 Chris Williamson <ch...@wolfram.com> on 2003/09/26 00:20:56 UTC

namespace question

Hello,

I have a question about namespaces while using document style web service...

Say I have a method defined by the schema...

<schema
    targetNamespace="http://www.domain.com/namespace"
    xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="operation">
    <complexType>
      <sequence>
        <element maxOccurs="1" name="text" type="xsd:string"/>
      </sequence>
    </complexType>
  </element>
...
</schema>

It appears that the code that is generated by WSDL2Java generates a message
that would look something like this...

<operation xmlns="http://www.domain.com/namespace">
  <text xmlns="">
    blah
  </text>
</operation>

Why does this add xmlns="" to the text element?  Should this not be there so
that the top level namespace persists?

I want to know this because I am of the opinion that the namespace should
persist to the elements defined inside the element and you should be able to
check against the namespace of these elements on the server.  With the
client adding xmlns="", the namespace is null and I can't check against the
namespace.  Is it acceptable for the namespace to be null or the namespace
defined by targetNamespace?

Thanks for any help,

Chris


RE: namespace question

Posted by Chris Williamson <ch...@wolfram.com>.
Excellent thanks Anne.  That is a big help.

So that means that if the form is qualified it takes on the targetNamespace.
I think I got it.

Thanks,

Chris

> -----Original Message-----
> From: Anne Thomas Manes [mailto:anne@manes.net]
> Sent: Friday, September 26, 2003 3:50 PM
> To: axis-user@ws.apache.org
> Subject: RE: namespace question
>
>
> Sorry I neglected to answer #2:
>
> If elementFormDefault="qualified" then all elements in the schema --
> whether local or global -- are in the targetNamespace, and all
> elements in
> a schema instance must be namespace qualified. If
> elementFormDefault="nonqualified", or if the attribute is not specified,
> then global elements (direct child of the <schema> element) are in the
> targetNamespace, and local elements (descendents of other
> definitions) are
> in no namespace. Local elements in a schema instance must not be
> namespace
> qualified. Note that the default form can be overridden in the
> schema on an
> element-by-element basis using the form attribute (form="qualified" or
> form="unqualified").
>
> Anne
>
> At 11:35 AM 9/26/2003 -0500, you wrote:
> >I have a few followup questions about this.
> >
> >1) What is the preferred way to do this?  Is it preferred to use
> >elementFormDefault="qualified" or not?  Is there anything mentioned about
> >this in ws-i or any other spec that tries to standardize web services?
> >
> >2) So if elementFormDefault="qualified" is not set and the element is a
> >child of the schema root then it should use the
> targetNnamespace?  Otherwise
> >if it is a local element it should not.  If
> elementFormDefault="qualified"
> >is set then all should use the targetNamespace.  Just to make sure.
> >
> >Thanks,
> >
> >Chris
> >
> > > -----Original Message-----
> > > From: Anne Thomas Manes [mailto:anne@manes.net]
> > > Sent: Thursday, September 25, 2003 8:54 PM
> > > To: axis-user@ws.apache.org
> > > Subject: Re: namespace question
> > >
> > >
> > > Per your schema, the element <text> is a local element, which
> > > means that it
> > > should not be namespace qualified. Hence Axis does produce an accurate
> > > realization of your element. Since the <operation> has a default
> > > namespace,
> > > you must use xmlns="" to turn off the default namespace.
> > >
> > > If you added elementFormDefault="qualified" to your <schema>
> > > element, then
> > > all of your local elements would also have qualified names,
> in which case
> > > they would inherit their namespace from their parent element.
> > >
> > > Anne
> > >
> > > At 05:20 PM 9/25/2003 -0500, you wrote:
> > > >Hello,
> > > >
> > > >I have a question about namespaces while using document style
> > > web service...
> > > >
> > > >Say I have a method defined by the schema...
> > > >
> > > ><schema
> > > >     targetNamespace="http://www.domain.com/namespace"
> > > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > > >   <element name="operation">
> > > >     <complexType>
> > > >       <sequence>
> > > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > > >       </sequence>
> > > >     </complexType>
> > > >   </element>
> > > >...
> > > ></schema>
> > > >
> > > >It appears that the code that is generated by WSDL2Java
> > > generates a message
> > > >that would look something like this...
> > > >
> > > ><operation xmlns="http://www.domain.com/namespace">
> > > >   <text xmlns="">
> > > >     blah
> > > >   </text>
> > > ></operation>
> > > >
> > > >Why does this add xmlns="" to the text element?  Should this not
> > > be there so
> > > >that the top level namespace persists?
> > > >
> > > >I want to know this because I am of the opinion that the
> namespace should
> > > >persist to the elements defined inside the element and you
> > > should be able to
> > > >check against the namespace of these elements on the server.
>  With the
> > > >client adding xmlns="", the namespace is null and I can't check
> > > against the
> > > >namespace.  Is it acceptable for the namespace to be null or the
> > > namespace
> > > >defined by targetNamespace?
> > > >
> > > >Thanks for any help,
> > > >
> > > >Chris
> > >
>


RE: namespace question

Posted by Anne Thomas Manes <an...@manes.net>.
Sorry I neglected to answer #2:

If elementFormDefault="qualified" then all elements in the schema -- 
whether local or global -- are in the targetNamespace, and all elements in 
a schema instance must be namespace qualified. If 
elementFormDefault="nonqualified", or if the attribute is not specified, 
then global elements (direct child of the <schema> element) are in the 
targetNamespace, and local elements (descendents of other definitions) are 
in no namespace. Local elements in a schema instance must not be namespace 
qualified. Note that the default form can be overridden in the schema on an 
element-by-element basis using the form attribute (form="qualified" or 
form="unqualified").

Anne

At 11:35 AM 9/26/2003 -0500, you wrote:
>I have a few followup questions about this.
>
>1) What is the preferred way to do this?  Is it preferred to use
>elementFormDefault="qualified" or not?  Is there anything mentioned about
>this in ws-i or any other spec that tries to standardize web services?
>
>2) So if elementFormDefault="qualified" is not set and the element is a
>child of the schema root then it should use the targetNnamespace?  Otherwise
>if it is a local element it should not.  If elementFormDefault="qualified"
>is set then all should use the targetNamespace.  Just to make sure.
>
>Thanks,
>
>Chris
>
> > -----Original Message-----
> > From: Anne Thomas Manes [mailto:anne@manes.net]
> > Sent: Thursday, September 25, 2003 8:54 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: namespace question
> >
> >
> > Per your schema, the element <text> is a local element, which
> > means that it
> > should not be namespace qualified. Hence Axis does produce an accurate
> > realization of your element. Since the <operation> has a default
> > namespace,
> > you must use xmlns="" to turn off the default namespace.
> >
> > If you added elementFormDefault="qualified" to your <schema>
> > element, then
> > all of your local elements would also have qualified names, in which case
> > they would inherit their namespace from their parent element.
> >
> > Anne
> >
> > At 05:20 PM 9/25/2003 -0500, you wrote:
> > >Hello,
> > >
> > >I have a question about namespaces while using document style
> > web service...
> > >
> > >Say I have a method defined by the schema...
> > >
> > ><schema
> > >     targetNamespace="http://www.domain.com/namespace"
> > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > >   <element name="operation">
> > >     <complexType>
> > >       <sequence>
> > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > >       </sequence>
> > >     </complexType>
> > >   </element>
> > >...
> > ></schema>
> > >
> > >It appears that the code that is generated by WSDL2Java
> > generates a message
> > >that would look something like this...
> > >
> > ><operation xmlns="http://www.domain.com/namespace">
> > >   <text xmlns="">
> > >     blah
> > >   </text>
> > ></operation>
> > >
> > >Why does this add xmlns="" to the text element?  Should this not
> > be there so
> > >that the top level namespace persists?
> > >
> > >I want to know this because I am of the opinion that the namespace should
> > >persist to the elements defined inside the element and you
> > should be able to
> > >check against the namespace of these elements on the server.  With the
> > >client adding xmlns="", the namespace is null and I can't check
> > against the
> > >namespace.  Is it acceptable for the namespace to be null or the
> > namespace
> > >defined by targetNamespace?
> > >
> > >Thanks for any help,
> > >
> > >Chris
> >



RE: namespace question

Posted by Chris Williamson <ch...@wolfram.com>.
Yeah I just wasn't sure if there are specific benefits of either way.  I
guess it is message size vs.  stricter validation.

Thanks again.

Chris

> -----Original Message-----
> From: Anne Thomas Manes [mailto:anne@manes.net]
> Sent: Friday, September 26, 2003 12:01 PM
> To: axis-user@ws.apache.org
> Subject: RE: namespace question
>
>
> There's isn't a preferred way to do it. You may design your
> schema however
> you like. When using Doc/literal, the SOAP engine MUST generate SOAP
> messages that conform to the schema.
>
> Anne
>
> At 11:35 AM 9/26/2003 -0500, you wrote:
> >I have a few followup questions about this.
> >
> >1) What is the preferred way to do this?  Is it preferred to use
> >elementFormDefault="qualified" or not?  Is there anything mentioned about
> >this in ws-i or any other spec that tries to standardize web services?
> >
> >2) So if elementFormDefault="qualified" is not set and the element is a
> >child of the schema root then it should use the
> targetNnamespace?  Otherwise
> >if it is a local element it should not.  If
> elementFormDefault="qualified"
> >is set then all should use the targetNamespace.  Just to make sure.
> >
> >Thanks,
> >
> >Chris
> >
> > > -----Original Message-----
> > > From: Anne Thomas Manes [mailto:anne@manes.net]
> > > Sent: Thursday, September 25, 2003 8:54 PM
> > > To: axis-user@ws.apache.org
> > > Subject: Re: namespace question
> > >
> > >
> > > Per your schema, the element <text> is a local element, which
> > > means that it
> > > should not be namespace qualified. Hence Axis does produce an accurate
> > > realization of your element. Since the <operation> has a default
> > > namespace,
> > > you must use xmlns="" to turn off the default namespace.
> > >
> > > If you added elementFormDefault="qualified" to your <schema>
> > > element, then
> > > all of your local elements would also have qualified names,
> in which case
> > > they would inherit their namespace from their parent element.
> > >
> > > Anne
> > >
> > > At 05:20 PM 9/25/2003 -0500, you wrote:
> > > >Hello,
> > > >
> > > >I have a question about namespaces while using document style
> > > web service...
> > > >
> > > >Say I have a method defined by the schema...
> > > >
> > > ><schema
> > > >     targetNamespace="http://www.domain.com/namespace"
> > > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > > >   <element name="operation">
> > > >     <complexType>
> > > >       <sequence>
> > > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > > >       </sequence>
> > > >     </complexType>
> > > >   </element>
> > > >...
> > > ></schema>
> > > >
> > > >It appears that the code that is generated by WSDL2Java
> > > generates a message
> > > >that would look something like this...
> > > >
> > > ><operation xmlns="http://www.domain.com/namespace">
> > > >   <text xmlns="">
> > > >     blah
> > > >   </text>
> > > ></operation>
> > > >
> > > >Why does this add xmlns="" to the text element?  Should this not
> > > be there so
> > > >that the top level namespace persists?
> > > >
> > > >I want to know this because I am of the opinion that the
> namespace should
> > > >persist to the elements defined inside the element and you
> > > should be able to
> > > >check against the namespace of these elements on the server.
>  With the
> > > >client adding xmlns="", the namespace is null and I can't check
> > > against the
> > > >namespace.  Is it acceptable for the namespace to be null or the
> > > namespace
> > > >defined by targetNamespace?
> > > >
> > > >Thanks for any help,
> > > >
> > > >Chris
> > >
>


RE: namespace question

Posted by Anne Thomas Manes <an...@manes.net>.
There's isn't a preferred way to do it. You may design your schema however 
you like. When using Doc/literal, the SOAP engine MUST generate SOAP 
messages that conform to the schema.

Anne

At 11:35 AM 9/26/2003 -0500, you wrote:
>I have a few followup questions about this.
>
>1) What is the preferred way to do this?  Is it preferred to use
>elementFormDefault="qualified" or not?  Is there anything mentioned about
>this in ws-i or any other spec that tries to standardize web services?
>
>2) So if elementFormDefault="qualified" is not set and the element is a
>child of the schema root then it should use the targetNnamespace?  Otherwise
>if it is a local element it should not.  If elementFormDefault="qualified"
>is set then all should use the targetNamespace.  Just to make sure.
>
>Thanks,
>
>Chris
>
> > -----Original Message-----
> > From: Anne Thomas Manes [mailto:anne@manes.net]
> > Sent: Thursday, September 25, 2003 8:54 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: namespace question
> >
> >
> > Per your schema, the element <text> is a local element, which
> > means that it
> > should not be namespace qualified. Hence Axis does produce an accurate
> > realization of your element. Since the <operation> has a default
> > namespace,
> > you must use xmlns="" to turn off the default namespace.
> >
> > If you added elementFormDefault="qualified" to your <schema>
> > element, then
> > all of your local elements would also have qualified names, in which case
> > they would inherit their namespace from their parent element.
> >
> > Anne
> >
> > At 05:20 PM 9/25/2003 -0500, you wrote:
> > >Hello,
> > >
> > >I have a question about namespaces while using document style
> > web service...
> > >
> > >Say I have a method defined by the schema...
> > >
> > ><schema
> > >     targetNamespace="http://www.domain.com/namespace"
> > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > >   <element name="operation">
> > >     <complexType>
> > >       <sequence>
> > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > >       </sequence>
> > >     </complexType>
> > >   </element>
> > >...
> > ></schema>
> > >
> > >It appears that the code that is generated by WSDL2Java
> > generates a message
> > >that would look something like this...
> > >
> > ><operation xmlns="http://www.domain.com/namespace">
> > >   <text xmlns="">
> > >     blah
> > >   </text>
> > ></operation>
> > >
> > >Why does this add xmlns="" to the text element?  Should this not
> > be there so
> > >that the top level namespace persists?
> > >
> > >I want to know this because I am of the opinion that the namespace should
> > >persist to the elements defined inside the element and you
> > should be able to
> > >check against the namespace of these elements on the server.  With the
> > >client adding xmlns="", the namespace is null and I can't check
> > against the
> > >namespace.  Is it acceptable for the namespace to be null or the
> > namespace
> > >defined by targetNamespace?
> > >
> > >Thanks for any help,
> > >
> > >Chris
> >



RE: namespace question

Posted by Chris Williamson <ch...@wolfram.com>.
Gary and Anne,

Thanks for the excellent answers.  I was not aware of this attribute and it
all now makes complete sense.  I was confused because the TerraService web
service (if you have ever seen it) requires qualified namespaces whereas the
axis examples I was working with do not.  And I was beginning to wonder if
it was a problem between the differences of the .net implementation and the
axis implementation.  I am glad it is not.  I checked out the terraservice
wsdl and lo-and-behold it has this attribute set.  Excellent!

Thanks,

Chris

> -----Original Message-----
> From: Anne Thomas Manes [mailto:anne@manes.net]
> Sent: Thursday, September 25, 2003 8:54 PM
> To: axis-user@ws.apache.org
> Subject: Re: namespace question
>
>
> Per your schema, the element <text> is a local element, which
> means that it
> should not be namespace qualified. Hence Axis does produce an accurate
> realization of your element. Since the <operation> has a default
> namespace,
> you must use xmlns="" to turn off the default namespace.
>
> If you added elementFormDefault="qualified" to your <schema>
> element, then
> all of your local elements would also have qualified names, in which case
> they would inherit their namespace from their parent element.
>
> Anne
>
> At 05:20 PM 9/25/2003 -0500, you wrote:
> >Hello,
> >
> >I have a question about namespaces while using document style
> web service...
> >
> >Say I have a method defined by the schema...
> >
> ><schema
> >     targetNamespace="http://www.domain.com/namespace"
> >     xmlns="http://www.w3.org/2001/XMLSchema">
> >   <element name="operation">
> >     <complexType>
> >       <sequence>
> >         <element maxOccurs="1" name="text" type="xsd:string"/>
> >       </sequence>
> >     </complexType>
> >   </element>
> >...
> ></schema>
> >
> >It appears that the code that is generated by WSDL2Java
> generates a message
> >that would look something like this...
> >
> ><operation xmlns="http://www.domain.com/namespace">
> >   <text xmlns="">
> >     blah
> >   </text>
> ></operation>
> >
> >Why does this add xmlns="" to the text element?  Should this not
> be there so
> >that the top level namespace persists?
> >
> >I want to know this because I am of the opinion that the namespace should
> >persist to the elements defined inside the element and you
> should be able to
> >check against the namespace of these elements on the server.  With the
> >client adding xmlns="", the namespace is null and I can't check
> against the
> >namespace.  Is it acceptable for the namespace to be null or the
> namespace
> >defined by targetNamespace?
> >
> >Thanks for any help,
> >
> >Chris
>


RE: namespace question

Posted by Chris Williamson <ch...@wolfram.com>.
Thanks Gary!  That is exactly what I needed to know.  That was very helpful.

Chris

> -----Original Message-----
> From: Gary L Peskin [mailto:garyp@firstech.com]
> Sent: Friday, September 26, 2003 12:25 PM
> To: axis-user@ws.apache.org
> Subject: RE: namespace question
>
>
> Please see my answers below.
>
> Gary
>
> > -----Original Message-----
> > From: Chris Williamson [mailto:chrisw@wolfram.com]
> > Sent: Friday, September 26, 2003 9:35 AM
> > To: axis-user@ws.apache.org
> > Subject: RE: namespace question
> >
> >
> > I have a few followup questions about this.
> >
> > 1) What is the preferred way to do this?  Is it preferred to
> > use elementFormDefault="qualified" or not?  Is there anything
> > mentioned about this in ws-i or any other spec that tries to
> > standardize web services?
>
> I think Anne already answered this.  I'm not aware of any WS-I standard
> about this.  It may be there, I just don't know.
>
> >
> > 2) So if elementFormDefault="qualified" is not set and the
> > element is a child of the schema root then it should use the
> > targetNnamespace?
>
> elementFormDefault does not affect children of the schema root one way or
> the other.  They are always in the targetNamespace specified in the schema
> element.  elementFormDefault only affects descendants of the schema below
> the children.  If set to qualified, the descendent is in the
> targetNamespace.  If set to unqualified, the descendant is not in any
> namespace.  This can be overridden with a form attribute on the descendent
> "element" element.
>
>
> > Otherwise if it is a local element it
> > should not.
>
> I'm not sure what this means.
>
> > If elementFormDefault="qualified" is set then
> > all should use the targetNamespace.  Just to make sure.
>
> Yes.
>
> >
> > Thanks,
> >
> > Chris
> >
> > > -----Original Message-----
> > > From: Anne Thomas Manes [mailto:anne@manes.net]
> > > Sent: Thursday, September 25, 2003 8:54 PM
> > > To: axis-user@ws.apache.org
> > > Subject: Re: namespace question
> > >
> > >
> > > Per your schema, the element <text> is a local element, which means
> > > that it should not be namespace qualified. Hence Axis does
> > produce an
> > > accurate realization of your element. Since the <operation> has a
> > > default namespace,
> > > you must use xmlns="" to turn off the default namespace.
> > >
> > > If you added elementFormDefault="qualified" to your
> > <schema> element,
> > > then all of your local elements would also have qualified names, in
> > > which case they would inherit their namespace from their parent
> > > element.
> > >
> > > Anne
> > >
> > > At 05:20 PM 9/25/2003 -0500, you wrote:
> > > >Hello,
> > > >
> > > >I have a question about namespaces while using document style
> > > web service...
> > > >
> > > >Say I have a method defined by the schema...
> > > >
> > > ><schema
> > > >     targetNamespace="http://www.domain.com/namespace"
> > > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > > >   <element name="operation">
> > > >     <complexType>
> > > >       <sequence>
> > > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > > >       </sequence>
> > > >     </complexType>
> > > >   </element>
> > > >...
> > > ></schema>
> > > >
> > > >It appears that the code that is generated by WSDL2Java
> > > generates a message
> > > >that would look something like this...
> > > >
> > > ><operation xmlns="http://www.domain.com/namespace">
> > > >   <text xmlns="">
> > > >     blah
> > > >   </text>
> > > ></operation>
> > > >
> > > >Why does this add xmlns="" to the text element?  Should this not
> > > be there so
> > > >that the top level namespace persists?
> > > >
> > > >I want to know this because I am of the opinion that the namespace
> > > >should persist to the elements defined inside the element and you
> > > should be able to
> > > >check against the namespace of these elements on the server.  With
> > > >the client adding xmlns="", the namespace is null and I can't check
> > > against the
> > > >namespace.  Is it acceptable for the namespace to be null or the
> > > namespace
> > > >defined by targetNamespace?
> > > >
> > > >Thanks for any help,
> > > >
> > > >Chris
> > >
> >


RE: namespace question

Posted by Gary L Peskin <ga...@firstech.com>.
Please see my answers below.

Gary

> -----Original Message-----
> From: Chris Williamson [mailto:chrisw@wolfram.com] 
> Sent: Friday, September 26, 2003 9:35 AM
> To: axis-user@ws.apache.org
> Subject: RE: namespace question
> 
> 
> I have a few followup questions about this.
> 
> 1) What is the preferred way to do this?  Is it preferred to 
> use elementFormDefault="qualified" or not?  Is there anything 
> mentioned about this in ws-i or any other spec that tries to 
> standardize web services?

I think Anne already answered this.  I'm not aware of any WS-I standard
about this.  It may be there, I just don't know.

> 
> 2) So if elementFormDefault="qualified" is not set and the 
> element is a child of the schema root then it should use the 
> targetNnamespace?

elementFormDefault does not affect children of the schema root one way or
the other.  They are always in the targetNamespace specified in the schema
element.  elementFormDefault only affects descendants of the schema below
the children.  If set to qualified, the descendent is in the
targetNamespace.  If set to unqualified, the descendant is not in any
namespace.  This can be overridden with a form attribute on the descendent
"element" element.


> Otherwise if it is a local element it 
> should not.

I'm not sure what this means.

> If elementFormDefault="qualified" is set then 
> all should use the targetNamespace.  Just to make sure.

Yes.

> 
> Thanks,
> 
> Chris
> 
> > -----Original Message-----
> > From: Anne Thomas Manes [mailto:anne@manes.net]
> > Sent: Thursday, September 25, 2003 8:54 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: namespace question
> >
> >
> > Per your schema, the element <text> is a local element, which means 
> > that it should not be namespace qualified. Hence Axis does 
> produce an 
> > accurate realization of your element. Since the <operation> has a 
> > default namespace,
> > you must use xmlns="" to turn off the default namespace.
> >
> > If you added elementFormDefault="qualified" to your 
> <schema> element, 
> > then all of your local elements would also have qualified names, in 
> > which case they would inherit their namespace from their parent 
> > element.
> >
> > Anne
> >
> > At 05:20 PM 9/25/2003 -0500, you wrote:
> > >Hello,
> > >
> > >I have a question about namespaces while using document style
> > web service...
> > >
> > >Say I have a method defined by the schema...
> > >
> > ><schema
> > >     targetNamespace="http://www.domain.com/namespace"
> > >     xmlns="http://www.w3.org/2001/XMLSchema">
> > >   <element name="operation">
> > >     <complexType>
> > >       <sequence>
> > >         <element maxOccurs="1" name="text" type="xsd:string"/>
> > >       </sequence>
> > >     </complexType>
> > >   </element>
> > >...
> > ></schema>
> > >
> > >It appears that the code that is generated by WSDL2Java
> > generates a message
> > >that would look something like this...
> > >
> > ><operation xmlns="http://www.domain.com/namespace">
> > >   <text xmlns="">
> > >     blah
> > >   </text>
> > ></operation>
> > >
> > >Why does this add xmlns="" to the text element?  Should this not
> > be there so
> > >that the top level namespace persists?
> > >
> > >I want to know this because I am of the opinion that the namespace 
> > >should persist to the elements defined inside the element and you
> > should be able to
> > >check against the namespace of these elements on the server.  With 
> > >the client adding xmlns="", the namespace is null and I can't check
> > against the
> > >namespace.  Is it acceptable for the namespace to be null or the
> > namespace
> > >defined by targetNamespace?
> > >
> > >Thanks for any help,
> > >
> > >Chris
> >
> 


RE: namespace question

Posted by Chris Williamson <ch...@wolfram.com>.
I have a few followup questions about this.

1) What is the preferred way to do this?  Is it preferred to use
elementFormDefault="qualified" or not?  Is there anything mentioned about
this in ws-i or any other spec that tries to standardize web services?

2) So if elementFormDefault="qualified" is not set and the element is a
child of the schema root then it should use the targetNnamespace?  Otherwise
if it is a local element it should not.  If elementFormDefault="qualified"
is set then all should use the targetNamespace.  Just to make sure.

Thanks,

Chris

> -----Original Message-----
> From: Anne Thomas Manes [mailto:anne@manes.net]
> Sent: Thursday, September 25, 2003 8:54 PM
> To: axis-user@ws.apache.org
> Subject: Re: namespace question
>
>
> Per your schema, the element <text> is a local element, which
> means that it
> should not be namespace qualified. Hence Axis does produce an accurate
> realization of your element. Since the <operation> has a default
> namespace,
> you must use xmlns="" to turn off the default namespace.
>
> If you added elementFormDefault="qualified" to your <schema>
> element, then
> all of your local elements would also have qualified names, in which case
> they would inherit their namespace from their parent element.
>
> Anne
>
> At 05:20 PM 9/25/2003 -0500, you wrote:
> >Hello,
> >
> >I have a question about namespaces while using document style
> web service...
> >
> >Say I have a method defined by the schema...
> >
> ><schema
> >     targetNamespace="http://www.domain.com/namespace"
> >     xmlns="http://www.w3.org/2001/XMLSchema">
> >   <element name="operation">
> >     <complexType>
> >       <sequence>
> >         <element maxOccurs="1" name="text" type="xsd:string"/>
> >       </sequence>
> >     </complexType>
> >   </element>
> >...
> ></schema>
> >
> >It appears that the code that is generated by WSDL2Java
> generates a message
> >that would look something like this...
> >
> ><operation xmlns="http://www.domain.com/namespace">
> >   <text xmlns="">
> >     blah
> >   </text>
> ></operation>
> >
> >Why does this add xmlns="" to the text element?  Should this not
> be there so
> >that the top level namespace persists?
> >
> >I want to know this because I am of the opinion that the namespace should
> >persist to the elements defined inside the element and you
> should be able to
> >check against the namespace of these elements on the server.  With the
> >client adding xmlns="", the namespace is null and I can't check
> against the
> >namespace.  Is it acceptable for the namespace to be null or the
> namespace
> >defined by targetNamespace?
> >
> >Thanks for any help,
> >
> >Chris
>


Re: namespace question

Posted by Anne Thomas Manes <an...@manes.net>.
Per your schema, the element <text> is a local element, which means that it 
should not be namespace qualified. Hence Axis does produce an accurate 
realization of your element. Since the <operation> has a default namespace, 
you must use xmlns="" to turn off the default namespace.

If you added elementFormDefault="qualified" to your <schema> element, then 
all of your local elements would also have qualified names, in which case 
they would inherit their namespace from their parent element.

Anne

At 05:20 PM 9/25/2003 -0500, you wrote:
>Hello,
>
>I have a question about namespaces while using document style web service...
>
>Say I have a method defined by the schema...
>
><schema
>     targetNamespace="http://www.domain.com/namespace"
>     xmlns="http://www.w3.org/2001/XMLSchema">
>   <element name="operation">
>     <complexType>
>       <sequence>
>         <element maxOccurs="1" name="text" type="xsd:string"/>
>       </sequence>
>     </complexType>
>   </element>
>...
></schema>
>
>It appears that the code that is generated by WSDL2Java generates a message
>that would look something like this...
>
><operation xmlns="http://www.domain.com/namespace">
>   <text xmlns="">
>     blah
>   </text>
></operation>
>
>Why does this add xmlns="" to the text element?  Should this not be there so
>that the top level namespace persists?
>
>I want to know this because I am of the opinion that the namespace should
>persist to the elements defined inside the element and you should be able to
>check against the namespace of these elements on the server.  With the
>client adding xmlns="", the namespace is null and I can't check against the
>namespace.  Is it acceptable for the namespace to be null or the namespace
>defined by targetNamespace?
>
>Thanks for any help,
>
>Chris



RE: namespace question

Posted by Gary L Peskin <ga...@firstech.com>.
The "text" element is a locally defined element in your schema because it is
declared as a child of the "sequence" element and not as a child of the
"schema" element.  The schema element has an attribute elementFormDefault
whose default value is "unqualified".  In your example, that attribute of
the schema element is not shown so it assumes its default value of
"unqualified".

This means that any locally declared elements are -not- in the
targetNamespace but are instead not in any namespace.  This is indicated by
the xmlns="" attribute.  The top level namespace should not "persist".  If
you want the text element to be in the targetNamespace, you should add an
elementFormDefault="qualified" attribute to your schema element.

Axis is doing the correct thing.

Gary

> -----Original Message-----
> From: Chris Williamson [mailto:chrisw@wolfram.com] 
> Sent: Thursday, September 25, 2003 3:21 PM
> To: axis-user@ws.apache.org
> Subject: namespace question
> 
> 
> Hello,
> 
> I have a question about namespaces while using document style 
> web service...
> 
> Say I have a method defined by the schema...
> 
> <schema
>     targetNamespace="http://www.domain.com/namespace"
>     xmlns="http://www.w3.org/2001/XMLSchema">
>   <element name="operation">
>     <complexType>
>       <sequence>
>         <element maxOccurs="1" name="text" type="xsd:string"/>
>       </sequence>
>     </complexType>
>   </element>
> ...
> </schema>
> 
> It appears that the code that is generated by WSDL2Java 
> generates a message that would look something like this...
> 
> <operation xmlns="http://www.domain.com/namespace">
>   <text xmlns="">
>     blah
>   </text>
> </operation>
> 
> Why does this add xmlns="" to the text element?  Should this 
> not be there so that the top level namespace persists?
> 
> I want to know this because I am of the opinion that the 
> namespace should persist to the elements defined inside the 
> element and you should be able to check against the namespace 
> of these elements on the server.  With the client adding 
> xmlns="", the namespace is null and I can't check against the 
> namespace.  Is it acceptable for the namespace to be null or 
> the namespace defined by targetNamespace?
> 
> Thanks for any help,
> 
> Chris
>