Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Document/literal web service

 
Ankur Si
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Peer and Jimmy, I'm going to try it out as suggested by you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic