@@ -59,10 +59,12 @@ public static synchronized <T extends Serializable> String getXml(T entity) thro
5959 request_ctx = jaxbContext .get (entity .getClass ().toString ());
6060 }
6161
62- Marshaller m = request_ctx .createMarshaller ();
63- m .setProperty (Marshaller .JAXB_FORMATTED_OUTPUT , true );
64-
65- m .marshal (entity , sw );
62+ if (request_ctx != null ){
63+ Marshaller m = request_ctx .createMarshaller ();
64+ m .setProperty (Marshaller .JAXB_FORMATTED_OUTPUT , true );
65+
66+ m .marshal (entity , sw );
67+ }
6668 }
6769 sw .flush ();
6870 sw .close ();
@@ -94,29 +96,31 @@ public static synchronized <T extends Serializable> T create(String xml, Class<T
9496 {
9597 response_ctx = jaxbContext .get (classType .toString ());
9698 }
97-
98- Unmarshaller um = response_ctx .createUnmarshaller ();
99- try {
100- Object unmarshaled = um .unmarshal (new StringReader (xml ));
101- if ( null != unmarshaled )
102- {
103- try {
104- entity = classType .cast (unmarshaled );
105- } catch (ClassCastException cce ) {
106- if (unmarshaled instanceof JAXBElement ) {
107- @ SuppressWarnings ("rawtypes" )
108- JAXBElement element = (JAXBElement ) unmarshaled ;
109- if ( null != element .getValue () && element .getValue ().getClass ()==classType ) {
110- entity = (T ) element .getValue ();
111- }
112- }
113- }
114- }
115- } catch (JAXBException jaxbe ) {
116- LogHelper .info (logger , "Exception - while deserializing text:'%s' " , xml );
117- LogHelper .warn (logger , "Exception Details-> Code:'%s', Message:'%s'" , jaxbe .getErrorCode (), jaxbe .getMessage ());
118- throw jaxbe ;
119- }
99+
100+ if (response_ctx != null ){
101+ Unmarshaller um = response_ctx .createUnmarshaller ();
102+ try {
103+ Object unmarshaled = um .unmarshal (new StringReader (xml ));
104+ if ( null != unmarshaled )
105+ {
106+ try {
107+ entity = classType .cast (unmarshaled );
108+ } catch (ClassCastException cce ) {
109+ if (unmarshaled instanceof JAXBElement ) {
110+ @ SuppressWarnings ("rawtypes" )
111+ JAXBElement element = (JAXBElement ) unmarshaled ;
112+ if ( null != element .getValue () && element .getValue ().getClass ()==classType ) {
113+ entity = (T ) element .getValue ();
114+ }
115+ }
116+ }
117+ }
118+ } catch (JAXBException jaxbe ) {
119+ LogHelper .info (logger , "Exception - while deserializing text:'%s' " , xml );
120+ LogHelper .warn (logger , "Exception Details-> Code:'%s', Message:'%s'" , jaxbe .getErrorCode (), jaxbe .getMessage ());
121+ throw jaxbe ;
122+ }
123+ }
120124 }
121125
122126 return entity ;
0 commit comments