I'm trying to make a web services that takes a Bean for parameter ed returns a Bean
While i'm trying to run the application i got this error
 
--------------------------------
Attenzion: Condizione di Fault
Code: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Description: org.xml.sax.SAXException: Deserializing parameter 'arg1':
could not find deserializer for type {urn:SwitchData}Persona
--------------------------------
   
I know that the exception is thrown when i call the invoke method, so i have a doubt:
 
 
1) The errror is throws by the WS that couldn't deserialize the Bean when it is parameter ( Deserializing parameter 'arg1' )
 
2) or by the return object
 
 
Thanx a lot Ivan
 
This is the code---->
 
Persona.java The Bean
 
package ivan.Persona;
import java.io.*;
 
public class Persona {
 
public Persona ( ) {
nome = "";
cognome = "";
}
 
public void setNome ( String nome ) { this.nome = nome; }
public void setCognome ( String cognome ) { this.cognome = cognome; }
 
public String getNome ( ) { return nome; }
public String getCognome ( ) { return cognome; }
 
public String toString () { return "Nome: " + nome + ", Cognome: " +
cognome; }
 
private String nome, cognome;
}
 
The web services SwitchData.jws
 
import ivan.Persona.*;
 
public class SwitchData {
public Persona switchData ( Persona persona ) {
String nome = persona.getNome();
String cognome = persona.getCognome();
persona.setNome ( cognome );
persona.setCognome ( nome );
return persona;
}
}
 
The deploy
 
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="DataSwitch" provider="java:RPC">
<parameter name="className" value="SwichData"/>
<parameter name="allowedMethods" value="swichData"/>
<beanMapping qname="myNS:Persona" xmlns:myNS="urn:SwitchData"
languageSpecificType="java:ivan.Persona.Persona"/>
</service>
</deployment>
 
and the client PersonaTest.java
 
import ivan.Persona.*;
 
import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
 
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
 
public class PersonaTest {
public final static void main(String args[]) throws Exception {
String nome = "Pippo";
String cognome = "Pluto";
QName qn = new QName( "urn:SwitchData", "Persona" );
if ( args.length == 2 ) {
nome = args [1];
cognome = args [2];
}
Persona persona = new Persona ();
persona.setNome ( nome );
persona.setCognome ( nome );
System.out.println ( "Before: " + persona.toString() );
 
String endpoint = "http://192.168.1.2:8080/axis/SwitchData.jws";
try {
Service service = new Service();
Call call = (Call) service.createCall();
call.registerTypeMapping(Persona.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(Persona.class,
qn),
new
org.apache.axis.encoding.ser.BeanDeserializerFactory(Persona.class, qn));
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("DataSwitch", "switchData"));
call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType ( qn );
persona = (Persona) call.invoke( new Object[] { persona } );
System.out.println ( "After: " + persona.toString() );
}
catch ( AxisFault fault ) {
System.err.println("--------------------------------");
System.err.println("Attenzion: Condizione di Fault");
System.err.println("Code: "+ fault.getFaultCode());
System.err.println("Description: "+ fault.getFaultString());
System.err.println("--------------------------------");
}
 
 
 
}
}

Reply via email to