You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jawad Kakar <jk...@qovia.com> on 2003/09/25 16:16:47 UTC

new to axis Question about Complex Type

I am new to Soap, and using version 1.1 of axis, my question is about complex type.

Code for the interface.

public class FamilyInterfaceImpl {
	public Family getFamily(){
		Family f = new Family("MyFamily", 5);
		return f;
	}
}

Code for Family Class.
public class Family {
	
	private String familyName;
	private int    numberOfMembers;
	
	public Family(){}
	public Family(String familyName, int numberOfMembers){
		this.familyName = familyName;
		this.numberOfMembers = numberOfMembers;
	}
}

To get the wsdl file I use the following command.

java org.apache.axis.wsdl.Java2WSDL -o family.ws
dl -l"http://localhost:8080/axis/services/soapexample" 
-n urn:soapexample -p"soapexample" urn:soapexample  soapexample.FamilyInterface

where soapexample is the package name.
Now I have to generate the Server-side Wrapper Code and Stubs for Client Access I use the following command.

java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p soapexample.ws family.wsdl

I got 8 file and one of them that I have to overwrite is 

package soapexample.ws;

import soapexample.FamilyInterfaceImpl;

public class SoapexampleSoapBindingImpl implements soapexample.ws.FamilyInterface{
	FamilyInterfaceImpl f = new FamilyInterfaceImpl();
    public soapexample.ws.Family getFamily() throws java.rmi.RemoteException {
        return f.getFamily();
    }

}
This class does not compile, because the  return type is of type soapexample.ws.Family and the method return soapexample.Family. 
Question: How to make soap axis work for complex type


Re: new to axis Question about Complex Type

Posted by Adhamh Findlay <af...@austin.rr.com>.
I've been struggling with Axis code generation too, and in pretty much the
same circumstances.  I've been thinking about writing a howto, so perhaps
this will be the first draft.

All of my classes and interfaces are in the same package, com.adhamh.SOAP
(for example).

First thing I do is use Ant to build my classes.  This puts then in build
directory, and then subdirectories.

So I'd end up with build/com/adhamh/SOAP/<compiled classes here>

When I run Java2WSDL I use this command (I run this from the build
directory):

java org.apache.axis.wsdl.Java2WSDL -o soap.wsdl -l
http://localhost:8080/axis/services/SOAPService -n com.adhamh.SOAP
-p"com.adhamh.SOAP" urn: com.adhamh.SOAP com.adhamh.SOAP.SOAPService

At this point you should validate your WSDL file.  If you are using the
default style (which the above command does) then you won't have problems,
but the wrapped and document styles do not generate valid WSDL.  (Still
trying to determine what effect the LITERAL or ENCODING options do.

Once again in the build directory, I run this command to get my java
classes:

java org.apache.axis.wsdl.WSDL2Java -v -o . -s -p com.adhamh.SOAP soap.wsdl

This command generates new java source files in the com/adhamh/SOAP
directory, right in place with the compiled classes.  At this point delete
the compiled classes in this directory.

Now you will need to merge the classes you created with the classes that
WSDL2Java created.  In your case you take your code from Family and add it
to the Axis generated Family class.  I've got a class hierarchy used by my
service Impl class, so I had to do this for several classes that axis
generates. 

Once this is done you will need to edit the service Impl class (the *Impl
class that Axis generates. Really and truly, you should only write a Service
interface, generate the WSDL, then Java classes, and then add custom code to
the Impl that WSDL2Java has generated).

Now, you'll need to compile the WSDL2Java generated code that you modified.
Some thing like "java com/adhamh/SOAP/*.java"

This is working for me.  Using WSDL2Java to generated code in a different
package was causing me more trouble than it was worth so I just started to
generate in the same package and do the merge.

As others will tell you you can setup an Ant task to do all this.  I haven't
done that yet because I wanted to understand exactly what was going on...

Does this procedure look okay to other people?

Adhamh


On 9/25/03 9:16 AM, "Jawad Kakar" <jk...@qovia.com> wrote:

> I am new to Soap, and using version 1.1 of axis, my question is about complex
> type.
> 
> Code for the interface.
> 
> public class FamilyInterfaceImpl {
> public Family getFamily(){
> Family f = new Family("MyFamily", 5);
> return f;
> }
> }
> 
> Code for Family Class.
> public class Family {
> 
> private String familyName;
> private int    numberOfMembers;
> 
> public Family(){}
> public Family(String familyName, int numberOfMembers){
> this.familyName = familyName;
> this.numberOfMembers = numberOfMembers;
> }
> }
> 
> To get the wsdl file I use the following command.
> 
> java org.apache.axis.wsdl.Java2WSDL -o family.ws
> dl -l"http://localhost:8080/axis/services/soapexample"
> -n urn:soapexample -p"soapexample" urn:soapexample
> soapexample.FamilyInterface
> 
> where soapexample is the package name.
> Now I have to generate the Server-side Wrapper Code and Stubs for Client
> Access I use the following command.
> 
> java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p soapexample.ws
> family.wsdl
> 
> I got 8 file and one of them that I have to overwrite is
> 
> package soapexample.ws;
> 
> import soapexample.FamilyInterfaceImpl;
> 
> public class SoapexampleSoapBindingImpl implements
> soapexample.ws.FamilyInterface{
> FamilyInterfaceImpl f = new FamilyInterfaceImpl();
>   public soapexample.ws.Family getFamily() throws java.rmi.RemoteException {
>       return f.getFamily();
>   }
> 
> }
> This class does not compile, because the  return type is of type
> soapexample.ws.Family and the method return soapexample.Family.
> Question: How to make soap axis work for complex type
> 
>