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 Dave MacLean <Da...@businessobjects.com> on 2006/05/13 02:17:47 UTC

[Axis2 1.0] Missing namespace on subelement

Hello everyone,
We're running into a bit of trouble since we moved from axis2 0.95 to
1.0.

The below all worked fine on 0.95:

The complex type in question is defined in the wsdl as:


<s:complexType name="Credential">
	<s:sequence/>
</s:complexType>

<s:complexType name="EnterpriseCredential">
<s:complexContent>
	<s:extension base="s0:Credential">
		<s:sequence/>
		<s:attribute name="Login" type="s:string"
use="required"/>
		<s:attribute name="Password" type="s:string"
use="optional"/>
		<s:attribute name="Locale" type="s:string"
use="optional"/>
		<s:attribute name="TimeZone" type="s:string"
use="optional"/>
		<s:attribute name="Domain" type="s:string"
use="optional"/>
		<s:attribute name="AuthType" type="s:string"
use="optional"/>
	</s:extension>
</s:complexContent>
</s:complexType>


In the provider's skeleton, we have the following:

    public com.businessobjects.dsws.session.LoginResponseDocument login(
        com.businessobjects.dsws.session.LoginDocument param12)
        throws
com.businessobjects.dsws.session.SessionSkeleton.DSWSExceptionException,
RemoteException {
		Login obj = param12.getLogin();
		Credential cred = obj.getCredential();


The problem is, on the getCredential() call, we actually get back an
object of type Credential (base class) when the method was invoked with
an enterprise credential.  So that further on, on the line:

EnterpriseCredential enterpriseCredential = (EnterpriseCredential) cred;

We get a class cast exception.

Tracing through a bit with the SOAPMonitor, we noticed that the xml
envelope actually ends up looking like:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<login xmlns="session.dsws.businessobjects.com">
<credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Password="" Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
Login="administrator" />
</login>
</soapenv:Body>
</soapenv:Envelope>

Where the namespace definition of "ses" is clearly missing.  If you
trace through the deserialization code a bit, this is why the object
comes back as the base class instead of the extended type.

Once thing interesting one of our developer's noticed, is that if, on
the consumer side, you add the lines:

            XmlOptions op1 = new XmlOptions();
            op1.setSaveNamespacesFirst();
            m_credential =
EnterpriseCredential.Factory.newInstance(op1);

At the time you create the credential, it seems that *some of the time*
this fixes the problem, so that the xml appears as:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<login xmlns="session.dsws.businessobjects.com">
<credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ses="session.dsws.businessobjects.com" Password=""
Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
Login="administrator" />
</login>
</soapenv:Body>
</soapenv:Envelope>

But only some of the time.

Is it possible there's a race condition here and that somehow the
attribute list is getting overwritten, or are we doing something wrong?

Thanks in advance,

Dave

Re: [Axis2 1.0] Missing namespace on subelement

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi,
I think the problem is in the use of the type attribute where the
value is actually qualified. The namespace (that refers to the prefix
mentioned in the value) will not be declared unless it was forcefully
done!
Most probably the solution for you is to use the newXMLStreamReader
method passing an options object. you will find this method in the
generated toOM methods for the relevant class.
My understanding is that you can pass an extra namespace map using the
	setLoadAdditionalNamespaces(Map nses) method through the options
object. that should do the trick

Ajith

On 5/13/06, Dave MacLean <Da...@businessobjects.com> wrote:
> Hello everyone,
> We're running into a bit of trouble since we moved from axis2 0.95 to
> 1.0.
>
> The below all worked fine on 0.95:
>
> The complex type in question is defined in the wsdl as:
>
>
> <s:complexType name="Credential">
>         <s:sequence/>
> </s:complexType>
>
> <s:complexType name="EnterpriseCredential">
> <s:complexContent>
>         <s:extension base="s0:Credential">
>                 <s:sequence/>
>                 <s:attribute name="Login" type="s:string"
> use="required"/>
>                 <s:attribute name="Password" type="s:string"
> use="optional"/>
>                 <s:attribute name="Locale" type="s:string"
> use="optional"/>
>                 <s:attribute name="TimeZone" type="s:string"
> use="optional"/>
>                 <s:attribute name="Domain" type="s:string"
> use="optional"/>
>                 <s:attribute name="AuthType" type="s:string"
> use="optional"/>
>         </s:extension>
> </s:complexContent>
> </s:complexType>
>
>
> In the provider's skeleton, we have the following:
>
>     public com.businessobjects.dsws.session.LoginResponseDocument login(
>         com.businessobjects.dsws.session.LoginDocument param12)
>         throws
> com.businessobjects.dsws.session.SessionSkeleton.DSWSExceptionException,
> RemoteException {
>                 Login obj = param12.getLogin();
>                 Credential cred = obj.getCredential();
>
>
> The problem is, on the getCredential() call, we actually get back an
> object of type Credential (base class) when the method was invoked with
> an enterprise credential.  So that further on, on the line:
>
> EnterpriseCredential enterpriseCredential = (EnterpriseCredential) cred;
>
> We get a class cast exception.
>
> Tracing through a bit with the SOAPMonitor, we noticed that the xml
> envelope actually ends up looking like:
>
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header />
> <soapenv:Body>
> <login xmlns="session.dsws.businessobjects.com">
> <credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> Password="" Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
> Login="administrator" />
> </login>
> </soapenv:Body>
> </soapenv:Envelope>
>
> Where the namespace definition of "ses" is clearly missing.  If you
> trace through the deserialization code a bit, this is why the object
> comes back as the base class instead of the extended type.
>
> Once thing interesting one of our developer's noticed, is that if, on
> the consumer side, you add the lines:
>
>             XmlOptions op1 = new XmlOptions();
>             op1.setSaveNamespacesFirst();
>             m_credential =
> EnterpriseCredential.Factory.newInstance(op1);
>
> At the time you create the credential, it seems that *some of the time*
> this fixes the problem, so that the xml appears as:
>
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header />
> <soapenv:Body>
> <login xmlns="session.dsws.businessobjects.com">
> <credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ses="session.dsws.businessobjects.com" Password=""
> Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
> Login="administrator" />
> </login>
> </soapenv:Body>
> </soapenv:Envelope>
>
> But only some of the time.
>
> Is it possible there's a race condition here and that somehow the
> attribute list is getting overwritten, or are we doing something wrong?
>
> Thanks in advance,
>
> Dave
>


-- 
Ajith Ranabahu

Re: [Axis2 1.0] Missing namespace on subelement

Posted by Deepal Jayasinghe <de...@opensource.lk>.
pls create a JIRA

Dave MacLean wrote:

>Hello everyone,
>We're running into a bit of trouble since we moved from axis2 0.95 to
>1.0.
>
>The below all worked fine on 0.95:
>
>The complex type in question is defined in the wsdl as:
>
>
><s:complexType name="Credential">
>	<s:sequence/>
></s:complexType>
>
><s:complexType name="EnterpriseCredential">
><s:complexContent>
>	<s:extension base="s0:Credential">
>		<s:sequence/>
>		<s:attribute name="Login" type="s:string"
>use="required"/>
>		<s:attribute name="Password" type="s:string"
>use="optional"/>
>		<s:attribute name="Locale" type="s:string"
>use="optional"/>
>		<s:attribute name="TimeZone" type="s:string"
>use="optional"/>
>		<s:attribute name="Domain" type="s:string"
>use="optional"/>
>		<s:attribute name="AuthType" type="s:string"
>use="optional"/>
>	</s:extension>
></s:complexContent>
></s:complexType>
>
>
>In the provider's skeleton, we have the following:
>
>    public com.businessobjects.dsws.session.LoginResponseDocument login(
>        com.businessobjects.dsws.session.LoginDocument param12)
>        throws
>com.businessobjects.dsws.session.SessionSkeleton.DSWSExceptionException,
>RemoteException {
>		Login obj = param12.getLogin();
>		Credential cred = obj.getCredential();
>
>
>The problem is, on the getCredential() call, we actually get back an
>object of type Credential (base class) when the method was invoked with
>an enterprise credential.  So that further on, on the line:
>
>EnterpriseCredential enterpriseCredential = (EnterpriseCredential) cred;
>
>We get a class cast exception.
>
>Tracing through a bit with the SOAPMonitor, we noticed that the xml
>envelope actually ends up looking like:
>
><?xml version='1.0' encoding='utf-8'?>
><soapenv:Envelope
>xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
><soapenv:Header />
><soapenv:Body>
><login xmlns="session.dsws.businessobjects.com">
><credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>Password="" Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
>Login="administrator" />
></login>
></soapenv:Body>
></soapenv:Envelope>
>
>Where the namespace definition of "ses" is clearly missing.  If you
>trace through the deserialization code a bit, this is why the object
>comes back as the base class instead of the extended type.
>
>Once thing interesting one of our developer's noticed, is that if, on
>the consumer side, you add the lines:
>
>            XmlOptions op1 = new XmlOptions();
>            op1.setSaveNamespacesFirst();
>            m_credential =
>EnterpriseCredential.Factory.newInstance(op1);
>
>At the time you create the credential, it seems that *some of the time*
>this fixes the problem, so that the xml appears as:
>
><?xml version='1.0' encoding='utf-8'?>
><soapenv:Envelope
>xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
><soapenv:Header />
><soapenv:Body>
><login xmlns="session.dsws.businessobjects.com">
><credential xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:ses="session.dsws.businessobjects.com" Password=""
>Domain="vanyma01" xsi:type="ses:EnterpriseCredential"
>Login="administrator" />
></login>
></soapenv:Body>
></soapenv:Envelope>
>
>But only some of the time.
>
>Is it possible there's a race condition here and that somehow the
>attribute list is getting overwritten, or are we doing something wrong?
>
>Thanks in advance,
>
>Dave
>
>
>  
>

-- 
Thanks,
Deepal
................................................................
~Future is Open~