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 robert lazarski <ro...@gmail.com> on 2006/07/06 19:05:18 UTC

[axis2] namespace question in wsdl

I've agot a wsdl that's giving me some problems, can someone give a
look at it for me? It seems to validate using eclipse's validator.

I have two namespaces that I'm having a hard time with - tns and ns2 .
When validating a response on the client side, I'm getting:

Error Message: Expected element 'errorMessage' instead of
'errorMessage@http://swaMaragatoNS/types' here in element
findElementoGerenciadoByIdResponse@http://swaMaragatoNS/types

Location of invalid XML: <errorMessage
xmlns="http://swaMaragatoNS/types"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">FRAMEX_ENTITY_NOTFOUND:
Entidade do tipo class
br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
com id 9.999 não pode ser achada</errorMessage>

Here's the soap message the client is getting:

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
/><soapenv:Body><findElementoGerenciadoByIdResponse
xmlns="http://swaMaragatoNS/types"><errorMessage>FRAMEX_ENTITY_NOTFOUND:
Entidade do tipo class
br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
com id 9.999 não pode ser
achada</errorMessage><successErrorCode>-1</successErrorCode></findElementoGerenciadoByIdResponse></soapenv:Body></soapenv:Envelope>

My wsdl is attached. Please help!
Robert
http://www.braziloutsource.com/

Re: [axis2] namespace question in wsdl

Posted by Anne Thomas Manes <at...@gmail.com>.
Robert,

I know that Axis2 1.0 had a bug in it such that it did not
automatically specify elementFormDefault="qualified" in its generated
schemas, but I thought it was fixed. If you are still seeing schemas
generated without elementFormDefault="qualified" in the latest build,
please file another JIRA.

I need to see more information to answer your second question:
- how many schemas do you have?
- what are their targetNamespaces?
- what are the namespace declarations in the schema that defines this element?
- what is the targetNamespace of the schema that defines the ReturnWebBase type?
- what is the targetNamespace of the schema that defines the
ElementoGerenciadoComplexo type?

If both the "tns" and "ns2" prefixes are assigned to the same
namespace, then it doesn't matter. (And that's my assumption, given
that both prefixes work.)

Here... I'll give you a quick explanation of namespaces:

The purpose of a namespace qualification is to disambiguate two
components of the same name. For example, if you have multiple schemas
that each defines an element called "foo", how do you tell them apart?

    <s:schema
         xmlns:s="http://www.w3.org/2001/XMLSchema"
         targetNamespace="urn:example:foo:1"/>
         <s:element name="foo" type=x:string"/>
     </s:schema>

    <s:schema
         xmlns:s="http://www.w3.org/2001/XMLSchema"
         targetNamespace="urn:example:foo:2"/>
         <s:element name="foo" type=x:int"/>
     </s:schema>

    <s:schema
         xmlns:s="http://www.w3.org/2001/XMLSchema"
         xmlns:ns1="urn:example:foo:1"
         xmlns:ns2="urn:example:foo:2"
         targetNamespace="urn:example:foo:0"/>
         <s:import namespace="urn:example:foo:1"/>
         <s:import namespace="urn:example:foo:2"/>
         <s:element name="foo"/>
            <s:complexType>
                <s:sequence>
                   <s:element ref="ns1:foo"/>
                   <s:element ref="ns2:foo"/>
                </s:sequence>
             </s:complexType>
         </s:element>
     </s:schema>

An instance document of this element could look like this:

     <ns0:foo
         xmlns:ns0="urn:example:foo:0"
         xmlns:ns1="urn:example:foo:1"
         xmlns:ns2="urn:example:foo:2">
           <ns1:foo>some string</ns1:foo>
           <ns2:foo>12345</ns2:foo>
      </ns0:foo>

This is equally valid (but less readable):

     <tns:foo xmlns:tns="urn:example:foo:0">
           <tns:foo xmlns:tns="urn:example:foo:1">some string</tns:foo>
           <tns:foo xmlns:tns="urn:example:foo:2">12345</tns:foo>
      </tns:foo>

In other words, the string used for the prefix is irrelevant -- what
matters is the namespace it's been assigned to and the scope of the
namespace declaration. A namespace declaration applies to the element
its defined in and all that element's children, but you can always
reassign the prefix to a different namespace in a child element.

The default namespace declaration (e.g., xmlns="urn:example:foo:0")
says that all non-explicitly qualified elements belong to the default
namespace. I generally recommend avoiding use of the default namespace
-- especially if you have unqualified elements -- because that forces
you to override the default namespace (e.g., xmlns="") on all
unqualified elements.

