After some time, I'm back again at my problem trying to directly 
returning XML from a web service. With RPC/encoded I'd get "section 5" 
encoding, but that's not what I want.

I'd like to return XML like this in the SOAP response

<root>
  <child>CHILDVALUE</child>
  <list>
    <item>ITEM1</item>
    <item>ITEM2</item>
  </list>
</root>

I've set up a test project where the serializer fakes this for a dummy 
return value. With rpc/encoded this works partly, that is, I can call 
the web service from a browser and get the result I want. But, of 
course, the result isn't really rpc/encoded, it actually is document 
(or wrapped)/literal. Now, when I change deploy.wsdd to reflect this 
(see below), my serializer isn't found anymore, as the thrown exception 
indicates

java.io.IOException: No serializer found for class 
wsdltest.MyReturnValue in registry 
[EMAIL PROTECTED]
        at 
org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1267)
        at 
org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:778)
...


Further problems are creation of appropriate WSDL, deserialization, and 
generation of client code.

I've looked through the axis samples and searched on the web, but I was 
unable to find an example that demonstrates what I'm trying to do. I'm 
wondering whether it's really so utterly uncommon.


Michael



public class MyService {
    public MyReturnValue test() {
        return new MyReturnValue();
    }
}


public class MyReturnValue {
}


public class MyReturnValueSerializer implements Serializer {

    public String getMechanismType() {
        return Constants.AXIS_SAX;
    }

    public void serialize( QName name, Attributes attribs,
            Object value, SerializationContext context )
            throws IOException {
        context.startElement(name, attribs);

        context.startElement(new QName("child"), null);
        context.writeString("CHILDVALUE");
        context.endElement();
        
        context.startElement(new QName("list"), null);
        
        context.startElement(new QName("item"), null);
        context.writeString("ITEM1");
        context.endElement();

        context.startElement(new QName("item"), null);
        context.writeString("ITEM2");
        context.endElement();
        
        context.endElement();
        
        context.endElement();
    }
    
    public Element writeSchema( Class javaType, Types types )
        throws Exception {
        // TODO
        return null;
    }
}


---->----deploy.wsdd---->----

<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"; 
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
 
  <service name="WsdlTest"
   provider="java:RPC"
   style="wrapped"
   use="literal">
    <parameter name="className" value="wsdltest.MyService"/>
    <parameter name="allowedMethods" value="test"/>

    <typeMapping
     xmlns:ns="http://schuerig.de/wsdltest";
     qname="ns:wsdltest"
     type="java:wsdltest.MyReturnValue"
     serializer="wsdltest.MyReturnValueSerializerFactory"
    />

  </service>
</deployment>

-- 
Michael Schuerig                            This is not a false alarm
mailto:[EMAIL PROTECTED]                         This is not a test
http://www.schuerig.de/michael/                      --Rush, Red Tide

Reply via email to