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 José Antonio Sánchez <ge...@gmail.com> on 2007/09/07 11:57:33 UTC
[Axis2] Strange error parsing databinding
Hello, I'm developing a web service specification with Axis2 1.3 and
I've generated the code using ADB. That specification has a type B
that extends type A and in some circumstances I want to convert an
object of type A to B so I did something like:
elem = A.getContent().getOMElement(B.name,factory);
B.parse(elem);
But I got an exception saying:
Unexpected subelement b
where b B.name.localpart.
To get it better, I have the following code:
RegistrationContext ctx = new RegistrationContext();
RegistrationContextType ctxContent = new RegistrationContextType();
ContextIdentifierType ctxId = new ContextIdentifierType();
ctxId.setAnyURI(new URI("http://adapt20/0"));
ctxContent.setContextIdentifier(ctxId);
ServiceRefType regSrvc = new ServiceRefType();
regSrvc.setExtraElement(AddressingUtils.eprToOM(new
EndpointReference("http://localhost/registration")));
ctxContent.setRegistrationService(regSrvc );
ctx.setRegistrationContext(ctxContent);
OMElement regCtxElem = ctx.getOMElement(null, OMAbstractFactory.getOMFactory());
System.out.println("Created registration context element:");
System.out.println(regCtxElem.toString());
RegistrationContext newRegCtx =
RegistrationContext.Factory.parse(regCtxElem.getXMLStreamReader());
So what I'm doing is basically creating an object of type B, getting
an OMElement from it and then parsing it through B.Factory.parse
method. It should work but I get the following exception:
java.lang.Exception: org.apache.axis2.databinding.ADBException:
Unexpected subelement registrationContext
at org.oasis.wscaf.types.wscf.RegistrationContextType$Factory.parse(RegistrationContextType.java:1103)
at org.oasis.wscaf.types.wscf.RegistrationContext$Factory.parse(RegistrationContext.java:307)
at org.oasis.wscaf.tests.DatabindingTest.main(DatabindingTest.java:52)
Caused by: org.apache.axis2.databinding.ADBException: Unexpected
subelement registrationContext
at org.oasis.wscaf.types.wscf.RegistrationContextType$Factory.parse(RegistrationContextType.java:907)
... 2 more
Which is strange since registrationContext is the local name of
RegistrationContext class.
I cannot use the getPullParser method because of this bug:
https://issues.apache.org/jira/browse/AXIS2-3028
So I'm doing this through the getOMElement method.
Is it a bug? Should I open a JIRA issue or am I doing something wrong?
--
Saludos.
José Antonio Sánchez
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [Axis2] Strange error parsing databinding
Posted by Amila Suriarachchi <am...@gmail.com>.
On 9/7/07, José Antonio Sánchez <ge...@gmail.com> wrote:
>
> Hello, I'm developing a web service specification with Axis2 1.3 and
> I've generated the code using ADB. That specification has a type B
> that extends type A and in some circumstances I want to convert an
> object of type A to B so I did something like:
>
> elem = A.getContent().getOMElement(B.name,factory);
> B.parse(elem);
>
> But I got an exception saying:
> Unexpected subelement b
>
> where b B.name.localpart.
>
> To get it better, I have the following code:
>
> RegistrationContext ctx = new RegistrationContext();
>
> RegistrationContextType ctxContent = new RegistrationContextType();
> ContextIdentifierType ctxId = new ContextIdentifierType();
> ctxId.setAnyURI(new URI("http://adapt20/0"));
> ctxContent.setContextIdentifier(ctxId);
>
> ServiceRefType regSrvc = new ServiceRefType();
> regSrvc.setExtraElement(AddressingUtils.eprToOM(new
> EndpointReference("http://localhost/registration")));
> ctxContent.setRegistrationService(regSrvc );
> ctx.setRegistrationContext(ctxContent);
>
> OMElement regCtxElem = ctx.getOMElement(null,
> OMAbstractFactory.getOMFactory());
why you have given null?
System.out.println("Created registration context element:");
> System.out.println(regCtxElem.toString());
are you getting the correct serialized string here?
RegistrationContext newRegCtx =
> RegistrationContext.Factory.parse(regCtxElem.getXMLStreamReader());
>
> So what I'm doing is basically creating an object of type B, getting
> an OMElement from it and then parsing it through B.Factory.parse
> method. It should work but I get the following exception:
>
> java.lang.Exception: org.apache.axis2.databinding.ADBException:
> Unexpected subelement registrationContext
> at
> org.oasis.wscaf.types.wscf.RegistrationContextType$Factory.parse(
> RegistrationContextType.java:1103)
> at org.oasis.wscaf.types.wscf.RegistrationContext$Factory.parse(
> RegistrationContext.java:307)
> at org.oasis.wscaf.tests.DatabindingTest.main(DatabindingTest.java
> :52)
> Caused by: org.apache.axis2.databinding.ADBException: Unexpected
> subelement registrationContext
> at
> org.oasis.wscaf.types.wscf.RegistrationContextType$Factory.parse(
> RegistrationContextType.java:907)
> ... 2 more
Can you send your schma part for this or any schema part which reproduces
the error?. So that I can generate the code and check your issue.
Which is strange since registrationContext is the local name of
> RegistrationContext class.
>
> I cannot use the getPullParser method because of this bug:
> https://issues.apache.org/jira/browse/AXIS2-3028
> So I'm doing this through the getOMElement method.
>
> Is it a bug? Should I open a JIRA issue or am I doing something wrong?
>
>
> --
> Saludos.
> José Antonio Sánchez
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
--
Amila Suriarachchi,
WSO2 Inc.