aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Document/literal web service" Watch "Document/literal web service" New topic
Author

Document/literal web service

Ankur Si
Greenhorn

Joined: Dec 02, 2005
Posts: 23
Hi,
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 PurchaseOrderService.java. It throws error -


The code for the PurchaseOrderService.java 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.

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

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
Bartender

Joined: Aug 19, 2005
Posts: 2906
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 ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Ankur Si
Greenhorn

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.

Ankur
Jimmy Ho
Ranch Hand

Joined: Jul 31, 2007
Posts: 56
If you're using Eclipse, you can try an alternate method from Axis tools by downloading from: http://www-128.ibm.com/developerworks/eclipse/downloads/

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
Bartender

Joined: Aug 19, 2005
Posts: 2906
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
Greenhorn

Joined: Dec 02, 2005
Posts: 23
Thanks a lot Peer and Jimmy, I'm going to try it out as suggested by you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
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