Friday 15 April 2011

java - problem subclassing ObjectFactory in jax-ws web service -


In a jax-ws web service, I can not directly use the JaxbContext object. I used to add code to ObjectFactoryBase , then added

  public class ObjectFactory ObjectFactoryBase {/ /. Expanding Overriden methods}  

Although invalid annotation exceptions came to publication on weblogic, because in the @XmlElementDecl currently Can not find in ObjectFactoryBase . When I work from this @XmlElementDecl to ObjectFactory , it works.

There is no luck with connecting @xmlSeeAlso ({ObjectFactoryBase.class}. I) either.

EDIT: Now I have found out that the jacked objectifier not even used is the above error message because the jaxws web service is not any more relevant any more Why the idea arises but it is not used?

Any thoughts?

JACAB ObjectFactorys are strange creatures, there are many aspects of your question, so I just answered with a bullet list

  • JAASAB1 relied on object-factor to create examples of bound classes, but everything with JACAB 2 becomes a Pazo and ObjectFactor, mostly unnecessary, still generated by XJC The partial rear compatibility For the reasons.
  • Comments on an ObjectFactory are complex and non-obvious, but since it is a generated class, it usually does not matter, and most people don do not see it anyway.
  • Object Factory is still useful on one occasion because it provides factory methods for bound sections which require JAXBElement wrapper, and using the provided factory To do this by hand with a very easy way
  • JAXWS Web Service can choose not to use the ObjectFactory, as it is not necessarily necessary. Although JAXBContext can still load and parse it, depending on how the context was initiated.
  • I have never tried to create an ObjectFactory; If the model XJC-is generated then the ObjectFactory generated is usually sufficient, and if you have a hands-written JAXB model, then ObjectFactory is usually completely unnecessary.

No comments:

Post a Comment