PDA

View Full Version : Publishing WebServices with Axis


dadelcas
Dec 12th, 2005, 11:03 AM
Hey guys,

I'm cunrrently trying to publish a class as WebService using Spring and Axis. I'm getting some problems doing that:

This is my ApplicationContext.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Servicios -->
<bean id="wstest.service.facade.GarageServiceFacade"
class="wstest.service.implementation.GarageServiceImpleme ntation">
</bean>
</beans>


This is my server-config.wsdd for Axis:

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="adminPassword" value="xxx"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthentication Handler"/>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponde r"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<service name="AdminService" provider="java:MSG">
<parameter name="allowedMethods" value="AdminService"/>
<parameter name="enableRemoteAdmin" value="false"/>
<parameter name="className" value="org.apache.axis.utils.Admin"/>
<namespace>http://xml.apache.org/axis/wsdd/</namespace>
</service>
<service name="GarageService" provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="wstest.service.remote.GarageServiceEndpoint"/>
<beanMapping qname="wstest-app:Carro" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:wstest.modelo.actor.Carro"/>
<beanMapping qname="wstest-app:CarroDeportivo" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:wstest.modelo.actor.CarroDeportivo"/>
<beanMapping qname="wstest-app:CarroLujo" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:ve.com.movilshit.wstest.modelo.actor.CarroLuj o"/>
<beanMapping qname="wstest-app:Garage" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:wstest.modelo.actor.Garage"/>
<beanMapping qname="wstest-app:Moto" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:wstest.modelo.actor.Moto"/>
<beanMapping qname="wstest-app:Vehiculo" xmlns:wstest-app="urn:WSTest" languageSpecificType="java:wstest.modelo.actor.Vehiculo"/>
</service>
<service name="Version" provider="java:RPC">
<parameter name="allowedMethods" value="getVersion"/>
<parameter name="className" value="org.apache.axis.Version"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>


As you see I'm publishing wstest.service.remote.GarageServiceEndpoint that is the following code:

public class GarageServiceEndpoint extends ServletEndpointSupport implements GarageServiceRemote {
private GarageServiceFacade biz;

protected void onInit() {
this.biz = (GarageServiceFacade) getWebApplicationContext().getBean(GarageServiceFa cade.class.getName());
}

public Garage consultarGarage(int identificador) throws RemoteException {
return biz.consultarGarage(identificador);
}

public void insertarGarage(Garage garage) throws RemoteException {
biz.insertarGarage(garage);
}
}


GarageServiceRemote is:

public interface GarageServiceRemote extends Remote {
Garage consultarGarage(int identificador) throws RemoteException;
void insertarGarage(Garage garage) throws RemoteException;
}


GarageServiceFacade is:

//ServiceFacade is a dummy interface by now (it's empty)
public interface GarageServiceFacade extends ServiceFacade {
Garage consultarGarage(int identificador);
void insertarGarage(Garage garage);
}


and GarageServiceImplementation is:

public class GarageServiceImplementation implements GarageServiceFacade {

public Garage consultarGarage(int identificador) {
Moto moto = new Moto();
moto.setMaca("Honda");
moto.setPlaca("ABC-123");
moto.setSerial("123456");

CarroDeportivo deportivo = new CarroDeportivo();
deportivo.setCaballosFuerza(250);
deportivo.setCantidadVelocidades(6);
deportivo.setPlaca("ABC-456");
deportivo.setSerial("123457");

CarroLujo lujo = new CarroLujo();
lujo.setTipoTransmision("Triptronic");
lujo.setPlaca("ABC-789");
lujo.setSerial("123458");

Vehiculo[] v = {moto, deportivo, lujo};

Garage g = new Garage();
g.setIdentificador(identificador);
g.setFechaCrecion(new Date());
g.setVahiculos(v);
return g;
}

public void insertarGarage(Garage garage) {
System.out.println(">>>>>>>>>>>>>>>>> garage = " + garage);
}
}


When I do this and I try to get access to GarageService?WSDL the server does nothing and after a while an error 500 is shown. If I publish GarageServiceImplementation directly in Axis, it works fine. Using Spring is the problem. I don't know if I'm missing something.

I'm using OC4J 10.1.2.0 as application server with a newest version of xmlparserv2.jar file. Don't care about the classes with name in spanish, they are the data-model I'm using for testing WebServices with Spring.

Please give me some help.

Thanks in advance