So for example, let's say I have this schema:

    <s:schema
         xmlns:s="http://www.w3.org/2001/XMLSchema"
         targetNamespace="urn:example:foobar"/>
         <s:element name="foobar"/>
            <s:complexType>
                <s:sequence>
                   <s:element name="foo" type="s:string"/>
                   <s:element name="bar" type="s:string"/>
                </s:sequence>
             </s:complexType>
         </s:element>
     </s:schema>

Because the schema does not specify elementFormDefault="qualified",
all local elements ("foo" and "bar") are unqualified. A valid instance
of this schema is:

     <tns:foobar xmlns:tns="urn:example:foobar">
        <foo>some string</foo>
        <bar>another string</bar>
     </tns:foobar>

But this is not valid because "foo" and "bar" must be unqualified:

     <foobar xmlns="urn:example:foobar">
        <foo>some string</foo>
        <bar>another string</bar>
     </foobar>

This is valid:

     <foobar xmlns="urn:example:foobar">
        <foo xmlns="">some string</foo>
        <bar xmlns="">another string</bar>
     </foobar>

Hope this helps.

Anne


On 7/7/06, robert lazarski <ro...@gmail.com> wrote:
> Thanks Anne! Using elementFormDefault="qualified" did the trick!
> Thanks for the informative response, I'm trying to get it all to sink
> in ;-) .
>
> I've got two questions please:
>
> 1) Considering this example uses the latest axis2 svn on both the
> client and server side, is this a bug with xmlbeans data binding, ie,
> should I log a jira? Your solutions 2 and 3 gave me the impression
> that perhaps its something axis2 should be handling itself assumming
> that this use case is indeed valid.
>
> 2) Looking at my wsdl I believe that both namespaces should be tns
> here, for example:
>
> <element name="findElementoGerenciadoByIdResponse">
>         <complexType>
>           <complexContent>
>             <extension base="tns:ReturnWebBase">
>               <sequence>
>                 <!-- on Exception there will be no complex object in
> the message -->
>                 <element minOccurs="0" maxOccurs="1"
> name="ElementoGerenciadoComplexo"
> type="tns:ElementoGerenciadoComplexo"/>
>               </sequence>
>             </extension>
>           </complexContent>
>         </complexType>
>       </element>
>
> But changing this to my namespace ns2 also works:
>
>                 <element minOccurs="0" maxOccurs="1"
> name="ElementoGerenciadoComplexo"
> type="ns2:ElementoGerenciadoComplexo"/>
>
> I'm in doubt what is correct or if it matters in this case.
>
> Thanks!
> Robert
> http://www.braziloutsource.com/
>
>
>
> On 7/6/06, Anne Thomas Manes <at...@gmail.com> wrote:
> > Your response message does not match your schema definition.
> > - Your schema does not specify elementFormDefault="qualified";
> > therefore, all local elements must be unqualified.
> > - Your response message defines a default namespace; therefore, all
> > non-explicitly qualified elements are qualified by the default
> > namespace.
> >
> > You have a number of options:
> >
> > 1. Add elementFormDefault="qualified" to your schema (best option).
> >
> > 2. Don't change the schema, but specify an explicit namespace in your
> > response message rather than a default namespace, e.g.:
> >
> > <?xml version='1.0' encoding='utf-8'?>
> > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> > <soapenv:Header/>
> > <soapenv:Body>
> > <ns:findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
> > <errorMessage>FRAMEX_ENTITY_NOTFOUND:
> > Entidade do tipo class
> > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > com id 9.999 não pode ser
> > achada</errorMessage>
> > <successErrorCode>-1</successErrorCode>
> > </ns:findElementoGerenciadoByIdResponse>
> > </soapenv:Body>
> > </soapenv:Envelope>
> >
> > 2. Don't change the schema, and don't specify an explicit namespace in
> > your response message, but override the default namespace in the local
> > elements, e.g.:
> >
> > <?xml version='1.0' encoding='utf-8'?>
> > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> > <soapenv:Header/>
> > <soapenv:Body>
> > <findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
> > <errorMessage xmlns="">FRAMEX_ENTITY_NOTFOUND:
> > Entidade do tipo class
> > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > com id 9.999 não pode ser
> > achada</errorMessage>
> > <successErrorCode xmlns="">-1</successErrorCode>
> > </ns:findElementoGerenciadoByIdResponse>
> > </soapenv:Body>
> > </soapenv:Envelope>
> >
> > Anne
> >
> > On 7/6/06, robert lazarski <ro...@gmail.com> wrote:
> > > I've agot a wsdl that's giving me some problems, can someone give a
> > > look at it for me? It seems to validate using eclipse's validator.
> > >
> > > I have two namespaces that I'm having a hard time with - tns and ns2 .
> > > When validating a response on the client side, I'm getting:
> > >
> > > Error Message: Expected element 'errorMessage' instead of
> > > 'errorMessage@http://swaMaragatoNS/types' here in element
> > > findElementoGerenciadoByIdResponse@http://swaMaragatoNS/types
> > >
> > > Location of invalid XML: <errorMessage
> > > xmlns="http://swaMaragatoNS/types"
> > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">FRAMEX_ENTITY_NOTFOUND:
> > > Entidade do tipo class
> > > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > > com id 9.999 não pode ser achada</errorMessage>
> > >
> > > Here's the soap message the client is getting:
> > >
> > > <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
> > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
> > > /><soapenv:Body><findElementoGerenciadoByIdResponse
> > > xmlns="http://swaMaragatoNS/types"><errorMessage>FRAMEX_ENTITY_NOTFOUND:
> > > Entidade do tipo class
> > > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > > com id 9.999 não pode ser
> > > achada</errorMessage><successErrorCode>-1</successErrorCode></findElementoGerenciadoByIdResponse></soapenv:Body></soapenv:Envelope>
> > >
> > > My wsdl is attached. Please help!
> > > Robert
> > > http://www.braziloutsource.com/
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] namespace question in wsdl

