aspose file tools*
The moose likes Web Services and the fly likes ADB webservice - attributes and elements content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "ADB webservice - attributes and elements content" Watch "ADB webservice - attributes and elements content" New topic
Author

ADB webservice - attributes and elements content

Deepu Arthi
Greenhorn

Joined: Apr 24, 2010
Posts: 4
Hi all,

I am using adb to generate my client class for a webservice.
And xsd for this is as below
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="Em" xmlns:SOAP_ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="Em">
<xsd:complexType name="ECode" mixed="true">
<xsd:attribute name="eType" type="xsd:string"/>
</xsd:complexType>
<xsd:element name="test" type="tns:ECode"/>
</xsd:schema>

The class for Ecode is generated has setter for eType only. however what i want is something like this

<tns:test eType="String" >text</tns:test>

Where i can set the eType as well as a value for test.However if i use Jaxbri I was able to get the setter for both the attribute as well as the content of the element.However the application throws exception when i use ADB based service provider consuming the service whose client which is generated using JAXbri based client.

Any pointers /suggestion to resolve this issue will be helpfull

Oh i am using axis2-1.2

Regards,
Deepu
Deepu Arthi
Greenhorn

Joined: Apr 24, 2010
Posts: 4
Hi all,

This is the error i am getting .

19:25:38,234 INFO [ServiceDeployer] Deploying Web service: version.aar
19:25:39,218 ERROR [AxisServlet] java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamWriter
19:25:39,218 ERROR [ContainerBase] Servlet.service() for servlet AxisServlet threw exception
java.lang.NullPointerException
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

Regards,
Deepu
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi Deepu, No replies so far. So let me take a guess.

You get the NoClassDefFound exception when the code (AxisServlet in this case) is not able to find the class in the classpath. So you have to:

a) find the jar file that has the implementation for javax.xml.stream.XMLStreamWriter, and
b) put that jar file in the WEB-INF/lib directory (for a web app) or somewhere in the application path so it can be found.

I usually do as follows:

1. Go to http://www.findjar.com/ and
2. Enter the class name as the search criteria to get a list of jars where the class is declared or implemented.

Depending on the technology you are using, you will usually find at least one jar in your machine that has what you need. Put that jar in the build path or where some of the other important jars are, and it should work out.

Best of luck Hope that helps.

Srini
Deepu Arthi
Greenhorn

Joined: Apr 24, 2010
Posts: 4
Hi ,

This was the first thing i did.I see that all the required Jar are in place. and even then i am getting the exception

The issue is when i used ADB its not able to create the setter and getter for the following schema properly.

<xsd:complexType name="ECode" mixed="true">
<xsd:attribute name="eType" type="xsd:string"/>
</xsd:complexType>
<xsd:element name="test" type="tns:ECode"/>

Still not able to figure out whats the issue with ADB ! If there is fix for this i am not worried too much about the exception because it was just an alternative.

The classdefnotfound occurs only when i mix up ADB and JAXBRI together in the same application package.But in fact i was just use ADB alone(for bothe creating the client and to create the skeleton for provider) and do not want mix ADB and Jaxbri .

Any thoughts

Regards,
Deepu
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
My apologies. I completely misread your problem.

So the issue seems to be with using mixed content in a schema. And this is my understanding of mixed content http://www.w3schools.com/schema/schema_complex_mixed.asp

I input your schema through xjc (not ADB), and I have the same issue. It does not generate the usual getter/setters. Instead, it generates methods getContent and setContent, and this is somewhat understandable because when we say mixed="true", we are making the structure of the xml variable by adding random data between the xml tags, and it can only generate methods for predictable structures without mixed content inside it. Here is a link I found that might help you: http://blogs.sun.com/mgrebac/entry/handling_extended_mixed_content_in

Now, if you are ok with using JAXB for this, you can see some examples here: http://java.sun.com/javaee/5/docs/api/javax/xml/bind/annotation/XmlMixed.html

This post from 2007 indicates that mixed mode is not supported in ADB. I don't know if that has changed. You can post your question to the axis user group.

In case you haven't already, you can also search the group posts from here. Search for "mixed = true" or something and you will see them.

Do you absolutely have to use ADB or are other alternatives acceptable? And do you have to use mixed=true? Maybe someone with more experience in this can comment or provide a solution.

Best of luck!
- Srini
Deepu Arthi
Greenhorn

Joined: Apr 24, 2010
Posts: 4
Thank you ,This helps a lot.

And java.lang.NoClassDefFoundError also got resolved.It was due to stax.jar's which was causing this issue .

Regards,
Deepu

 
 
subject: ADB webservice - attributes and elements content