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

    XmlJavaTypeAdapter classes ignored in SOAP responses

    geturner

      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. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
          geturner

          Actually I was doing some more testing, and the adapters are not used in the request processing OR the response processing.  But they ARE used when I submit the request from a remote client using the same classes as what the server is using.

          • 2. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
            jaikiran

            George Turner wrote:

            It would be great if this is resolved in CR2 before final releases!

            9.0.0.CR2 has already been released a few days back https://developer.jboss.org/thread/260342

            • 3. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
              geturner

              I know that.  I meant it would be great if it was fixed in Final.  This discussion was to prompt to see if I should enter it as a bug, or if there was a missing server configuration.  It is kind of wierd that this works great in the client code, but does not work in the server.

              • 4. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                jaikiran

                I don't actually have any knowledge in this area. So I won't be able to help, sorry. If you could explain a bit more about how you use this code (the client etc) and attach a reproducible application, maybe someone else with the relevant knowledge might be able to figure out what the issue is.

                • 5. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                  geturner

                  I provided all of the relevant code.  I cannot provide the implementation as it is government code and not releasable.  This is really a pretty simple error.  There are many issue with this problem already raised.  Someone in JbossWS and ApacheCXF should be able to resolve this quickly.

                  • 6. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                    jaikiran

                    George Turner wrote:

                     

                    Someone in JbossWS and ApacheCXF should be able to resolve this quickly.

                    Maybe asoldano might be able to help then.

                    • 7. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                      asoldano

                      George Turner wrote:

                       

                      I provided all of the relevant code.  I cannot provide the implementation as it is government code and not releasable.  This is really a pretty simple error.  There are many issue with this problem already raised.  Someone in JbossWS and ApacheCXF should be able to resolve this quickly.

                      Don't get me wrong, but you provided the code that you assume being relevant. The issue might still come from errors in the way the app is packaged, or in how dependencies are set, in missing package-info.class and/or ObjectFactory.class, etc. That's why a reproducer, as Jaikiran said, could be useful. If you can't share your app, you can likely code and provide a minimal reproducer. Can you please link to the issues/jiras regarding this that are raised and not fixed? That helps searches and other users.

                       

                      This said, we do have a testcase in the JBossWS testsuite which covers a scenario pretty similar to what you seems to be doing, see jbossws - Revision 19806: /stack/cxf/tags/jbossws-cxf-5.0.0.Final/modules/testsuite/shared-tests/src/test/java/org/jboss… If you're not sharing any further info / a reproducer, you might want to checkout or download JBossWS 5.0.0.Final, try / analyze the test and figure out what's different from your scenario and is causing the problem.

                      • 8. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                        asoldano

                        jaikiran pai wrote:

                        Maybe asoldano might be able to help then.

                        Thanks Jaikiran ;-)

                        • 9. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                          geturner

                          I will be glad to provide specific pieces upon request.  And if you can point to the instructions of how to swap out JBossWS in my current WF9CR1 installation, I would be happy to try it.  I simple don't have the time to write a standalone product that re-produces this problem, but I am more than willing to provide compiled components that may help to solve the problem.

                          I am not a newbie to SOAP services so I can try anything you can come up with.

                          • 10. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                            asoldano

                            OK, you might start by verifying that your deployment has the generated ObjectFactory and package-info classes included. That the endpoint interface is @XmlSeeAlso({ObjectFactory.class}) annotated. That the request and response message objects (assuming you have @RequestWrapper/@ResponseWrapped annotated methods in the endpoint interface) are valid java beans with a protected field annotated with @XmlJavaTypeAdapter(...) and there're proper getter and setter for the field.

                             

                            You could then checkout / download JBossWS 5.0.0.Final and simply run the afore mentioned test against your WFLY 9.0.0.CR1, which already includes 5.0.0.Final. See what differs between the test code and your scenario.

                            • 11. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                              geturner

                              Everything is where is should be, but the package-info class is interesting:

                               

                              package gov.c2ssa.c2ssadomain.spacefence.v2.subscription;

                               

                               

                              import javax.xml.bind.annotation.XmlNsForm;

                              import javax.xml.bind.annotation.XmlSchema;

                               

                               

                              @XmlSchema(namespace="http://www.C2SSA.gov/C2SSADomain/SpaceFence/v2/Subscription", elementFormDefault=XmlNsForm.QUALIFIED)

                              abstract interface package-info

                              {

                              }

                               

                              Also, have you ensured that the Adapter1 class of yours is being executed?  When I try to debug trap in the class, it does not trap.  I would be curious if you changed the output string of the Adapter1 like I have and see if it performs as expected.

                              • 12. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                                asoldano

                                Indeed interesting package-info, I need to think about it a bit more tomorrow or such, but I can't say that's related to problem for sure.

                                 

                                As for the test in JBossWS sources, I've just tried adding System.out lines within the Adapter1 and re-run the test and I can see relevant prints in the logs on both client and server side.

                                • 13. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                                  geturner

                                  I am at wits end.  I added a package-info class in the package where the adapater classes are defined:

                                   

                                  @XmlJavaTypeAdapters({

                                     @XmlJavaTypeAdapter(value=XmlDateAdapter.class, type=Date.class),

                                     @XmlJavaTypeAdapter(value=XmlDatetimeAdapter.class, type=Calendar.class)

                                  })

                                  package com.lmco.spacefence.webservices.util;

                                  import java.util.Calendar;

                                  import java.util.Date;

                                   

                                  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

                                  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;

                                   

                                   

                                  I added a System.out.println on each of the methods of each adapter.  When I call the service from a client, the println's are seen in the log.  They are not seen in the server log for the responses.

                                  Help me out here.  I have used Glassfish/Metro and have never had these problems, but from a LOT of Internet reading, it seems ApacheCXF does things differently.  There must be something else that I need to do that is not obvious to me, however I see a LOT of people on the Internet that have had these same problems with CXF, so what am I missing?  Is there a HOW-TO make this work document somewhere????

                                  • 14. Re: XmlJavaTypeAdapter classes ignored in SOAP responses
                                    asoldano

                                    Possibly stupid question, but can you double-check the package-info class is *actually* included in the jar/war that's deployed on the server? I've seen many times it not being included because of the way the war/jar was created (filters and such).

                                    1 2 3 Previous Next