Posted by robert lazarski <ro...@gmail.com>.
Thanks Anne! Using elementFormDefault="qualified" did the trick!
Thanks for the informative response, I'm trying to get it all to sink
in ;-) .

I've got two questions please:

1) Considering this example uses the latest axis2 svn on both the
client and server side, is this a bug with xmlbeans data binding, ie,
should I log a jira? Your solutions 2 and 3 gave me the impression
that perhaps its something axis2 should be handling itself assumming
that this use case is indeed valid.

2) Looking at my wsdl I believe that both namespaces should be tns
here, for example:

<element name="findElementoGerenciadoByIdResponse">
        <complexType>
          <complexContent>
            <extension base="tns:ReturnWebBase">
              <sequence>
                <!-- on Exception there will be no complex object in
the message -->
                <element minOccurs="0" maxOccurs="1"
name="ElementoGerenciadoComplexo"
type="tns:ElementoGerenciadoComplexo"/>
              </sequence>
            </extension>
          </complexContent>
        </complexType>
      </element>

But changing this to my namespace ns2 also works:

                <element minOccurs="0" maxOccurs="1"
name="ElementoGerenciadoComplexo"
type="ns2:ElementoGerenciadoComplexo"/>

I'm in doubt what is correct or if it matters in this case.

Thanks!
Robert
http://www.braziloutsource.com/



