@@ -59,10 +59,12 @@ public static synchronized <T extends Serializable> String getXml(T entity) thro
59
59
request_ctx = jaxbContext .get (entity .getClass ().toString ());
60
60
}
61
61
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
+ }
66
68
}
67
69
sw .flush ();
68
70
sw .close ();
@@ -94,29 +96,31 @@ public static synchronized <T extends Serializable> T create(String xml, Class<T
94
96
{
95
97
response_ctx = jaxbContext .get (classType .toString ());
96
98
}
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
+ }
120
124
}
121
125
122
126
return entity ;
0 commit comments