Does anyone have sample code that shows how to return a custom type from
a capability operation, and then how to retrieve that object from the
client side?
 
For example, I have a BoxType as the return value of a capability
method.  I have a custom BoxTypeSerializer and specified it in muse.xml.
In the server trace, I see the xml data being passed ok to the client.
But, in myclient code, I'm not sure what to write in order to retrieve
this BoxType object properly.
 
The apache-httpd sample only shows how to retrieve a custom type as a
resource property by calling WsResourceClient.getPropertyAsObject().
But, this can't be used when trying to get the custom type as a return
value of an operation.
 
My client proxy class implements AbstractResourceClient.  The only
methods available for calling resource operations are
invoke(String,Element) and invoke(ProxyHandler,Object[]).  The first
method returns an xml Element, which is not what I want because I'm
expecting a BoxType object.  The second method doesn't make sense on the
client side because the client would not know the reflection info to
pass in the call (which must be specified to ReflectionProxyHandler, the
only implementation of the ProxyHandler interface).  I think ideally,
this should all be hidden from the client, and the only thing the client
needs to know is the resource EPR, and the operation name and
parameters.
 
Here's my server code (using XmlBeans for serialization):
    public class BoxCapability extends AbstractCapability implements
IBoxCapability
    {
        public BoxType boxOperation(int width) throws Exception
        {
            BoxDocument doc = BoxDocument.Factory.newInstance();
            BoxType type = doc.addNewBox();
            type.setWidth(BigInteger.valueOf(width));
            type.setHeight(BigInteger.valueOf(width));
            return type;
        }
    }
 
Here's my incomplete client code:
    public class SimpleResourceClient extends AbstractResourceClient
    {
        public BoxType testBoxOperation(int width) throws SoapFault
        {
            Element body =
XmlUtils.createElement(IBoxCapability.OP_QNAME, new Integer(width));

            BoxType response = ...  // what do I write here???

            return response;
        }
    }
 
 

Reply via email to