Hi all,
I need some help on
serialization/deserialization.
I have created a web-service whose code
is given below:
package test.service ;
public class
Service
{
public Data
dataOperation()
{
return new Data()
;
}
}
Data is a simple java
bean.
The definition of Data class is given
below:
package test.service ;
import java.util.Vector
;
public class Data
{
public String
stringMember ;
public Vector vectorMember
;
public Object[]
arrayMember ;
public Data()
{
stringMember = "string"
;
vectorMember = new Vector()
;
vectorMember.addElement(
"vishal batra" ) ;
vectorMember.addElement( "satbir singh" ) ;
vectorMember.addElement( "faisal abhdullah" )
;
vectorMember.addElement( "mohammad shadab" ) ;
arrayMember = new Object[ 2 ] ;
arrayMember[ 0 ] = "first" ;
arrayMember[ 1 ] = new Long( 1234567890 )
;
}
public void
setStringMember( String stringMember )
{
this.stringMember = stringMember
;
}
public String
getStringMember()
{
return stringMember ;
}
public void setVectorMember( Vector
vectorMember )
{
this.vectorMember = vectorMember
;
}
public Vector
getVectorMember()
{
return vectorMember ;
}
public void setArrayMember( Object[] arrayMember
)
{
this.arrayMember = arrayMember
;
}
public Object[]
getArrayMember()
{
return arrayMember ;
}
}
I create the following deployment
descriptor:
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestService"
provider="java:RPC">
<parameter name="className"
value="test.service.Service"/>
<parameter name="allowedMethods"
value="*"/>
</service>
</deployment>
My deployment is sucessful but when I try to
incoke the dataOperation() through client I get a exception in the soap
response complaining that a serializer not found for Data. and my client
throws an internal server exception
So I modify my deployment descriptor as
follows:
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestService"
provider="java:RPC">
<parameter name="className"
value="test.service.Service"/>
<parameter name="allowedMethods"
value="*"/>
<beanMapping
qname="myNS:Data"
xmlns:myNS="urn:TestService"
languageSpecificType="java:test.service.Data"/>
</service>
</deployment>
Finally i get a proper soap response which i have
given below. I have caught this soap response from org.apache.axis.utils.tcpmon tool
HTTP/1.0 200 OK
Content-Type: text/xml;
charset=utf-8
Content-Length: 1478
Servlet-Engine: Tomcat Web Server/3.2.3 (JSP 1.1;
Servlet 2.2; Java 1.3.0; Windows 2000 5.0 x86; java.vendor=Sun Microsystems
Inc.)
<?xml version="1.0"
encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:dataOperationResponse
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="TestService">
<dataOperationReturn
href="#id0"/>
</ns1:dataOperationResponse>
<multiRef id="id0" SOAP-ENC:root="0"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Data"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/:encodingStyle"
xmlns:ns3="urn:TestService">
<stringMember
xsi:type="xsd:string">string</stringMember>
<vectorMember href="#id1"/>
<arrayMember
xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="xsd:anyType[2]">
<item
xsi:type="xsd:string">first</item>
<item
xsi:type="xsd:long">1234567890</item>
</arrayMember>
</multiRef>
<multiRef
id="id1" SOAP-ENC:root="0"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns4:Vector" xmlns:ns4="http://xml.apache.org/xml-soap"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<item xsi:type="xsd:string">vishal batra</item>
<item xsi:type="xsd:string">satbir singh</item>
<item xsi:type="xsd:string">faisal
abhdullah</item>
<item
xsi:type="xsd:string">mohammad shadab</item>
</multiRef>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But my client is still giving me an
exception:
org.xml.sax.SAXException: Deserializing parameter
'dataOperationReturn': could
not find deserializer for type
urn:TestService:Data
at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:227)
at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:831)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:199)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:589)
at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:224)
at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:248)
at
org.apache.axis.client.Call.invoke(Call.java:1701)
at
org.apache.axis.client.Call.invoke(Call.java:1608)
at
org.apache.axis.client.Call.invoke(Call.java:1169)
at test.service.Client.main(test/service/Client.java:29)
Exception in thread "main" org.xml.sax.SAXException:
Deserializing parameter 'da
taOperationReturn': could not find
deserializer for type urn:TestService:Data
org.xml.sax.SAXException:
Deserializing parameter 'dataOperationReturn': could
not find
deserializer for type
urn:TestService:Data
at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:227)
at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:831)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:199)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:589)
at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:224)
at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:248)
at
org.apache.axis.client.Call.invoke(Call.java:1701)
at
org.apache.axis.client.Call.invoke(Call.java:1608)
at
org.apache.axis.client.Call.invoke(Call.java:1169)
at
test.service.Client.main(test/service/Client.java:29)
Please help me on this on this.
need desperately
Vishal