Hi,
I am new in Axis and
web services and I am facing a problem with the client implementation of a
webservice that I can not solve.
I have my own bean
as follows:
-----------------------------------------------
public class
MyStruct {
private String a;
private String b;
private String a;
private String b;
public String
geta(){return a;}
public String getb(){return b;}
public void seta(String na){a=na;}
public void setb(String nb){b=nb;}
}
public String getb(){return b;}
public void seta(String na){a=na;}
public void setb(String nb){b=nb;}
}
--------------------------------------------------
The service is coded
as follows:
//check if a service
receives properly a struct passed in a SOAP message.
//assumed struct with 2 String components
//assumed struct with 2 String components
public class StructTest2
{
public MyStruct serviceMethod(MyStruct s)
{
String aux="";
aux=s.geta();
s.seta(s.getb());
s.setb(aux);
return s;
}
}
-----------------------------------------
The
WSDL for this service once deployed in Axis apears at the end of this
mail.
-------------------------------------------
The wsdd file
contents are the following:
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service
name="StructTest2" provider="java:RPC">
<parameter name="className" value="StructTest2"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:MyStruct" xmlns:myNS="urn:StructTest2" languageSpecificType="java:MyStruct"/>
</service>
<parameter name="className" value="StructTest2"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:MyStruct" xmlns:myNS="urn:StructTest2" languageSpecificType="java:MyStruct"/>
</service>
</deployment>
-----------------------------
The client has been
encoded as follows:
{
public static void main(String [] args) throws Exception {
String target = "http://localhost:8080/axis/services/StructTest";
MyStruct request = new MyStruct();
MyStruct response;
//
request.seta(args[0]);
request.setb(args[1]);
//response.seta("j");
//response.setb("j");
//
Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "urn:StructTest2", "MyStruct");
//
String result= "OK: ";
try
{
call.registerTypeMapping(MyStruct.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(MyStruct.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(MyStruct.class, qn));
call.setTargetEndpointAddress( new java.net.URL(target) );
call.setOperationName("serviceMethod");
call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType(qn, MyStruct.class);
response = (MyStruct) call.invoke( new Object [] {request});
System.out.println(result + response.geta() + " " + response.getb());
}catch (AxisFault fault){
System.out.println("Error: " + fault.toString());
}
}
}
public static void main(String [] args) throws Exception {
String target = "http://localhost:8080/axis/services/StructTest";
MyStruct request = new MyStruct();
MyStruct response;
//
request.seta(args[0]);
request.setb(args[1]);
//response.seta("j");
//response.setb("j");
//
Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "urn:StructTest2", "MyStruct");
//
String result= "OK: ";
try
{
call.registerTypeMapping(MyStruct.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(MyStruct.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(MyStruct.class, qn));
call.setTargetEndpointAddress( new java.net.URL(target) );
call.setOperationName("serviceMethod");
call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType(qn, MyStruct.class);
response = (MyStruct) call.invoke( new Object [] {request});
System.out.println(result + response.geta() + " " + response.getb());
}catch (AxisFault fault){
System.out.println("Error: " + fault.toString());
}
}
}
The error I get on
executin ( no compilation errors) is the following:
C:\jose\SOAP\argtests\Struct2>javac
StructTest2Client.java
C:\jose\SOAP\argtests\Struct2>java StructTest2Client works
yes
Error: org.xml.sax.SAXException: Deserializing parameter 'arg1': could not find
deserializer for type {urn:StructTest2}MyStruct
Error: org.xml.sax.SAXException: Deserializing parameter 'arg1': could not find
deserializer for type {urn:StructTest2}MyStruct
But I have definrd
the TypeMapping etc...I am lost.
Any one can give me
a piece of advice?
Thanks in
advance,
jose
----WSDL---
<?xml version="1.0" encoding="UTF-8"
?>
- <wsdl:definitions targetNamespace="http://localhost:8080/axis/services/StructTest2"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost:8080/axis/services/StructTest2"
xmlns:intf="http://localhost:8080/axis/services/StructTest2"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns1="urn:StructTest2"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</wsdl:types>
<wsdl:part name="in0"
type="tns1:MyStruct" />
</wsdl:message>
<wsdl:part name="serviceMethodReturn"
type="tns1:MyStruct" />
</wsdl:message>
<wsdl:input message="impl:serviceMethodRequest"
name="serviceMethodRequest" />
<wsdl:output message="impl:serviceMethodResponse"
name="serviceMethodResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdlsoap:operation soapAction="" />
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace"
use="encoded" />
</wsdl:input>
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/StructTest2"
use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdlsoap:address location="http://localhost:8080/axis/services/StructTest2" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
