users@wadl.java.net

Re: WADL2Java Disambiguation problem

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 11 Dec 2009 15:53:21 -0500

OK, I took a look and a quick workaround is to separate the xml and json types into separate methods like this (I removed the parameters for clarity):

<application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://research.sun.com/wadl/2006/10">
  <resources base="http://example.com/">
    <resource path="norm">
      <method id="normalization-and-extraction-xml" name="POST">
        <doc>
          Post single list for normalization and/or extraction. HTTP respose contains the results.
        </doc>
        <request>
          <representation id="AttachmentXml" mediaType="application/xml" status="200" element="nm:ExtractAndNormalize">
            <doc>
              ExtractAndNormalize.xsd
            </doc>
          </representation>
        </request>
        <response>
          <representation id="AcceptXml" mediaType="application/xml" element="nm:ExtractAndNormalize" status="200"/>
            </response>
      </method>
      <method id="normalization-and-extraction-json" name="POST">
        <doc>
          Post single list for normalization and/or extraction. HTTP respose contains the results.
        </doc>
        <request>
          <representation id="AttachmentJson" mediaType="application/json" status="200">
            <doc>
              JSON equivalent of ExtractAndNormalize.xsd
            </doc>
          </representation>
        </request>
        <response>
          <representation id="AcceptJson" mediaType="application/json" status="200"/>
            </response>
      </method>
    </resource>
  </resources>
</application>

I realize this isn't ideal since a client might want to send xml and get back json (or vice versa) so I'll continue to look at this but I thought an early solution might be useful in case you are blocked by it.

Marc.