Hi Jose,
Since you have the WSDL file run it through WSDL2Java and just go through
the *Binding stub. Then you will see how axis sets arguments to the call
object and register serializers/deserializers. It helped me a lot.
Regards,
Dimuthu.
----- Original Message -----
From: Jose Soler
To: [EMAIL PROTECTED]
Sent: Wednesday, September 24, 2003 8:26 PM
Subject: Need help deserializing at the client side
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;
public String geta(){return a;}
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
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">
<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>
</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());
}
}
}
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
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>
- <schema targetNamespace="urn:StructTest2"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="MyStruct">
- <sequence>
<element name="a" nillable="true" type="xsd:string" />
<element name="b" nillable="true" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="serviceMethodRequest">
<wsdl:part name="in0" type="tns1:MyStruct" />
</wsdl:message>
- <wsdl:message name="serviceMethodResponse">
<wsdl:part name="serviceMethodReturn" type="tns1:MyStruct" />
</wsdl:message>
- <wsdl:portType name="StructTest2">
- <wsdl:operation name="serviceMethod" parameterOrder="in0">
<wsdl:input message="impl:serviceMethodRequest"
name="serviceMethodRequest" />
<wsdl:output message="impl:serviceMethodResponse"
name="serviceMethodResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="StructTest2SoapBinding" type="impl:StructTest2">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="serviceMethod">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="serviceMethodRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="serviceMethodResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/StructTest2" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="StructTest2Service">
- <wsdl:port binding="impl:StructTest2SoapBinding" name="StructTest2">
<wsdlsoap:address
location="http://localhost:8080/axis/services/StructTest2" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>