@@ -147,20 +147,20 @@ def execute(self):
147147
148148 except Exception as objectifyexception :
149149 logging .error ( 'Create Document Exception: %s, %s' , type (objectifyexception ), objectifyexception .args )
150- pyxb . GlobalValidationConfig . _setForBinding ( False )
151- self . _response = apicontractsv1 . CreateFromDocument ( self . _httpResponse )
152- #objectify code
153- xmlResponse = self . _response . toxml ( encoding = constants . xml_encoding , element_name = self . getrequesttype ())
154- xmlResponse = xmlResponse . replace ( constants . nsNamespace1 , b'' )
155- xmlResponse = xmlResponse . replace ( constants . nsNamespace2 , b'' )
156- self . _mainObject = objectify . fromstring ( xmlResponse )
157- else :
150+ responseString = self . _httpResponse
151+
152+ # removing encoding attribute as objectify fails if it is present
153+ responseString = responseString . replace ( ' encoding=\" utf-8 \" ' , '' )
154+ self . _mainObject = objectify . fromstring ( responseString )
155+ else :
156+ domResponse = xml . dom . minidom . parseString ( self . _httpResponse )
157+
158158 #if type(self.getresponseclass()) == type(self._response):
159159 if type (self .getresponseclass ()) != type (self ._mainObject ):
160160 if self ._response .messages .resultCode == "Error" :
161161 logging .debug ("Response error" )
162- domResponse = xml .dom .minidom .parseString (self ._httpResponse )
163- logging .debug ('Received response: %s' % domResponse .toprettyxml ())
162+ domResponse = xml .dom .minidom .parseString (self ._httpResponse . encode ( 'utf-8' ). decode ( 'utf-8' ) )
163+ logging .debug ('Received response: %s' % domResponse .toprettyxml (encoding = 'utf-8' ))
164164 else :
165165 #Need to handle ErrorResponse
166166 logging .debug ('Error retrieving response for request: %s' % self ._request )
0 commit comments