Hello Martin,

WSDL2Java creates a template for the impl file for your convenience. All methods with a return value are generated with "return null;" or some primitive value so that they compile. WSDL2Java will not copy the method body from your original class.

Note that actually the idea when you start with a Java class is that you start with an interface (no method bodies), use Java2WSDL to generate a WSDL, then use WSDL2Java to generate the server-side interface and a template in which you fill the method bodies.

Although Java2WSDL allows you to specify a concrete class (not interface) as input interface, it treats it as an interface (i.e. does not look at the methods' bodies, decompile them and copy the source into the generated impl file's method bodies).

The WSDL defines the interface of your web service. Therefore, it is not strange to lose your method implementations in the Java->WSDL->Java conversions.

Regards,
Dies


Martin Wunderlich wrote:
Dear all,

Further to my recent problems with creating a simple web service and
getting only null values as return values (see below), I seem to have
located the problem.

WSDL2Java, which creates the required server-side files, doesn't seem
to implement the original method properly. In particular, the file
<MyClass>SoapBindingImpl.java, where the actual method implementation
is located, doesn't seem to be correct. For instance, I have the
following simple class:

package mypackage;

public class SayHello {
    public java.lang.String hello(java.lang.String input) {
        return ("Hello, " + input");
    }
}

The class SayHelloSoapBindingImpl, which is created by WSDL2Java looks
like this:

package mypackage;

public class SayHelloSoapBindingImpl implements mypackage.SayHello{
    public java.lang.String hello(java.lang.String input) throws 
java.rmi.RemoteException {
        return null;
    }

}

Note the hard-coded null value that is returned instead of the
original implementation of the method. If I change this incorrect
implementation, everything works fine.

Am I missing something here? It seems like a lot of unnecessary extra
work, if I have to recreate all the methods when I start building real web
services. I'd rather avoid that.

Cheers,

Martin


Thanks for the hint. I've managed to generate the test client now.
Everything works fine, except for validating the result I get. The
returned String is still null (which confirms the results of my other
method calls).

I went again through the process of setting up the web service and
generating the code. The only odd thing I noticed is with the
interface for the Java class from which I want to build the service.
The class would be something like myPackage.SayHello; The interface
generated by WSDL2Java has the exact same name, which makes it kinda
hard for the class and the interface to coexist. I don't know, if this
could be relevant.

Cheers,

Martin

http://ws.apache.org/axis/java/reference.html

-t builds testClient

   good luck,



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Martin Wunderlich
Sent: Wednesday, April 05, 2006 3:57 PM
To: Jinyuan Zhou
Subject: Re[2]: Problem using deployed Axis web services

Thanks a lot for the quick replies, Jinyuan.

I checked WSDL2Java for the JUnit option you mentioned, but couldn't
find it.
As for the URL I call the web service with, it's a bit different from
the one you provided. I tried the following:
http://localhost/WSTest/services/SayHello2?method=hello&in0=Bla
and
http://localhost/WSTest/services/SayHello2?method=hello&in=Bla

Neither of this works.

I have also pasted the client code below. This only returns a null
value.

Cheers,

Martin

Reply via email to