GeeCON Prague 2014*
The moose likes Web Services and the fly likes AXIS Generated WSDL file looks wrong. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "AXIS Generated WSDL file looks wrong." Watch "AXIS Generated WSDL file looks wrong." New topic
Author

AXIS Generated WSDL file looks wrong.

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
I have been tryint ot get an example axis web service running and have been having an issue with the following error:

SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.


...and I think I have found the issue but am not sure.

The original example is a simple calculator that add/subtracts, passing in two int values (i1, i2) and returning a single int (result) value. I have ammended the example to pass in a bean containing the two ints and return int.

As I say, since doing this I have been getting the above error, and I think it might be because when I run the following URL:



The generated XML has this within it:



Now it appears to me that it is still trying to use the two ints and return an int, I'd expect it would have had a reference to my new bean. So I guess my question is, where is this WSDL kept or rather what generates it as I think mine is incorrect.

Cheers in advance

KS
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Just an update, just tried restarting my Tomcat and now when I run my CalcClient, I get a

Caused by: java.lang.NoClassDefFoundError: Calculator (wrong name: com/test/axis/Calculator); nested exception is:
java.lang.NoClassDefFoundError: Calculator (wrong name: com/test/axis/Calculator)


error.

The Calculator.class looks like:



I think this still relates to the fact that it is using the TestBean as it was working fine before when it was passing in the two ints and returning an int (now replaced by TestBean)

For reference:



Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Yes, your WSDL is definitely wrong and it is as you suspect.
How did you generate the WSDL in the first place?

You may want to check out this tutorial on how to create an Axis2 web service with NetBeans: http://netbeans.org/kb/docs/websvc/gs-axis.html
Alternatively, if you want to further simplify web service development, you may want to have a look at developing web services with JAX-WS: http://netbeans.org/kb/docs/websvc/jax-ws.html
Best wishes!
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
I had a look at those examples you linked me to, I imagine they would work because like mine they are only passing over standard Objects or types (in this case 'int'), my web service worked when I was passing/returning ints, it was when I replaced them with the TestBean that I started getting problems, it seems Axis is limited to primitive types and Objects?


Gives:
Caused by: Error while compiling: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\services\WEB-INF\jwsClasses\Calculator.javaIWAV0052E Invocation Target Exception creating CalcClient

Why in God's name does Axis find this so difficult to deal with?

Surely there must be someone out there who has successfully used Axis for something useful other than passing strings or ints back and forth... Surely there must be a way Axis can cope with a sodding bean!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Keith SmithA wrote:
Surely there must be someone out there who has successfully used Axis for something useful other than passing strings or ints back and forth... Surely there must be a way Axis can cope with a sodding bean!

Do you really HAVE to use Axis?
It seems that you are putting yourself through a lot of unnecessary pain and wasting time because of having chosen Axis.
Best wishes!
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Not sure what other options there are out there, Axis is just what has been used before in this system (although not with passing a Bean)

If I compile the classes outside of Axis (in Eclipse) I just get the following:
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I played around a little with your service on GlassFish v3 with the following results:
- Overloaded methods are not handled well.
In fact, I recall that overloaded methods are not allowed in WSDLs. The best is to avoid them altogether, giving each method in the endpoint implementation class an unique name.
Adding a @WebMethod annotation and giving each method a unique operation name is not enough.
- No special treatment was needed for the TestBean.
In the XML schema accompanying the generated WSDL, the following complex type was generated:

Using soapUI to test the web service, a request to the addBean method (I renamed the methods taking a bean as parameter) looks like this:

The corresponding response looks like this:


So, my advice is: Rename methods to avoid methods with the same name in the endpoint implementation class and give it another try (if you haven't already done so).
Best wishes!
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Cheers for that update perhaps it's an environment issue as I am using jdk1.6, Axis 1.4 with Tomcat 6, I will keep looking into it.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Aside, for custom object types you would need to declare them in the service's deployment descriptor via beanMapping element. For the client, you would need to register the class with the service's TypeRegistry and finally make you have also registered the serializer and deserializer for the custom object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AXIS Generated WSDL file looks wrong.