You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Eric Jain <Er...@isb-sib.ch> on 2003/06/27 19:44:34 UTC

Creating attachments in Serializer

I have a custom serializer that adds some specific object as an
attachment to a response, instead of encoding it as usual. Two issues:

1) What to do in writeSchema?
2) How to get rid of extra href's in the generated message?


public class EntrySerializer
  extends SimpleSerializer
{
  public EntrySerializer(Class javaType, QName xmlType)
  {
    super(javaType, xmlType);
  }

  public void serialize(QName name, Attributes attributes,
      final Object value, SerializationContext context)
    throws IOException
  {
    DataHandler data = ...
    Serializer serializer =
      context.getSerializerForJavaType(DataHandler.class);
    serializer.serialize(name, attributes, data, context);
  }

  public boolean writeSchema(Types types)
  {
    return false;
  }
}


Sample message (actual):

<soapenv:Body>
  <retrieveResponse
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  >
    <retrieveReturn href="#id0"/>
  </retrieveResponse>
  <multiRef
    id="id0"
    soapenc:root="0"
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    href="cid:B3B9A15141292E38B39BB4C7D212432A"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:ns1="http://expasy.org/soap/sptr/"
  />
</soapenv:Body>
...


Sample message (expected):

<soapenv:Body>
  <retrieveResponse
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  >
    <retrieveReturn
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      href="cid:B3B9A15141292E38B39BB4C7D212432A"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    />
  </retrieveResponse>
</soapenv:Body>
...


--
Eric Jain