1 2 3 Previous Next 36 Replies Latest reply on Feb 27, 2017 7:54 AM by Pradeep Ganapathy

    XmlJavaTypeAdapter classes ignored in SOAP responses

    George Turner Newbie

      I was able to get my classes generated correctly so that the Adapter definition is in the class.  I used a binding.xjb class to do this.

       

      @XmlAttribute(name = "createDate", namespace = "urn:us:gov:ic:ism", required = true)

          @XmlJavaTypeAdapter(XmlDateAdapter.class)

          protected Date createDate;

       

      @XmlElement(name = "MsgCreationTime", required = true)

          @XmlJavaTypeAdapter(XmlDatetimeAdapter.class)

          @XmlSchemaType(name = "dateTime")

       

      My adapter classes are as follows:

       

      public class XmlDateAdapter extends XmlAdapter<String, Date> {

         @Override
         public Date unmarshal(String value) {

         if (value == null) {

         return null;

        }

         return javax.xml.bind.DatatypeConverter.parseDate(value).getTime();

        }

       

         @Override
         public String marshal(Date value) {

         if (value == null) {

         return null;

        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

         return sdf.format(value);

        }

      }

       

      public class XmlDatetimeAdapter extends XmlAdapter<String, Calendar> {

         @Override
         public Calendar unmarshal(String value) {

         if (value == null) {

         return null;

        }

         return javax.xml.bind.DatatypeConverter.parseDateTime(value);

        }

       

         @Override
         public String marshal(Calendar value) {

         if (value == null) {

         return null;

        }

        value.setTimeZone(TimeZone.getTimeZone("UTC"));

         return javax.xml.bind.DatatypeConverter.printDateTime(value);

        }

      }

       

      When I create a request and send it to the server, all is well, but when the server sends back the response, I cannot debug trap in the adapter classes and it is evident by the fact that the Date values output with full xs:dateTime strings with timezone offsets and my Date adapter specifically uses a SimpleDateFormat to NOT produce that string.  And my Calendar output has a timezone offset, whereas my Calendar adapter set the calendar instance to UTC so that it should have a "Z" ending instead of an offset value (which works correctly from the client)

       

      This is being tested in 9.0.0.CR1.  It would be great if this is resolved in CR2 before final releases!

        1 2 3 Previous Next