On 7/6/06, Anne Thomas Manes <at...@gmail.com> wrote:
> Your response message does not match your schema definition.
> - Your schema does not specify elementFormDefault="qualified";
> therefore, all local elements must be unqualified.
> - Your response message defines a default namespace; therefore, all
> non-explicitly qualified elements are qualified by the default
> namespace.
>
> You have a number of options:
>
> 1. Add elementFormDefault="qualified" to your schema (best option).
>
> 2. Don't change the schema, but specify an explicit namespace in your
> response message rather than a default namespace, e.g.:
>
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header/>
> <soapenv:Body>
> <ns:findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
> <errorMessage>FRAMEX_ENTITY_NOTFOUND:
> Entidade do tipo class
> br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> com id 9.999 não pode ser
> achada</errorMessage>
> <successErrorCode>-1</successErrorCode>
> </ns:findElementoGerenciadoByIdResponse>
> </soapenv:Body>
> </soapenv:Envelope>
>
> 2. Don't change the schema, and don't specify an explicit namespace in
> your response message, but override the default namespace in the local
> elements, e.g.:
>
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header/>
> <soapenv:Body>
> <findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
> <errorMessage xmlns="">FRAMEX_ENTITY_NOTFOUND:
> Entidade do tipo class
> br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> com id 9.999 não pode ser
> achada</errorMessage>
> <successErrorCode xmlns="">-1</successErrorCode>
> </ns:findElementoGerenciadoByIdResponse>
> </soapenv:Body>
> </soapenv:Envelope>
>
> Anne
>
> On 7/6/06, robert lazarski <ro...@gmail.com> wrote:
> > I've agot a wsdl that's giving me some problems, can someone give a
> > look at it for me? It seems to validate using eclipse's validator.
> >
> > I have two namespaces that I'm having a hard time with - tns and ns2 .
> > When validating a response on the client side, I'm getting:
> >
> > Error Message: Expected element 'errorMessage' instead of
> > 'errorMessage@http://swaMaragatoNS/types' here in element
> > findElementoGerenciadoByIdResponse@http://swaMaragatoNS/types
> >
> > Location of invalid XML: <errorMessage
> > xmlns="http://swaMaragatoNS/types"
> > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">FRAMEX_ENTITY_NOTFOUND:
> > Entidade do tipo class
> > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > com id 9.999 não pode ser achada</errorMessage>
> >
> > Here's the soap message the client is getting:
> >
> > <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
> > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
> > /><soapenv:Body><findElementoGerenciadoByIdResponse
> > xmlns="http://swaMaragatoNS/types"><errorMessage>FRAMEX_ENTITY_NOTFOUND:
> > Entidade do tipo class
> > br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> > com id 9.999 não pode ser
> > achada</errorMessage><successErrorCode>-1</successErrorCode></findElementoGerenciadoByIdResponse></soapenv:Body></soapenv:Envelope>
> >
> > My wsdl is attached. Please help!
> > Robert
> > http://www.braziloutsource.com/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] namespace question in wsdl

Posted by Anne Thomas Manes <at...@gmail.com>.
Your response message does not match your schema definition.
- Your schema does not specify elementFormDefault="qualified";
therefore, all local elements must be unqualified.
- Your response message defines a default namespace; therefore, all
non-explicitly qualified elements are qualified by the default
namespace.

You have a number of options:

1. Add elementFormDefault="qualified" to your schema (best option).

2. Don't change the schema, but specify an explicit namespace in your
response message rather than a default namespace, e.g.:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns:findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
<errorMessage>FRAMEX_ENTITY_NOTFOUND:
Entidade do tipo class
br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
com id 9.999 não pode ser
achada</errorMessage>
<successErrorCode>-1</successErrorCode>
</ns:findElementoGerenciadoByIdResponse>
</soapenv:Body>
</soapenv:Envelope>

2. Don't change the schema, and don't specify an explicit namespace in
your response message, but override the default namespace in the local
elements, e.g.:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<findElementoGerenciadoByIdResponse xmlns:ns="http://swaMaragatoNS/types">
<errorMessage xmlns="">FRAMEX_ENTITY_NOTFOUND:
Entidade do tipo class
br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
com id 9.999 não pode ser
achada</errorMessage>
<successErrorCode xmlns="">-1</successErrorCode>
</ns:findElementoGerenciadoByIdResponse>
</soapenv:Body>
</soapenv:Envelope>

Anne

On 7/6/06, robert lazarski <ro...@gmail.com> wrote:
> I've agot a wsdl that's giving me some problems, can someone give a
> look at it for me? It seems to validate using eclipse's validator.
>
> I have two namespaces that I'm having a hard time with - tns and ns2 .
> When validating a response on the client side, I'm getting:
>
> Error Message: Expected element 'errorMessage' instead of
> 'errorMessage@http://swaMaragatoNS/types' here in element
> findElementoGerenciadoByIdResponse@http://swaMaragatoNS/types
>
> Location of invalid XML: <errorMessage
> xmlns="http://swaMaragatoNS/types"
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">FRAMEX_ENTITY_NOTFOUND:
> Entidade do tipo class
> br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> com id 9.999 não pode ser achada</errorMessage>
>
> Here's the soap message the client is getting:
>
> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
> /><soapenv:Body><findElementoGerenciadoByIdResponse
> xmlns="http://swaMaragatoNS/types"><errorMessage>FRAMEX_ENTITY_NOTFOUND:
> Entidade do tipo class
> br.com.atlantico.maragato.nucleogerencia.model.ElementoGerenciadoTO
> com id 9.999 não pode ser
> achada</errorMessage><successErrorCode>-1</successErrorCode></findElementoGerenciadoByIdResponse></soapenv:Body></soapenv:Envelope>
>
> My wsdl is attached. Please help!
> Robert
> http://www.braziloutsource.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org