You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by br...@paraware.com on 2001/12/05 22:26:02 UTC
SOAP is trying to Instantiate the Interface
We've implemented a service with the following interface:
com.xyz.Response execute(com.xyz.Command);
Where xyz.Response is an interface containing a method: Object getValue
and xyz.Command is an interface containing a method: xyz.Response
execute()
We are sending over Commands that implement this interface via SOAP over
HTTP.
We've created a command/response pair that implement the above interfaces.
Our client creates the following entries in the SoapMappingRegistry:
smr.mapTypes(encodingStyleURI, new QName("urn:xyz", "Response"),
xyz.Response.class, beanSer, beanSer);
smr.mapTypes(encodingStyleURI, new QName("urn:xyz", "Command"),
xyz.Command.class, beanSer, beanSer);
We set our parameter as:
params.addElement(new Parameter("CountCommand", Command.class, toSend,
encodingStyleURI));
where toSend is an instance of xyz.CountCommand
and
When we do this however, Instead of using the CountCommand mapping (via
toSend), it uses the Command mapping and then throws an exception on the
server saying it can deserialize it because the Service can't find the
serializer:
java.io.IOException: Generated fault:
Fault Code = SOAP-ENV:Client Fault String = Unable to instantiate
'xyz.Command': null
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
java.io.IOException(java.lang.String)
xyz.Response xyz.SoapConduit.sendCommand(xyz.Command)
void xyz.TestCommandImpl.main(java.lang.String [])
Well, I wouldn't expect it to try to implement Command (an interface).
If I modify the code to include mappings for the Command and Response (and
likewise put mappings on the server side) AND to add the parameter using:
params.addElement(new Parameter("CountCommand", CountCommand.class,
toSend, encodingStyleURI));
NOTICE the CountCommand.class instead of just specifying the interface.
The Call object tries to unmarshall the CountResponse (which my
CountCommand creates in the execute method) as a Response object and
throws a similar
error to that above of:
java.io.IOException: Caught SOAPException (SOAP-ENV:Client): Unable to
instantiate 'xyz.Response': null
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
java.io.IOException(java.lang.String)
xyz.Response xyz.SoapConduit.sendCommand(xyzCommand)
void xyz.TestCommandImpl.main(java.lang.String [])
Again it's trying to deserialize the Response into the Interface and NOT
the class.
The real kicker is that I looked in the code and it KNOWs about the Type
(Response) and the Class (CountResponse). So why doesn't it try to
instantiate CountResponse instead? And why did I have to Modify my
outgoing params to say CountCommand.class (the implementation) instead of
Command.class (the interface).
Thanks,
Brian Bonner