This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Document/literal web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Document/literal web service" Watch "Document/literal web service" New topic

Document/literal web service

Ankur Si

Joined: Dec 02, 2005
Posts: 23
I know this forum is the best forum for the Java developers, as lot of gurus around. I got stuck in my project and need urgent help -

I'm developing DOCUMNET/Literal web service on AXIS. When I run java2wsdl on It throws error -

The code for the is given below -

Can someone please help me out how to generate the WSDL in this case using java2Wsdl. I'm using AXIS 1.2

Thanks in advance.

[ July 30, 2007: Message edited by: Bear Bibeault ]
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

Hey, the problem is that you have a custom object aka PurchaseOrder as an argument to the method in the service class. Axis does not know how to serialize it i.e. represent it as a WSDL request message. You need to define a custom serializer for this object. This url may be a kick-start.

apigee, a better way to API!
Peer Reynders

Joined: Aug 19, 2005
Posts: 2921
Document/Literal web services are typically designed WSDL first. I.e. you design your Purchase Order XML Schema, reference the schema in your WSDL and then use WSDL2Java. Then you write the "glue code" to map the generated stubs to your existing objects.
Patterns and Strategies for Building Document-Based Web Services

Custom serialization usually results in RPC/encoded web services.
[ July 31, 2007: Message edited by: Peer Reynders ]
Ankur Si

Joined: Dec 02, 2005
Posts: 23
Hi Nishant and Peer, thanks you so much for sending over your valuable comments.
In mycase I need to generate WSDL file from the Java classes as posted above where I need to run - java2wsdl on AXIS. When I try to run the command java2Wsdl there only I do encounter this error, that forbids me to generate WSDL file.
Could you suggest some good websites where a complete example is given using Object as an argument (like my case), that I can refer for my document/literal type webservices.

Thanks a lot again in advance.

Jimmy Ho
Ranch Hand

Joined: Jul 31, 2007
Posts: 61
If you're using Eclipse, you can try an alternate method from Axis tools by downloading from:

With the WTP (Web Tools Platform), you can (in Eclipse), click on any JavaBean in a Dynamic Web Project, and see an option for "Web Services-->Generate WebService" or something like that. It has the option of using Axis APIs/libraries that you can choose in one of the dialogs that pop up when you do this.

You may have more luck with this. It can also generate the Java proxy to access/test the web service as well.

If you have IBM Rational Application Developer, then this functionality comes automatically, though you may have to 'enable' the web services Capability under Windows-->Preferences.

Good luck...
Peer Reynders

Joined: Aug 19, 2005
Posts: 2921
You have to create a deploy.wsdd (WSDD Reference) for Java2WSDL and in it specify the bean mapping or type mapping for PurchaseOrder.

If your PurchaseOrder class follows JavaBean conventions then you can get away with a beanMapping.
Encoding Your Beans - the BeanSerializer(look for axis/samples/userguide/example5) (Don't forget the -y DOCUMENT option on Java2WSDL (literal is implied for DOCUMENT))

Otherwise you need a typeMapping - this requires you to code your own serializer and deserializer - i.e. you still have to design the XML that is equivalent to your class yourself. Moreover this implies RPC/encoded - not Document/literal.
When Beans Are Not Enough - Custom Serialization
Ankur Si

Joined: Dec 02, 2005
Posts: 23
Thanks a lot Peer and Jimmy, I'm going to try it out as suggested by you.
It is sorta covered in the JavaRanch Style Guide.
subject: Document/literal web service
Similar Threads
Webservices + Jrun
AXIS-JAVA2WSDL ClassNotFoundException
Axis1 (1.4) - Simple client proof of concept - SAXParserException: Content is not allowed in prolog
Log4j in struts
Stored procedure which returns array