Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 695 | blopes | 1 | /** |
| 2 | * NFeAutorizacao4Stub.java |
||
| 3 | * |
||
| 4 | * This file was auto-generated from WSDL |
||
| 5 | * by the Apache Axis2 version: 1.7.5 Built on : May 06, 2017 (03:45:26 BST) |
||
| 6 | */ |
||
| 7 | package br.com.swconsultoria.nfe.wsdl.NFeAutorizacao; |
||
| 8 | |||
| 9 | |||
| 10 | import org.apache.axis2.client.Stub; |
||
| 11 | |||
| 12 | /* |
||
| 13 | * NFeAutorizacao4Stub java implementation |
||
| 14 | */ |
||
| 15 | public class NFeAutorizacao4Stub extends org.apache.axis2.client.Stub { |
||
| 16 | private static int counter = 0; |
||
| 17 | protected org.apache.axis2.description.AxisOperation[] _operations; |
||
| 18 | |||
| 19 | //hashmaps to keep the fault mapping |
||
| 20 | private java.util.HashMap faultExceptionNameMap = new java.util.HashMap(); |
||
| 21 | private java.util.HashMap faultExceptionClassNameMap = new java.util.HashMap(); |
||
| 22 | private java.util.HashMap faultMessageMap = new java.util.HashMap(); |
||
| 23 | private javax.xml.namespace.QName[] opNameArray = null; |
||
| 24 | |||
| 25 | /** |
||
| 26 | *Constructor that takes in a configContext |
||
| 27 | */ |
||
| 28 | public NFeAutorizacao4Stub( |
||
| 29 | org.apache.axis2.context.ConfigurationContext configurationContext, |
||
| 30 | String targetEndpoint) throws org.apache.axis2.AxisFault { |
||
| 31 | this(configurationContext, targetEndpoint, false); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Constructor that takes in a configContext and useseperate listner |
||
| 36 | */ |
||
| 37 | public NFeAutorizacao4Stub( |
||
| 38 | org.apache.axis2.context.ConfigurationContext configurationContext, |
||
| 39 | String targetEndpoint, boolean useSeparateListener) |
||
| 40 | throws org.apache.axis2.AxisFault { |
||
| 41 | //To populate AxisService |
||
| 42 | populateAxisService(); |
||
| 43 | populateFaults(); |
||
| 44 | |||
| 45 | _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext, |
||
| 46 | _service); |
||
| 47 | |||
| 48 | _serviceClient.getOptions() |
||
| 49 | .setTo(new org.apache.axis2.addressing.EndpointReference( |
||
| 50 | targetEndpoint)); |
||
| 51 | _serviceClient.getOptions().setUseSeparateListener(useSeparateListener); |
||
| 52 | |||
| 53 | //Set the soap version |
||
| 54 | _serviceClient.getOptions() |
||
| 55 | .setSoapVersionURI(org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Default Constructor |
||
| 60 | */ |
||
| 61 | public NFeAutorizacao4Stub( |
||
| 62 | org.apache.axis2.context.ConfigurationContext configurationContext) |
||
| 63 | throws org.apache.axis2.AxisFault { |
||
| 64 | this(configurationContext, |
||
| 65 | "https://nfe.fazenda.sp.gov.br/ws/nfeautorizacao4.asmx"); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Default Constructor |
||
| 70 | */ |
||
| 71 | public NFeAutorizacao4Stub() throws org.apache.axis2.AxisFault { |
||
| 72 | this("https://nfe.fazenda.sp.gov.br/ws/nfeautorizacao4.asmx"); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Constructor taking the target endpoint |
||
| 77 | */ |
||
| 78 | public NFeAutorizacao4Stub(String targetEndpoint) |
||
| 79 | throws org.apache.axis2.AxisFault { |
||
| 80 | this(null, targetEndpoint); |
||
| 81 | } |
||
| 82 | |||
| 83 | private static synchronized String getUniqueSuffix() { |
||
| 84 | // reset the counter if it is greater than 99999 |
||
| 85 | if (counter > 99999) { |
||
| 86 | counter = 0; |
||
| 87 | } |
||
| 88 | |||
| 89 | counter = counter + 1; |
||
| 90 | |||
| 91 | return Long.toString(System.currentTimeMillis()) + |
||
| 92 | "_" + counter; |
||
| 93 | } |
||
| 94 | |||
| 95 | private void populateAxisService() throws org.apache.axis2.AxisFault { |
||
| 96 | //creating the Service with a unique name |
||
| 97 | _service = new org.apache.axis2.description.AxisService( |
||
| 98 | "NFeAutorizacao4" + getUniqueSuffix()); |
||
| 99 | addAnonymousOperations(); |
||
| 100 | |||
| 101 | //creating the operations |
||
| 102 | org.apache.axis2.description.AxisOperation __operation; |
||
| 103 | |||
| 104 | _operations = new org.apache.axis2.description.AxisOperation[2]; |
||
| 105 | |||
| 106 | __operation = new org.apache.axis2.description.OutInAxisOperation(); |
||
| 107 | |||
| 108 | __operation.setName(new javax.xml.namespace.QName( |
||
| 109 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 110 | "nfeAutorizacaoLote")); |
||
| 111 | _service.addOperation(__operation); |
||
| 112 | |||
| 113 | _operations[0] = __operation; |
||
| 114 | |||
| 115 | __operation = new org.apache.axis2.description.OutInAxisOperation(); |
||
| 116 | |||
| 117 | __operation.setName(new javax.xml.namespace.QName( |
||
| 118 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 119 | "nfeAutorizacaoLoteZip")); |
||
| 120 | _service.addOperation(__operation); |
||
| 121 | |||
| 122 | _operations[1] = __operation; |
||
| 123 | } |
||
| 124 | |||
| 125 | //populates the faults |
||
| 126 | private void populateFaults() { |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Auto generated method signature |
||
| 131 | * Transmissão de Lote de NF-e |
||
| 132 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeAutorizacao.NFeAutorizacao4#nfeAutorizacaoLote |
||
| 133 | * @param nfeDadosMsg1 |
||
| 134 | */ |
||
| 135 | public NFeAutorizacao4Stub.NfeResultMsg nfeAutorizacaoLote( |
||
| 136 | NFeAutorizacao4Stub.NfeDadosMsg nfeDadosMsg1) |
||
| 137 | throws java.rmi.RemoteException { |
||
| 138 | org.apache.axis2.context.MessageContext _messageContext = null; |
||
| 139 | |||
| 140 | try { |
||
| 141 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); |
||
| 142 | _operationClient.getOptions() |
||
| 143 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4/nfeAutorizacaoLote"); |
||
| 144 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 145 | |||
| 146 | addPropertyToOperationClient(_operationClient, |
||
| 147 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 148 | "&"); |
||
| 149 | |||
| 150 | // create a message context |
||
| 151 | _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 152 | |||
| 153 | // create SOAP envelope with that payload |
||
| 154 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 155 | |||
| 156 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 157 | .getSoapVersionURI()), |
||
| 158 | nfeDadosMsg1, |
||
| 159 | optimizeContent( |
||
| 160 | new javax.xml.namespace.QName( |
||
| 161 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 162 | "nfeAutorizacaoLote")), |
||
| 163 | new javax.xml.namespace.QName( |
||
| 164 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 165 | "nfeDadosMsg")); |
||
| 166 | |||
| 167 | //adding SOAP soap_headers |
||
| 168 | _serviceClient.addHeadersToEnvelope(env); |
||
| 169 | // set the message context with that soap envelope |
||
| 170 | _messageContext.setEnvelope(env); |
||
| 171 | |||
| 172 | // add the message contxt to the operation client |
||
| 173 | _operationClient.addMessageContext(_messageContext); |
||
| 174 | |||
| 175 | //execute the operation client |
||
| 176 | _operationClient.execute(true); |
||
| 177 | |||
| 178 | org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); |
||
| 179 | org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); |
||
| 180 | |||
| 181 | Object object = fromOM(_returnEnv.getBody() |
||
| 182 | .getFirstElement(), |
||
| 183 | NFeAutorizacao4Stub.NfeResultMsg.class); |
||
| 184 | |||
| 185 | return (NFeAutorizacao4Stub.NfeResultMsg) object; |
||
| 186 | } catch (org.apache.axis2.AxisFault f) { |
||
| 187 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 188 | |||
| 189 | if (faultElt != null) { |
||
| 190 | if (faultExceptionNameMap.containsKey( |
||
| 191 | new org.apache.axis2.client.FaultMapKey( |
||
| 192 | faultElt.getQName(), "nfeAutorizacaoLote"))) { |
||
| 193 | //make the fault by reflection |
||
| 194 | try { |
||
| 195 | String exceptionClassName = (String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 196 | faultElt.getQName(), "nfeAutorizacaoLote")); |
||
| 197 | Class exceptionClass = Class.forName(exceptionClassName); |
||
| 198 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(String.class); |
||
| 199 | Exception ex = (Exception) constructor.newInstance(f.getMessage()); |
||
| 200 | |||
| 201 | //message class |
||
| 202 | String messageClassName = (String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 203 | faultElt.getQName(), "nfeAutorizacaoLote")); |
||
| 204 | Class messageClass = Class.forName(messageClassName); |
||
| 205 | Object messageObject = fromOM(faultElt, |
||
| 206 | messageClass); |
||
| 207 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 208 | new Class[] { messageClass }); |
||
| 209 | m.invoke(ex, new Object[] { messageObject }); |
||
| 210 | |||
| 211 | throw new java.rmi.RemoteException(ex.getMessage(), ex); |
||
| 212 | } catch (ClassCastException e) { |
||
| 213 | // we cannot intantiate the class - throw the original Axis fault |
||
| 214 | throw f; |
||
| 215 | } catch (ClassNotFoundException e) { |
||
| 216 | // we cannot intantiate the class - throw the original Axis fault |
||
| 217 | throw f; |
||
| 218 | } catch (NoSuchMethodException e) { |
||
| 219 | // we cannot intantiate the class - throw the original Axis fault |
||
| 220 | throw f; |
||
| 221 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 222 | // we cannot intantiate the class - throw the original Axis fault |
||
| 223 | throw f; |
||
| 224 | } catch (IllegalAccessException e) { |
||
| 225 | // we cannot intantiate the class - throw the original Axis fault |
||
| 226 | throw f; |
||
| 227 | } catch (InstantiationException e) { |
||
| 228 | // we cannot intantiate the class - throw the original Axis fault |
||
| 229 | throw f; |
||
| 230 | } |
||
| 231 | } else { |
||
| 232 | throw f; |
||
| 233 | } |
||
| 234 | } else { |
||
| 235 | throw f; |
||
| 236 | } |
||
| 237 | } finally { |
||
| 238 | if (_messageContext.getTransportOut() != null) { |
||
| 239 | _messageContext.getTransportOut().getSender() |
||
| 240 | .cleanup(_messageContext); |
||
| 241 | } |
||
| 242 | } |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Auto generated method signature for Asynchronous Invocations |
||
| 247 | * Transmissão de Lote de NF-e |
||
| 248 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeAutorizacao.NFeAutorizacao4#startnfeAutorizacaoLote |
||
| 249 | * @param nfeDadosMsg1 |
||
| 250 | */ |
||
| 251 | public void startnfeAutorizacaoLote( |
||
| 252 | NFeAutorizacao4Stub.NfeDadosMsg nfeDadosMsg1, |
||
| 253 | final NFeAutorizacao4CallbackHandler callback) |
||
| 254 | throws java.rmi.RemoteException { |
||
| 255 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); |
||
| 256 | _operationClient.getOptions() |
||
| 257 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4/nfeAutorizacaoLote"); |
||
| 258 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 259 | |||
| 260 | addPropertyToOperationClient(_operationClient, |
||
| 261 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 262 | "&"); |
||
| 263 | |||
| 264 | // create SOAP envelope with that payload |
||
| 265 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 266 | final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 267 | |||
| 268 | //Style is Doc. |
||
| 269 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 270 | .getSoapVersionURI()), |
||
| 271 | nfeDadosMsg1, |
||
| 272 | optimizeContent( |
||
| 273 | new javax.xml.namespace.QName( |
||
| 274 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 275 | "nfeAutorizacaoLote")), |
||
| 276 | new javax.xml.namespace.QName( |
||
| 277 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 278 | "nfeDadosMsg")); |
||
| 279 | |||
| 280 | // adding SOAP soap_headers |
||
| 281 | _serviceClient.addHeadersToEnvelope(env); |
||
| 282 | // create message context with that soap envelope |
||
| 283 | _messageContext.setEnvelope(env); |
||
| 284 | |||
| 285 | // add the message context to the operation client |
||
| 286 | _operationClient.addMessageContext(_messageContext); |
||
| 287 | |||
| 288 | _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { |
||
| 289 | public void onMessage( |
||
| 290 | org.apache.axis2.context.MessageContext resultContext) { |
||
| 291 | try { |
||
| 292 | org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); |
||
| 293 | |||
| 294 | Object object = fromOM(resultEnv.getBody() |
||
| 295 | .getFirstElement(), |
||
| 296 | NFeAutorizacao4Stub.NfeResultMsg.class); |
||
| 297 | callback.receiveResultnfeAutorizacaoLote((NFeAutorizacao4Stub.NfeResultMsg) object); |
||
| 298 | } catch (org.apache.axis2.AxisFault e) { |
||
| 299 | callback.receiveErrornfeAutorizacaoLote(e); |
||
| 300 | } |
||
| 301 | } |
||
| 302 | |||
| 303 | public void onError(Exception error) { |
||
| 304 | if (error instanceof org.apache.axis2.AxisFault) { |
||
| 305 | org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; |
||
| 306 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 307 | |||
| 308 | if (faultElt != null) { |
||
| 309 | if (faultExceptionNameMap.containsKey( |
||
| 310 | new org.apache.axis2.client.FaultMapKey( |
||
| 311 | faultElt.getQName(), |
||
| 312 | "nfeAutorizacaoLote"))) { |
||
| 313 | //make the fault by reflection |
||
| 314 | try { |
||
| 315 | String exceptionClassName = (String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 316 | faultElt.getQName(), |
||
| 317 | "nfeAutorizacaoLote")); |
||
| 318 | Class exceptionClass = Class.forName(exceptionClassName); |
||
| 319 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(String.class); |
||
| 320 | Exception ex = (Exception) constructor.newInstance(f.getMessage()); |
||
| 321 | |||
| 322 | //message class |
||
| 323 | String messageClassName = (String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 324 | faultElt.getQName(), |
||
| 325 | "nfeAutorizacaoLote")); |
||
| 326 | Class messageClass = Class.forName(messageClassName); |
||
| 327 | Object messageObject = fromOM(faultElt, |
||
| 328 | messageClass); |
||
| 329 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 330 | new Class[] { messageClass }); |
||
| 331 | m.invoke(ex, |
||
| 332 | new Object[] { messageObject }); |
||
| 333 | |||
| 334 | callback.receiveErrornfeAutorizacaoLote(new java.rmi.RemoteException( |
||
| 335 | ex.getMessage(), ex)); |
||
| 336 | } catch (ClassCastException e) { |
||
| 337 | // we cannot intantiate the class - throw the original Axis fault |
||
| 338 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 339 | } catch (ClassNotFoundException e) { |
||
| 340 | // we cannot intantiate the class - throw the original Axis fault |
||
| 341 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 342 | } catch (NoSuchMethodException e) { |
||
| 343 | // we cannot intantiate the class - throw the original Axis fault |
||
| 344 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 345 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 346 | // we cannot intantiate the class - throw the original Axis fault |
||
| 347 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 348 | } catch (IllegalAccessException e) { |
||
| 349 | // we cannot intantiate the class - throw the original Axis fault |
||
| 350 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 351 | } catch (InstantiationException e) { |
||
| 352 | // we cannot intantiate the class - throw the original Axis fault |
||
| 353 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 354 | } catch (org.apache.axis2.AxisFault e) { |
||
| 355 | // we cannot intantiate the class - throw the original Axis fault |
||
| 356 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 357 | } |
||
| 358 | } else { |
||
| 359 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 360 | } |
||
| 361 | } else { |
||
| 362 | callback.receiveErrornfeAutorizacaoLote(f); |
||
| 363 | } |
||
| 364 | } else { |
||
| 365 | callback.receiveErrornfeAutorizacaoLote(error); |
||
| 366 | } |
||
| 367 | } |
||
| 368 | |||
| 369 | public void onFault( |
||
| 370 | org.apache.axis2.context.MessageContext faultContext) { |
||
| 371 | org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext); |
||
| 372 | onError(fault); |
||
| 373 | } |
||
| 374 | |||
| 375 | public void onComplete() { |
||
| 376 | try { |
||
| 377 | _messageContext.getTransportOut().getSender() |
||
| 378 | .cleanup(_messageContext); |
||
| 379 | } catch (org.apache.axis2.AxisFault axisFault) { |
||
| 380 | callback.receiveErrornfeAutorizacaoLote(axisFault); |
||
| 381 | } |
||
| 382 | } |
||
| 383 | }); |
||
| 384 | |||
| 385 | org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; |
||
| 386 | |||
| 387 | if ((_operations[0].getMessageReceiver() == null) && |
||
| 388 | _operationClient.getOptions().isUseSeparateListener()) { |
||
| 389 | _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); |
||
| 390 | _operations[0].setMessageReceiver(_callbackReceiver); |
||
| 391 | } |
||
| 392 | |||
| 393 | //execute the operation client |
||
| 394 | _operationClient.execute(false); |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Auto generated method signature |
||
| 399 | * Transmissão de Lote de NF-e compactado |
||
| 400 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeAutorizacao.NFeAutorizacao4#nfeAutorizacaoLoteZip |
||
| 401 | * @param nfeDadosMsgZip3 |
||
| 402 | */ |
||
| 403 | public NFeAutorizacao4Stub.NfeResultMsg nfeAutorizacaoLoteZip( |
||
| 404 | NFeAutorizacao4Stub.NfeDadosMsgZip nfeDadosMsgZip3) |
||
| 405 | throws java.rmi.RemoteException { |
||
| 406 | org.apache.axis2.context.MessageContext _messageContext = null; |
||
| 407 | |||
| 408 | try { |
||
| 409 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[1].getName()); |
||
| 410 | _operationClient.getOptions() |
||
| 411 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4/nfeAutorizacaoLoteZip"); |
||
| 412 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 413 | |||
| 414 | addPropertyToOperationClient(_operationClient, |
||
| 415 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 416 | "&"); |
||
| 417 | |||
| 418 | // create a message context |
||
| 419 | _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 420 | |||
| 421 | // create SOAP envelope with that payload |
||
| 422 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 423 | |||
| 424 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 425 | .getSoapVersionURI()), |
||
| 426 | nfeDadosMsgZip3, |
||
| 427 | optimizeContent( |
||
| 428 | new javax.xml.namespace.QName( |
||
| 429 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 430 | "nfeAutorizacaoLoteZip")), |
||
| 431 | new javax.xml.namespace.QName( |
||
| 432 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 433 | "nfeDadosMsgZip")); |
||
| 434 | |||
| 435 | //adding SOAP soap_headers |
||
| 436 | _serviceClient.addHeadersToEnvelope(env); |
||
| 437 | // set the message context with that soap envelope |
||
| 438 | _messageContext.setEnvelope(env); |
||
| 439 | |||
| 440 | // add the message contxt to the operation client |
||
| 441 | _operationClient.addMessageContext(_messageContext); |
||
| 442 | |||
| 443 | //execute the operation client |
||
| 444 | _operationClient.execute(true); |
||
| 445 | |||
| 446 | org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); |
||
| 447 | org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); |
||
| 448 | |||
| 449 | Object object = fromOM(_returnEnv.getBody() |
||
| 450 | .getFirstElement(), |
||
| 451 | NFeAutorizacao4Stub.NfeResultMsg.class); |
||
| 452 | |||
| 453 | return (NFeAutorizacao4Stub.NfeResultMsg) object; |
||
| 454 | } catch (org.apache.axis2.AxisFault f) { |
||
| 455 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 456 | |||
| 457 | if (faultElt != null) { |
||
| 458 | if (faultExceptionNameMap.containsKey( |
||
| 459 | new org.apache.axis2.client.FaultMapKey( |
||
| 460 | faultElt.getQName(), "nfeAutorizacaoLoteZip"))) { |
||
| 461 | //make the fault by reflection |
||
| 462 | try { |
||
| 463 | String exceptionClassName = (String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 464 | faultElt.getQName(), "nfeAutorizacaoLoteZip")); |
||
| 465 | Class exceptionClass = Class.forName(exceptionClassName); |
||
| 466 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(String.class); |
||
| 467 | Exception ex = (Exception) constructor.newInstance(f.getMessage()); |
||
| 468 | |||
| 469 | //message class |
||
| 470 | String messageClassName = (String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 471 | faultElt.getQName(), "nfeAutorizacaoLoteZip")); |
||
| 472 | Class messageClass = Class.forName(messageClassName); |
||
| 473 | Object messageObject = fromOM(faultElt, |
||
| 474 | messageClass); |
||
| 475 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 476 | new Class[] { messageClass }); |
||
| 477 | m.invoke(ex, new Object[] { messageObject }); |
||
| 478 | |||
| 479 | throw new java.rmi.RemoteException(ex.getMessage(), ex); |
||
| 480 | } catch (ClassCastException e) { |
||
| 481 | // we cannot intantiate the class - throw the original Axis fault |
||
| 482 | throw f; |
||
| 483 | } catch (ClassNotFoundException e) { |
||
| 484 | // we cannot intantiate the class - throw the original Axis fault |
||
| 485 | throw f; |
||
| 486 | } catch (NoSuchMethodException e) { |
||
| 487 | // we cannot intantiate the class - throw the original Axis fault |
||
| 488 | throw f; |
||
| 489 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 490 | // we cannot intantiate the class - throw the original Axis fault |
||
| 491 | throw f; |
||
| 492 | } catch (IllegalAccessException e) { |
||
| 493 | // we cannot intantiate the class - throw the original Axis fault |
||
| 494 | throw f; |
||
| 495 | } catch (InstantiationException e) { |
||
| 496 | // we cannot intantiate the class - throw the original Axis fault |
||
| 497 | throw f; |
||
| 498 | } |
||
| 499 | } else { |
||
| 500 | throw f; |
||
| 501 | } |
||
| 502 | } else { |
||
| 503 | throw f; |
||
| 504 | } |
||
| 505 | } finally { |
||
| 506 | if (_messageContext.getTransportOut() != null) { |
||
| 507 | _messageContext.getTransportOut().getSender() |
||
| 508 | .cleanup(_messageContext); |
||
| 509 | } |
||
| 510 | } |
||
| 511 | } |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Auto generated method signature for Asynchronous Invocations |
||
| 515 | * Transmissão de Lote de NF-e compactado |
||
| 516 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeAutorizacao.NFeAutorizacao4#startnfeAutorizacaoLoteZip |
||
| 517 | * @param nfeDadosMsgZip3 |
||
| 518 | */ |
||
| 519 | public void startnfeAutorizacaoLoteZip( |
||
| 520 | NFeAutorizacao4Stub.NfeDadosMsgZip nfeDadosMsgZip3, |
||
| 521 | final NFeAutorizacao4CallbackHandler callback) |
||
| 522 | throws java.rmi.RemoteException { |
||
| 523 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[1].getName()); |
||
| 524 | _operationClient.getOptions() |
||
| 525 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4/nfeAutorizacaoLoteZip"); |
||
| 526 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 527 | |||
| 528 | addPropertyToOperationClient(_operationClient, |
||
| 529 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 530 | "&"); |
||
| 531 | |||
| 532 | // create SOAP envelope with that payload |
||
| 533 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 534 | final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 535 | |||
| 536 | //Style is Doc. |
||
| 537 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 538 | .getSoapVersionURI()), |
||
| 539 | nfeDadosMsgZip3, |
||
| 540 | optimizeContent( |
||
| 541 | new javax.xml.namespace.QName( |
||
| 542 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 543 | "nfeAutorizacaoLoteZip")), |
||
| 544 | new javax.xml.namespace.QName( |
||
| 545 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 546 | "nfeDadosMsgZip")); |
||
| 547 | |||
| 548 | // adding SOAP soap_headers |
||
| 549 | _serviceClient.addHeadersToEnvelope(env); |
||
| 550 | // create message context with that soap envelope |
||
| 551 | _messageContext.setEnvelope(env); |
||
| 552 | |||
| 553 | // add the message context to the operation client |
||
| 554 | _operationClient.addMessageContext(_messageContext); |
||
| 555 | |||
| 556 | _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { |
||
| 557 | public void onMessage( |
||
| 558 | org.apache.axis2.context.MessageContext resultContext) { |
||
| 559 | try { |
||
| 560 | org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); |
||
| 561 | |||
| 562 | Object object = fromOM(resultEnv.getBody() |
||
| 563 | .getFirstElement(), |
||
| 564 | NFeAutorizacao4Stub.NfeResultMsg.class); |
||
| 565 | callback.receiveResultnfeAutorizacaoLoteZip((NFeAutorizacao4Stub.NfeResultMsg) object); |
||
| 566 | } catch (org.apache.axis2.AxisFault e) { |
||
| 567 | callback.receiveErrornfeAutorizacaoLoteZip(e); |
||
| 568 | } |
||
| 569 | } |
||
| 570 | |||
| 571 | public void onError(Exception error) { |
||
| 572 | if (error instanceof org.apache.axis2.AxisFault) { |
||
| 573 | org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; |
||
| 574 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 575 | |||
| 576 | if (faultElt != null) { |
||
| 577 | if (faultExceptionNameMap.containsKey( |
||
| 578 | new org.apache.axis2.client.FaultMapKey( |
||
| 579 | faultElt.getQName(), |
||
| 580 | "nfeAutorizacaoLoteZip"))) { |
||
| 581 | //make the fault by reflection |
||
| 582 | try { |
||
| 583 | String exceptionClassName = (String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 584 | faultElt.getQName(), |
||
| 585 | "nfeAutorizacaoLoteZip")); |
||
| 586 | Class exceptionClass = Class.forName(exceptionClassName); |
||
| 587 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(String.class); |
||
| 588 | Exception ex = (Exception) constructor.newInstance(f.getMessage()); |
||
| 589 | |||
| 590 | //message class |
||
| 591 | String messageClassName = (String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 592 | faultElt.getQName(), |
||
| 593 | "nfeAutorizacaoLoteZip")); |
||
| 594 | Class messageClass = Class.forName(messageClassName); |
||
| 595 | Object messageObject = fromOM(faultElt, |
||
| 596 | messageClass); |
||
| 597 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 598 | new Class[] { messageClass }); |
||
| 599 | m.invoke(ex, |
||
| 600 | new Object[] { messageObject }); |
||
| 601 | |||
| 602 | callback.receiveErrornfeAutorizacaoLoteZip(new java.rmi.RemoteException( |
||
| 603 | ex.getMessage(), ex)); |
||
| 604 | } catch (ClassCastException e) { |
||
| 605 | // we cannot intantiate the class - throw the original Axis fault |
||
| 606 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 607 | } catch (ClassNotFoundException e) { |
||
| 608 | // we cannot intantiate the class - throw the original Axis fault |
||
| 609 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 610 | } catch (NoSuchMethodException e) { |
||
| 611 | // we cannot intantiate the class - throw the original Axis fault |
||
| 612 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 613 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 614 | // we cannot intantiate the class - throw the original Axis fault |
||
| 615 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 616 | } catch (IllegalAccessException e) { |
||
| 617 | // we cannot intantiate the class - throw the original Axis fault |
||
| 618 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 619 | } catch (InstantiationException e) { |
||
| 620 | // we cannot intantiate the class - throw the original Axis fault |
||
| 621 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 622 | } catch (org.apache.axis2.AxisFault e) { |
||
| 623 | // we cannot intantiate the class - throw the original Axis fault |
||
| 624 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 625 | } |
||
| 626 | } else { |
||
| 627 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 628 | } |
||
| 629 | } else { |
||
| 630 | callback.receiveErrornfeAutorizacaoLoteZip(f); |
||
| 631 | } |
||
| 632 | } else { |
||
| 633 | callback.receiveErrornfeAutorizacaoLoteZip(error); |
||
| 634 | } |
||
| 635 | } |
||
| 636 | |||
| 637 | public void onFault( |
||
| 638 | org.apache.axis2.context.MessageContext faultContext) { |
||
| 639 | org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext); |
||
| 640 | onError(fault); |
||
| 641 | } |
||
| 642 | |||
| 643 | public void onComplete() { |
||
| 644 | try { |
||
| 645 | _messageContext.getTransportOut().getSender() |
||
| 646 | .cleanup(_messageContext); |
||
| 647 | } catch (org.apache.axis2.AxisFault axisFault) { |
||
| 648 | callback.receiveErrornfeAutorizacaoLoteZip(axisFault); |
||
| 649 | } |
||
| 650 | } |
||
| 651 | }); |
||
| 652 | |||
| 653 | org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; |
||
| 654 | |||
| 655 | if ((_operations[1].getMessageReceiver() == null) && |
||
| 656 | _operationClient.getOptions().isUseSeparateListener()) { |
||
| 657 | _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); |
||
| 658 | _operations[1].setMessageReceiver(_callbackReceiver); |
||
| 659 | } |
||
| 660 | |||
| 661 | //execute the operation client |
||
| 662 | _operationClient.execute(false); |
||
| 663 | } |
||
| 664 | |||
| 665 | private boolean optimizeContent(javax.xml.namespace.QName opName) { |
||
| 666 | if (opNameArray == null) { |
||
| 667 | return false; |
||
| 668 | } |
||
| 669 | |||
| 670 | for (int i = 0; i < opNameArray.length; i++) { |
||
| 671 | if (opName.equals(opNameArray[i])) { |
||
| 672 | return true; |
||
| 673 | } |
||
| 674 | } |
||
| 675 | |||
| 676 | return false; |
||
| 677 | } |
||
| 678 | |||
| 679 | private org.apache.axiom.om.OMElement toOM( |
||
| 680 | NFeAutorizacao4Stub.NfeDadosMsg param, |
||
| 681 | boolean optimizeContent) throws org.apache.axis2.AxisFault { |
||
| 682 | try { |
||
| 683 | return param.getOMElement(NFeAutorizacao4Stub.NfeDadosMsg.MY_QNAME, |
||
| 684 | org.apache.axiom.om.OMAbstractFactory.getOMFactory()); |
||
| 685 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 686 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 687 | } |
||
| 688 | } |
||
| 689 | |||
| 690 | private org.apache.axiom.om.OMElement toOM( |
||
| 691 | NFeAutorizacao4Stub.NfeResultMsg param, |
||
| 692 | boolean optimizeContent) throws org.apache.axis2.AxisFault { |
||
| 693 | try { |
||
| 694 | return param.getOMElement(NFeAutorizacao4Stub.NfeResultMsg.MY_QNAME, |
||
| 695 | org.apache.axiom.om.OMAbstractFactory.getOMFactory()); |
||
| 696 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 697 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 698 | } |
||
| 699 | } |
||
| 700 | |||
| 701 | private org.apache.axiom.om.OMElement toOM( |
||
| 702 | NFeAutorizacao4Stub.NfeDadosMsgZip param, |
||
| 703 | boolean optimizeContent) throws org.apache.axis2.AxisFault { |
||
| 704 | try { |
||
| 705 | return param.getOMElement(NFeAutorizacao4Stub.NfeDadosMsgZip.MY_QNAME, |
||
| 706 | org.apache.axiom.om.OMAbstractFactory.getOMFactory()); |
||
| 707 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 708 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 709 | } |
||
| 710 | } |
||
| 711 | |||
| 712 | private org.apache.axiom.soap.SOAPEnvelope toEnvelope( |
||
| 713 | org.apache.axiom.soap.SOAPFactory factory, |
||
| 714 | NFeAutorizacao4Stub.NfeDadosMsg param, |
||
| 715 | boolean optimizeContent, javax.xml.namespace.QName elementQName) |
||
| 716 | throws org.apache.axis2.AxisFault { |
||
| 717 | try { |
||
| 718 | org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); |
||
| 719 | emptyEnvelope.getBody() |
||
| 720 | .addChild(param.getOMElement( |
||
| 721 | NFeAutorizacao4Stub.NfeDadosMsg.MY_QNAME, |
||
| 722 | factory)); |
||
| 723 | |||
| 724 | return emptyEnvelope; |
||
| 725 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 726 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 727 | } |
||
| 728 | } |
||
| 729 | |||
| 730 | /* methods to provide back word compatibility */ |
||
| 731 | private org.apache.axiom.soap.SOAPEnvelope toEnvelope( |
||
| 732 | org.apache.axiom.soap.SOAPFactory factory, |
||
| 733 | NFeAutorizacao4Stub.NfeDadosMsgZip param, |
||
| 734 | boolean optimizeContent, javax.xml.namespace.QName elementQName) |
||
| 735 | throws org.apache.axis2.AxisFault { |
||
| 736 | try { |
||
| 737 | org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); |
||
| 738 | emptyEnvelope.getBody() |
||
| 739 | .addChild(param.getOMElement( |
||
| 740 | NFeAutorizacao4Stub.NfeDadosMsgZip.MY_QNAME, |
||
| 741 | factory)); |
||
| 742 | |||
| 743 | return emptyEnvelope; |
||
| 744 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 745 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 746 | } |
||
| 747 | } |
||
| 748 | |||
| 749 | /* methods to provide back word compatibility */ |
||
| 750 | |||
| 751 | /** |
||
| 752 | * get the default envelope |
||
| 753 | */ |
||
| 754 | private org.apache.axiom.soap.SOAPEnvelope toEnvelope( |
||
| 755 | org.apache.axiom.soap.SOAPFactory factory) { |
||
| 756 | return factory.getDefaultEnvelope(); |
||
| 757 | } |
||
| 758 | |||
| 759 | private Object fromOM(org.apache.axiom.om.OMElement param, |
||
| 760 | Class type) throws org.apache.axis2.AxisFault { |
||
| 761 | try { |
||
| 762 | if (NFeAutorizacao4Stub.NfeDadosMsg.class.equals( |
||
| 763 | type)) { |
||
| 764 | return NFeAutorizacao4Stub.NfeDadosMsg.Factory.parse(param.getXMLStreamReaderWithoutCaching()); |
||
| 765 | } |
||
| 766 | |||
| 767 | if (NFeAutorizacao4Stub.NfeDadosMsgZip.class.equals( |
||
| 768 | type)) { |
||
| 769 | return NFeAutorizacao4Stub.NfeDadosMsgZip.Factory.parse(param.getXMLStreamReaderWithoutCaching()); |
||
| 770 | } |
||
| 771 | |||
| 772 | if (NFeAutorizacao4Stub.NfeResultMsg.class.equals( |
||
| 773 | type)) { |
||
| 774 | return NFeAutorizacao4Stub.NfeResultMsg.Factory.parse(param.getXMLStreamReaderWithoutCaching()); |
||
| 775 | } |
||
| 776 | } catch (Exception e) { |
||
| 777 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 778 | } |
||
| 779 | |||
| 780 | return null; |
||
| 781 | } |
||
| 782 | |||
| 783 | //https://nfe.fazenda.sp.gov.br/ws/nfeautorizacao4.asmx |
||
| 784 | public static class NfeResultMsg implements org.apache.axis2.databinding.ADBBean { |
||
| 785 | public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 786 | "nfeResultMsg", "ns1"); |
||
| 787 | |||
| 788 | /** |
||
| 789 | * field for ExtraElement |
||
| 790 | */ |
||
| 791 | protected org.apache.axiom.om.OMElement localExtraElement; |
||
| 792 | |||
| 793 | /** |
||
| 794 | * Auto generated getter method |
||
| 795 | * @return org.apache.axiom.om.OMElement |
||
| 796 | */ |
||
| 797 | public org.apache.axiom.om.OMElement getExtraElement() { |
||
| 798 | return localExtraElement; |
||
| 799 | } |
||
| 800 | |||
| 801 | /** |
||
| 802 | * Auto generated setter method |
||
| 803 | * @param param ExtraElement |
||
| 804 | */ |
||
| 805 | public void setExtraElement(org.apache.axiom.om.OMElement param) { |
||
| 806 | this.localExtraElement = param; |
||
| 807 | } |
||
| 808 | |||
| 809 | /** |
||
| 810 | * |
||
| 811 | * @param parentQName |
||
| 812 | * @param factory |
||
| 813 | * @return org.apache.axiom.om.OMElement |
||
| 814 | */ |
||
| 815 | public org.apache.axiom.om.OMElement getOMElement( |
||
| 816 | final javax.xml.namespace.QName parentQName, |
||
| 817 | final org.apache.axiom.om.OMFactory factory) |
||
| 818 | throws org.apache.axis2.databinding.ADBException { |
||
| 819 | return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( |
||
| 820 | this, MY_QNAME)); |
||
| 821 | } |
||
| 822 | |||
| 823 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 824 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 825 | throws javax.xml.stream.XMLStreamException, |
||
| 826 | org.apache.axis2.databinding.ADBException { |
||
| 827 | serialize(parentQName, xmlWriter, false); |
||
| 828 | } |
||
| 829 | |||
| 830 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 831 | javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) |
||
| 832 | throws javax.xml.stream.XMLStreamException, |
||
| 833 | org.apache.axis2.databinding.ADBException { |
||
| 834 | String prefix = null; |
||
| 835 | String namespace = null; |
||
| 836 | |||
| 837 | prefix = parentQName.getPrefix(); |
||
| 838 | namespace = parentQName.getNamespaceURI(); |
||
| 839 | writeStartElement(prefix, namespace, parentQName.getLocalPart(), |
||
| 840 | xmlWriter); |
||
| 841 | |||
| 842 | if (serializeType) { |
||
| 843 | String namespacePrefix = registerPrefix(xmlWriter, |
||
| 844 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4"); |
||
| 845 | |||
| 846 | if ((namespacePrefix != null) && |
||
| 847 | (namespacePrefix.trim().length() > 0)) { |
||
| 848 | writeAttribute("xsi", |
||
| 849 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 850 | namespacePrefix + ":nfeResultMsg", xmlWriter); |
||
| 851 | } else { |
||
| 852 | writeAttribute("xsi", |
||
| 853 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 854 | "nfeResultMsg", xmlWriter); |
||
| 855 | } |
||
| 856 | } |
||
| 857 | |||
| 858 | if (localExtraElement != null) { |
||
| 859 | localExtraElement.serialize(xmlWriter); |
||
| 860 | } else { |
||
| 861 | throw new org.apache.axis2.databinding.ADBException( |
||
| 862 | "extraElement cannot be null!!"); |
||
| 863 | } |
||
| 864 | |||
| 865 | xmlWriter.writeEndElement(); |
||
| 866 | } |
||
| 867 | |||
| 868 | private static String generatePrefix( |
||
| 869 | String namespace) { |
||
| 870 | if (namespace.equals( |
||
| 871 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4")) { |
||
| 872 | return "ns1"; |
||
| 873 | } |
||
| 874 | |||
| 875 | return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * Utility method to write an element start tag. |
||
| 880 | */ |
||
| 881 | private void writeStartElement(String prefix, |
||
| 882 | String namespace, String localPart, |
||
| 883 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 884 | throws javax.xml.stream.XMLStreamException { |
||
| 885 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 886 | |||
| 887 | if (writerPrefix != null) { |
||
| 888 | xmlWriter.writeStartElement(writerPrefix, localPart, namespace); |
||
| 889 | } else { |
||
| 890 | if (namespace.length() == 0) { |
||
| 891 | prefix = ""; |
||
| 892 | } else if (prefix == null) { |
||
| 893 | prefix = generatePrefix(namespace); |
||
| 894 | } |
||
| 895 | |||
| 896 | xmlWriter.writeStartElement(prefix, localPart, namespace); |
||
| 897 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 898 | xmlWriter.setPrefix(prefix, namespace); |
||
| 899 | } |
||
| 900 | } |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Util method to write an attribute with the ns prefix |
||
| 904 | */ |
||
| 905 | private void writeAttribute(String prefix, |
||
| 906 | String namespace, String attName, |
||
| 907 | String attValue, |
||
| 908 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 909 | throws javax.xml.stream.XMLStreamException { |
||
| 910 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 911 | |||
| 912 | if (writerPrefix != null) { |
||
| 913 | xmlWriter.writeAttribute(writerPrefix, namespace, attName, |
||
| 914 | attValue); |
||
| 915 | } else { |
||
| 916 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 917 | xmlWriter.setPrefix(prefix, namespace); |
||
| 918 | xmlWriter.writeAttribute(prefix, namespace, attName, attValue); |
||
| 919 | } |
||
| 920 | } |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Util method to write an attribute without the ns prefix |
||
| 924 | */ |
||
| 925 | private void writeAttribute(String namespace, |
||
| 926 | String attName, String attValue, |
||
| 927 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 928 | throws javax.xml.stream.XMLStreamException { |
||
| 929 | if (namespace.equals("")) { |
||
| 930 | xmlWriter.writeAttribute(attName, attValue); |
||
| 931 | } else { |
||
| 932 | xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), |
||
| 933 | namespace, attName, attValue); |
||
| 934 | } |
||
| 935 | } |
||
| 936 | |||
| 937 | /** |
||
| 938 | * Util method to write an attribute without the ns prefix |
||
| 939 | */ |
||
| 940 | private void writeQNameAttribute(String namespace, |
||
| 941 | String attName, javax.xml.namespace.QName qname, |
||
| 942 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 943 | throws javax.xml.stream.XMLStreamException { |
||
| 944 | String attributeNamespace = qname.getNamespaceURI(); |
||
| 945 | String attributePrefix = xmlWriter.getPrefix(attributeNamespace); |
||
| 946 | |||
| 947 | if (attributePrefix == null) { |
||
| 948 | attributePrefix = registerPrefix(xmlWriter, attributeNamespace); |
||
| 949 | } |
||
| 950 | |||
| 951 | String attributeValue; |
||
| 952 | |||
| 953 | if (attributePrefix.trim().length() > 0) { |
||
| 954 | attributeValue = attributePrefix + ":" + qname.getLocalPart(); |
||
| 955 | } else { |
||
| 956 | attributeValue = qname.getLocalPart(); |
||
| 957 | } |
||
| 958 | |||
| 959 | if (namespace.equals("")) { |
||
| 960 | xmlWriter.writeAttribute(attName, attributeValue); |
||
| 961 | } else { |
||
| 962 | registerPrefix(xmlWriter, namespace); |
||
| 963 | xmlWriter.writeAttribute(attributePrefix, namespace, attName, |
||
| 964 | attributeValue); |
||
| 965 | } |
||
| 966 | } |
||
| 967 | |||
| 968 | /** |
||
| 969 | * method to handle Qnames |
||
| 970 | */ |
||
| 971 | private void writeQName(javax.xml.namespace.QName qname, |
||
| 972 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 973 | throws javax.xml.stream.XMLStreamException { |
||
| 974 | String namespaceURI = qname.getNamespaceURI(); |
||
| 975 | |||
| 976 | if (namespaceURI != null) { |
||
| 977 | String prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 978 | |||
| 979 | if (prefix == null) { |
||
| 980 | prefix = generatePrefix(namespaceURI); |
||
| 981 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 982 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 983 | } |
||
| 984 | |||
| 985 | if (prefix.trim().length() > 0) { |
||
| 986 | xmlWriter.writeCharacters(prefix + ":" + |
||
| 987 | org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 988 | qname)); |
||
| 989 | } else { |
||
| 990 | // i.e this is the default namespace |
||
| 991 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 992 | qname)); |
||
| 993 | } |
||
| 994 | } else { |
||
| 995 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 996 | qname)); |
||
| 997 | } |
||
| 998 | } |
||
| 999 | |||
| 1000 | private void writeQNames(javax.xml.namespace.QName[] qnames, |
||
| 1001 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1002 | throws javax.xml.stream.XMLStreamException { |
||
| 1003 | if (qnames != null) { |
||
| 1004 | // we have to store this data until last moment since it is not possible to write any |
||
| 1005 | // namespace data after writing the charactor data |
||
| 1006 | StringBuffer stringToWrite = new StringBuffer(); |
||
| 1007 | String namespaceURI = null; |
||
| 1008 | String prefix = null; |
||
| 1009 | |||
| 1010 | for (int i = 0; i < qnames.length; i++) { |
||
| 1011 | if (i > 0) { |
||
| 1012 | stringToWrite.append(" "); |
||
| 1013 | } |
||
| 1014 | |||
| 1015 | namespaceURI = qnames[i].getNamespaceURI(); |
||
| 1016 | |||
| 1017 | if (namespaceURI != null) { |
||
| 1018 | prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1019 | |||
| 1020 | if ((prefix == null) || (prefix.length() == 0)) { |
||
| 1021 | prefix = generatePrefix(namespaceURI); |
||
| 1022 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1023 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1024 | } |
||
| 1025 | |||
| 1026 | if (prefix.trim().length() > 0) { |
||
| 1027 | stringToWrite.append(prefix).append(":") |
||
| 1028 | .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1029 | qnames[i])); |
||
| 1030 | } else { |
||
| 1031 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1032 | qnames[i])); |
||
| 1033 | } |
||
| 1034 | } else { |
||
| 1035 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1036 | qnames[i])); |
||
| 1037 | } |
||
| 1038 | } |
||
| 1039 | |||
| 1040 | xmlWriter.writeCharacters(stringToWrite.toString()); |
||
| 1041 | } |
||
| 1042 | } |
||
| 1043 | |||
| 1044 | /** |
||
| 1045 | * Register a namespace prefix |
||
| 1046 | */ |
||
| 1047 | private String registerPrefix( |
||
| 1048 | javax.xml.stream.XMLStreamWriter xmlWriter, |
||
| 1049 | String namespace) |
||
| 1050 | throws javax.xml.stream.XMLStreamException { |
||
| 1051 | String prefix = xmlWriter.getPrefix(namespace); |
||
| 1052 | |||
| 1053 | if (prefix == null) { |
||
| 1054 | prefix = generatePrefix(namespace); |
||
| 1055 | |||
| 1056 | javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); |
||
| 1057 | |||
| 1058 | while (true) { |
||
| 1059 | String uri = nsContext.getNamespaceURI(prefix); |
||
| 1060 | |||
| 1061 | if ((uri == null) || (uri.length() == 0)) { |
||
| 1062 | break; |
||
| 1063 | } |
||
| 1064 | |||
| 1065 | prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1066 | } |
||
| 1067 | |||
| 1068 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1069 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1070 | } |
||
| 1071 | |||
| 1072 | return prefix; |
||
| 1073 | } |
||
| 1074 | |||
| 1075 | /** |
||
| 1076 | * Factory class that keeps the parse method |
||
| 1077 | */ |
||
| 1078 | public static class Factory { |
||
| 1079 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); |
||
| 1080 | |||
| 1081 | /** |
||
| 1082 | * static method to create the object |
||
| 1083 | * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable |
||
| 1084 | * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element |
||
| 1085 | * Postcondition: If this object is an element, the reader is positioned at its end element |
||
| 1086 | * If this object is a complex type, the reader is positioned at the end element of its outer element |
||
| 1087 | */ |
||
| 1088 | public static NfeResultMsg parse( |
||
| 1089 | javax.xml.stream.XMLStreamReader reader) |
||
| 1090 | throws Exception { |
||
| 1091 | NfeResultMsg object = new NfeResultMsg(); |
||
| 1092 | |||
| 1093 | int event; |
||
| 1094 | javax.xml.namespace.QName currentQName = null; |
||
| 1095 | String nillableValue = null; |
||
| 1096 | String prefix = ""; |
||
| 1097 | String namespaceuri = ""; |
||
| 1098 | |||
| 1099 | try { |
||
| 1100 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1101 | reader.next(); |
||
| 1102 | |||
| 1103 | currentQName = reader.getName(); |
||
| 1104 | |||
| 1105 | if (reader.getAttributeValue( |
||
| 1106 | "http://www.w3.org/2001/XMLSchema-instance", |
||
| 1107 | "type") != null) { |
||
| 1108 | String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", |
||
| 1109 | "type"); |
||
| 1110 | |||
| 1111 | if (fullTypeName != null) { |
||
| 1112 | String nsPrefix = null; |
||
| 1113 | |||
| 1114 | if (fullTypeName.indexOf(":") > -1) { |
||
| 1115 | nsPrefix = fullTypeName.substring(0, |
||
| 1116 | fullTypeName.indexOf(":")); |
||
| 1117 | } |
||
| 1118 | |||
| 1119 | nsPrefix = (nsPrefix == null) ? "" : nsPrefix; |
||
| 1120 | |||
| 1121 | String type = fullTypeName.substring(fullTypeName.indexOf( |
||
| 1122 | ":") + 1); |
||
| 1123 | |||
| 1124 | if (!"nfeResultMsg".equals(type)) { |
||
| 1125 | //find namespace for the prefix |
||
| 1126 | String nsUri = reader.getNamespaceContext() |
||
| 1127 | .getNamespaceURI(nsPrefix); |
||
| 1128 | |||
| 1129 | return (NfeResultMsg) ExtensionMapper.getTypeObject(nsUri, |
||
| 1130 | type, reader); |
||
| 1131 | } |
||
| 1132 | } |
||
| 1133 | } |
||
| 1134 | |||
| 1135 | // Note all attributes that were handled. Used to differ normal attributes |
||
| 1136 | // from anyAttributes. |
||
| 1137 | java.util.Vector handledAttributes = new java.util.Vector(); |
||
| 1138 | |||
| 1139 | reader.next(); |
||
| 1140 | |||
| 1141 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1142 | reader.next(); |
||
| 1143 | |||
| 1144 | if (reader.isStartElement()) { |
||
| 1145 | //use the QName from the parser as the name for the builder |
||
| 1146 | javax.xml.namespace.QName startQname1 = reader.getName(); |
||
| 1147 | |||
| 1148 | // We need to wrap the reader so that it produces a fake START_DOCUMENT event |
||
| 1149 | // this is needed by the builder classes |
||
| 1150 | org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = |
||
| 1151 | new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(new org.apache.axis2.util.StreamWrapper( |
||
| 1152 | reader), startQname1); |
||
| 1153 | object.setExtraElement(builder1.getOMElement()); |
||
| 1154 | |||
| 1155 | reader.next(); |
||
| 1156 | } // End of if for expected property start element |
||
| 1157 | |||
| 1158 | else { |
||
| 1159 | // 1 - A start element we are not expecting indicates an invalid parameter was passed |
||
| 1160 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1161 | "Unexpected subelement " + reader.getName()); |
||
| 1162 | } |
||
| 1163 | |||
| 1164 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1165 | reader.next(); |
||
| 1166 | |||
| 1167 | if (reader.isStartElement()) { |
||
| 1168 | // 2 - A start element we are not expecting indicates a trailing invalid property |
||
| 1169 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1170 | "Unexpected subelement " + reader.getName()); |
||
| 1171 | } |
||
| 1172 | } catch (javax.xml.stream.XMLStreamException e) { |
||
| 1173 | throw new Exception(e); |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | return object; |
||
| 1177 | } |
||
| 1178 | } //end of factory class |
||
| 1179 | } |
||
| 1180 | |||
| 1181 | public static class NfeDadosMsg implements org.apache.axis2.databinding.ADBBean { |
||
| 1182 | public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 1183 | "nfeDadosMsg", "ns1"); |
||
| 1184 | |||
| 1185 | /** |
||
| 1186 | * field for ExtraElement |
||
| 1187 | */ |
||
| 1188 | protected org.apache.axiom.om.OMElement localExtraElement; |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Auto generated getter method |
||
| 1192 | * @return org.apache.axiom.om.OMElement |
||
| 1193 | */ |
||
| 1194 | public org.apache.axiom.om.OMElement getExtraElement() { |
||
| 1195 | return localExtraElement; |
||
| 1196 | } |
||
| 1197 | |||
| 1198 | /** |
||
| 1199 | * Auto generated setter method |
||
| 1200 | * @param param ExtraElement |
||
| 1201 | */ |
||
| 1202 | public void setExtraElement(org.apache.axiom.om.OMElement param) { |
||
| 1203 | this.localExtraElement = param; |
||
| 1204 | } |
||
| 1205 | |||
| 1206 | /** |
||
| 1207 | * |
||
| 1208 | * @param parentQName |
||
| 1209 | * @param factory |
||
| 1210 | * @return org.apache.axiom.om.OMElement |
||
| 1211 | */ |
||
| 1212 | public org.apache.axiom.om.OMElement getOMElement( |
||
| 1213 | final javax.xml.namespace.QName parentQName, |
||
| 1214 | final org.apache.axiom.om.OMFactory factory) |
||
| 1215 | throws org.apache.axis2.databinding.ADBException { |
||
| 1216 | return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( |
||
| 1217 | this, MY_QNAME)); |
||
| 1218 | } |
||
| 1219 | |||
| 1220 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 1221 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1222 | throws javax.xml.stream.XMLStreamException, |
||
| 1223 | org.apache.axis2.databinding.ADBException { |
||
| 1224 | serialize(parentQName, xmlWriter, false); |
||
| 1225 | } |
||
| 1226 | |||
| 1227 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 1228 | javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) |
||
| 1229 | throws javax.xml.stream.XMLStreamException, |
||
| 1230 | org.apache.axis2.databinding.ADBException { |
||
| 1231 | String prefix = null; |
||
| 1232 | String namespace = null; |
||
| 1233 | |||
| 1234 | prefix = parentQName.getPrefix(); |
||
| 1235 | namespace = parentQName.getNamespaceURI(); |
||
| 1236 | writeStartElement(prefix, namespace, parentQName.getLocalPart(), |
||
| 1237 | xmlWriter); |
||
| 1238 | |||
| 1239 | if (serializeType) { |
||
| 1240 | String namespacePrefix = registerPrefix(xmlWriter, |
||
| 1241 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4"); |
||
| 1242 | |||
| 1243 | if ((namespacePrefix != null) && |
||
| 1244 | (namespacePrefix.trim().length() > 0)) { |
||
| 1245 | writeAttribute("xsi", |
||
| 1246 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 1247 | namespacePrefix + ":nfeDadosMsg", xmlWriter); |
||
| 1248 | } else { |
||
| 1249 | writeAttribute("xsi", |
||
| 1250 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 1251 | "nfeDadosMsg", xmlWriter); |
||
| 1252 | } |
||
| 1253 | } |
||
| 1254 | |||
| 1255 | if (localExtraElement != null) { |
||
| 1256 | localExtraElement.serialize(xmlWriter); |
||
| 1257 | } else { |
||
| 1258 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1259 | "extraElement cannot be null!!"); |
||
| 1260 | } |
||
| 1261 | |||
| 1262 | xmlWriter.writeEndElement(); |
||
| 1263 | } |
||
| 1264 | |||
| 1265 | private static String generatePrefix( |
||
| 1266 | String namespace) { |
||
| 1267 | if (namespace.equals( |
||
| 1268 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4")) { |
||
| 1269 | return "ns1"; |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1273 | } |
||
| 1274 | |||
| 1275 | /** |
||
| 1276 | * Utility method to write an element start tag. |
||
| 1277 | */ |
||
| 1278 | private void writeStartElement(String prefix, |
||
| 1279 | String namespace, String localPart, |
||
| 1280 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1281 | throws javax.xml.stream.XMLStreamException { |
||
| 1282 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 1283 | |||
| 1284 | if (writerPrefix != null) { |
||
| 1285 | xmlWriter.writeStartElement(writerPrefix, localPart, namespace); |
||
| 1286 | } else { |
||
| 1287 | if (namespace.length() == 0) { |
||
| 1288 | prefix = ""; |
||
| 1289 | } else if (prefix == null) { |
||
| 1290 | prefix = generatePrefix(namespace); |
||
| 1291 | } |
||
| 1292 | |||
| 1293 | xmlWriter.writeStartElement(prefix, localPart, namespace); |
||
| 1294 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1295 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1296 | } |
||
| 1297 | } |
||
| 1298 | |||
| 1299 | /** |
||
| 1300 | * Util method to write an attribute with the ns prefix |
||
| 1301 | */ |
||
| 1302 | private void writeAttribute(String prefix, |
||
| 1303 | String namespace, String attName, |
||
| 1304 | String attValue, |
||
| 1305 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1306 | throws javax.xml.stream.XMLStreamException { |
||
| 1307 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 1308 | |||
| 1309 | if (writerPrefix != null) { |
||
| 1310 | xmlWriter.writeAttribute(writerPrefix, namespace, attName, |
||
| 1311 | attValue); |
||
| 1312 | } else { |
||
| 1313 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1314 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1315 | xmlWriter.writeAttribute(prefix, namespace, attName, attValue); |
||
| 1316 | } |
||
| 1317 | } |
||
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Util method to write an attribute without the ns prefix |
||
| 1321 | */ |
||
| 1322 | private void writeAttribute(String namespace, |
||
| 1323 | String attName, String attValue, |
||
| 1324 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1325 | throws javax.xml.stream.XMLStreamException { |
||
| 1326 | if (namespace.equals("")) { |
||
| 1327 | xmlWriter.writeAttribute(attName, attValue); |
||
| 1328 | } else { |
||
| 1329 | xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), |
||
| 1330 | namespace, attName, attValue); |
||
| 1331 | } |
||
| 1332 | } |
||
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Util method to write an attribute without the ns prefix |
||
| 1336 | */ |
||
| 1337 | private void writeQNameAttribute(String namespace, |
||
| 1338 | String attName, javax.xml.namespace.QName qname, |
||
| 1339 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1340 | throws javax.xml.stream.XMLStreamException { |
||
| 1341 | String attributeNamespace = qname.getNamespaceURI(); |
||
| 1342 | String attributePrefix = xmlWriter.getPrefix(attributeNamespace); |
||
| 1343 | |||
| 1344 | if (attributePrefix == null) { |
||
| 1345 | attributePrefix = registerPrefix(xmlWriter, attributeNamespace); |
||
| 1346 | } |
||
| 1347 | |||
| 1348 | String attributeValue; |
||
| 1349 | |||
| 1350 | if (attributePrefix.trim().length() > 0) { |
||
| 1351 | attributeValue = attributePrefix + ":" + qname.getLocalPart(); |
||
| 1352 | } else { |
||
| 1353 | attributeValue = qname.getLocalPart(); |
||
| 1354 | } |
||
| 1355 | |||
| 1356 | if (namespace.equals("")) { |
||
| 1357 | xmlWriter.writeAttribute(attName, attributeValue); |
||
| 1358 | } else { |
||
| 1359 | registerPrefix(xmlWriter, namespace); |
||
| 1360 | xmlWriter.writeAttribute(attributePrefix, namespace, attName, |
||
| 1361 | attributeValue); |
||
| 1362 | } |
||
| 1363 | } |
||
| 1364 | |||
| 1365 | /** |
||
| 1366 | * method to handle Qnames |
||
| 1367 | */ |
||
| 1368 | private void writeQName(javax.xml.namespace.QName qname, |
||
| 1369 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1370 | throws javax.xml.stream.XMLStreamException { |
||
| 1371 | String namespaceURI = qname.getNamespaceURI(); |
||
| 1372 | |||
| 1373 | if (namespaceURI != null) { |
||
| 1374 | String prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1375 | |||
| 1376 | if (prefix == null) { |
||
| 1377 | prefix = generatePrefix(namespaceURI); |
||
| 1378 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1379 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1380 | } |
||
| 1381 | |||
| 1382 | if (prefix.trim().length() > 0) { |
||
| 1383 | xmlWriter.writeCharacters(prefix + ":" + |
||
| 1384 | org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1385 | qname)); |
||
| 1386 | } else { |
||
| 1387 | // i.e this is the default namespace |
||
| 1388 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1389 | qname)); |
||
| 1390 | } |
||
| 1391 | } else { |
||
| 1392 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1393 | qname)); |
||
| 1394 | } |
||
| 1395 | } |
||
| 1396 | |||
| 1397 | private void writeQNames(javax.xml.namespace.QName[] qnames, |
||
| 1398 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1399 | throws javax.xml.stream.XMLStreamException { |
||
| 1400 | if (qnames != null) { |
||
| 1401 | // we have to store this data until last moment since it is not possible to write any |
||
| 1402 | // namespace data after writing the charactor data |
||
| 1403 | StringBuffer stringToWrite = new StringBuffer(); |
||
| 1404 | String namespaceURI = null; |
||
| 1405 | String prefix = null; |
||
| 1406 | |||
| 1407 | for (int i = 0; i < qnames.length; i++) { |
||
| 1408 | if (i > 0) { |
||
| 1409 | stringToWrite.append(" "); |
||
| 1410 | } |
||
| 1411 | |||
| 1412 | namespaceURI = qnames[i].getNamespaceURI(); |
||
| 1413 | |||
| 1414 | if (namespaceURI != null) { |
||
| 1415 | prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1416 | |||
| 1417 | if ((prefix == null) || (prefix.length() == 0)) { |
||
| 1418 | prefix = generatePrefix(namespaceURI); |
||
| 1419 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1420 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1421 | } |
||
| 1422 | |||
| 1423 | if (prefix.trim().length() > 0) { |
||
| 1424 | stringToWrite.append(prefix).append(":") |
||
| 1425 | .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1426 | qnames[i])); |
||
| 1427 | } else { |
||
| 1428 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1429 | qnames[i])); |
||
| 1430 | } |
||
| 1431 | } else { |
||
| 1432 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1433 | qnames[i])); |
||
| 1434 | } |
||
| 1435 | } |
||
| 1436 | |||
| 1437 | xmlWriter.writeCharacters(stringToWrite.toString()); |
||
| 1438 | } |
||
| 1439 | } |
||
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Register a namespace prefix |
||
| 1443 | */ |
||
| 1444 | private String registerPrefix( |
||
| 1445 | javax.xml.stream.XMLStreamWriter xmlWriter, |
||
| 1446 | String namespace) |
||
| 1447 | throws javax.xml.stream.XMLStreamException { |
||
| 1448 | String prefix = xmlWriter.getPrefix(namespace); |
||
| 1449 | |||
| 1450 | if (prefix == null) { |
||
| 1451 | prefix = generatePrefix(namespace); |
||
| 1452 | |||
| 1453 | javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); |
||
| 1454 | |||
| 1455 | while (true) { |
||
| 1456 | String uri = nsContext.getNamespaceURI(prefix); |
||
| 1457 | |||
| 1458 | if ((uri == null) || (uri.length() == 0)) { |
||
| 1459 | break; |
||
| 1460 | } |
||
| 1461 | |||
| 1462 | prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1463 | } |
||
| 1464 | |||
| 1465 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1466 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1467 | } |
||
| 1468 | |||
| 1469 | return prefix; |
||
| 1470 | } |
||
| 1471 | |||
| 1472 | /** |
||
| 1473 | * Factory class that keeps the parse method |
||
| 1474 | */ |
||
| 1475 | public static class Factory { |
||
| 1476 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); |
||
| 1477 | |||
| 1478 | /** |
||
| 1479 | * static method to create the object |
||
| 1480 | * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable |
||
| 1481 | * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element |
||
| 1482 | * Postcondition: If this object is an element, the reader is positioned at its end element |
||
| 1483 | * If this object is a complex type, the reader is positioned at the end element of its outer element |
||
| 1484 | */ |
||
| 1485 | public static NfeDadosMsg parse( |
||
| 1486 | javax.xml.stream.XMLStreamReader reader) |
||
| 1487 | throws Exception { |
||
| 1488 | NfeDadosMsg object = new NfeDadosMsg(); |
||
| 1489 | |||
| 1490 | int event; |
||
| 1491 | javax.xml.namespace.QName currentQName = null; |
||
| 1492 | String nillableValue = null; |
||
| 1493 | String prefix = ""; |
||
| 1494 | String namespaceuri = ""; |
||
| 1495 | |||
| 1496 | try { |
||
| 1497 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1498 | reader.next(); |
||
| 1499 | |||
| 1500 | currentQName = reader.getName(); |
||
| 1501 | |||
| 1502 | if (reader.getAttributeValue( |
||
| 1503 | "http://www.w3.org/2001/XMLSchema-instance", |
||
| 1504 | "type") != null) { |
||
| 1505 | String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", |
||
| 1506 | "type"); |
||
| 1507 | |||
| 1508 | if (fullTypeName != null) { |
||
| 1509 | String nsPrefix = null; |
||
| 1510 | |||
| 1511 | if (fullTypeName.indexOf(":") > -1) { |
||
| 1512 | nsPrefix = fullTypeName.substring(0, |
||
| 1513 | fullTypeName.indexOf(":")); |
||
| 1514 | } |
||
| 1515 | |||
| 1516 | nsPrefix = (nsPrefix == null) ? "" : nsPrefix; |
||
| 1517 | |||
| 1518 | String type = fullTypeName.substring(fullTypeName.indexOf( |
||
| 1519 | ":") + 1); |
||
| 1520 | |||
| 1521 | if (!"nfeDadosMsg".equals(type)) { |
||
| 1522 | //find namespace for the prefix |
||
| 1523 | String nsUri = reader.getNamespaceContext() |
||
| 1524 | .getNamespaceURI(nsPrefix); |
||
| 1525 | |||
| 1526 | return (NfeDadosMsg) ExtensionMapper.getTypeObject(nsUri, |
||
| 1527 | type, reader); |
||
| 1528 | } |
||
| 1529 | } |
||
| 1530 | } |
||
| 1531 | |||
| 1532 | // Note all attributes that were handled. Used to differ normal attributes |
||
| 1533 | // from anyAttributes. |
||
| 1534 | java.util.Vector handledAttributes = new java.util.Vector(); |
||
| 1535 | |||
| 1536 | reader.next(); |
||
| 1537 | |||
| 1538 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1539 | reader.next(); |
||
| 1540 | |||
| 1541 | if (reader.isStartElement()) { |
||
| 1542 | //use the QName from the parser as the name for the builder |
||
| 1543 | javax.xml.namespace.QName startQname1 = reader.getName(); |
||
| 1544 | |||
| 1545 | // We need to wrap the reader so that it produces a fake START_DOCUMENT event |
||
| 1546 | // this is needed by the builder classes |
||
| 1547 | org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = |
||
| 1548 | new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(new org.apache.axis2.util.StreamWrapper( |
||
| 1549 | reader), startQname1); |
||
| 1550 | object.setExtraElement(builder1.getOMElement()); |
||
| 1551 | |||
| 1552 | reader.next(); |
||
| 1553 | } // End of if for expected property start element |
||
| 1554 | |||
| 1555 | else { |
||
| 1556 | // 1 - A start element we are not expecting indicates an invalid parameter was passed |
||
| 1557 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1558 | "Unexpected subelement " + reader.getName()); |
||
| 1559 | } |
||
| 1560 | |||
| 1561 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1562 | reader.next(); |
||
| 1563 | |||
| 1564 | if (reader.isStartElement()) { |
||
| 1565 | // 2 - A start element we are not expecting indicates a trailing invalid property |
||
| 1566 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1567 | "Unexpected subelement " + reader.getName()); |
||
| 1568 | } |
||
| 1569 | } catch (javax.xml.stream.XMLStreamException e) { |
||
| 1570 | throw new Exception(e); |
||
| 1571 | } |
||
| 1572 | |||
| 1573 | return object; |
||
| 1574 | } |
||
| 1575 | } //end of factory class |
||
| 1576 | } |
||
| 1577 | |||
| 1578 | public static class ExtensionMapper { |
||
| 1579 | public static Object getTypeObject( |
||
| 1580 | String namespaceURI, String typeName, |
||
| 1581 | javax.xml.stream.XMLStreamReader reader) throws Exception { |
||
| 1582 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1583 | "Unsupported type " + namespaceURI + " " + typeName); |
||
| 1584 | } |
||
| 1585 | } |
||
| 1586 | |||
| 1587 | public static class NfeDadosMsgZip implements org.apache.axis2.databinding.ADBBean { |
||
| 1588 | public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 1589 | "nfeDadosMsgZip", "ns1"); |
||
| 1590 | |||
| 1591 | /** |
||
| 1592 | * field for NfeDadosMsgZip |
||
| 1593 | */ |
||
| 1594 | protected String localNfeDadosMsgZip; |
||
| 1595 | |||
| 1596 | /** |
||
| 1597 | * Auto generated getter method |
||
| 1598 | * @return java.lang.String |
||
| 1599 | */ |
||
| 1600 | public String getNfeDadosMsgZip() { |
||
| 1601 | return localNfeDadosMsgZip; |
||
| 1602 | } |
||
| 1603 | |||
| 1604 | /** |
||
| 1605 | * Auto generated setter method |
||
| 1606 | * @param param NfeDadosMsgZip |
||
| 1607 | */ |
||
| 1608 | public void setNfeDadosMsgZip(String param) { |
||
| 1609 | this.localNfeDadosMsgZip = param; |
||
| 1610 | } |
||
| 1611 | |||
| 1612 | /** |
||
| 1613 | * |
||
| 1614 | * @param parentQName |
||
| 1615 | * @param factory |
||
| 1616 | * @return org.apache.axiom.om.OMElement |
||
| 1617 | */ |
||
| 1618 | public org.apache.axiom.om.OMElement getOMElement( |
||
| 1619 | final javax.xml.namespace.QName parentQName, |
||
| 1620 | final org.apache.axiom.om.OMFactory factory) |
||
| 1621 | throws org.apache.axis2.databinding.ADBException { |
||
| 1622 | return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( |
||
| 1623 | this, MY_QNAME)); |
||
| 1624 | } |
||
| 1625 | |||
| 1626 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 1627 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1628 | throws javax.xml.stream.XMLStreamException, |
||
| 1629 | org.apache.axis2.databinding.ADBException { |
||
| 1630 | serialize(parentQName, xmlWriter, false); |
||
| 1631 | } |
||
| 1632 | |||
| 1633 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 1634 | javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) |
||
| 1635 | throws javax.xml.stream.XMLStreamException, |
||
| 1636 | org.apache.axis2.databinding.ADBException { |
||
| 1637 | //We can safely assume an element has only one type associated with it |
||
| 1638 | String namespace = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4"; |
||
| 1639 | String _localName = "nfeDadosMsgZip"; |
||
| 1640 | |||
| 1641 | writeStartElement(null, namespace, _localName, xmlWriter); |
||
| 1642 | |||
| 1643 | // add the type details if this is used in a simple type |
||
| 1644 | if (serializeType) { |
||
| 1645 | String namespacePrefix = registerPrefix(xmlWriter, |
||
| 1646 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4"); |
||
| 1647 | |||
| 1648 | if ((namespacePrefix != null) && |
||
| 1649 | (namespacePrefix.trim().length() > 0)) { |
||
| 1650 | writeAttribute("xsi", |
||
| 1651 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 1652 | namespacePrefix + ":nfeDadosMsgZip", xmlWriter); |
||
| 1653 | } else { |
||
| 1654 | writeAttribute("xsi", |
||
| 1655 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 1656 | "nfeDadosMsgZip", xmlWriter); |
||
| 1657 | } |
||
| 1658 | } |
||
| 1659 | |||
| 1660 | if (localNfeDadosMsgZip == null) { |
||
| 1661 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1662 | "nfeDadosMsgZip cannot be null !!"); |
||
| 1663 | } else { |
||
| 1664 | xmlWriter.writeCharacters(localNfeDadosMsgZip); |
||
| 1665 | } |
||
| 1666 | |||
| 1667 | xmlWriter.writeEndElement(); |
||
| 1668 | } |
||
| 1669 | |||
| 1670 | private static String generatePrefix( |
||
| 1671 | String namespace) { |
||
| 1672 | if (namespace.equals( |
||
| 1673 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4")) { |
||
| 1674 | return "ns1"; |
||
| 1675 | } |
||
| 1676 | |||
| 1677 | return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1678 | } |
||
| 1679 | |||
| 1680 | /** |
||
| 1681 | * Utility method to write an element start tag. |
||
| 1682 | */ |
||
| 1683 | private void writeStartElement(String prefix, |
||
| 1684 | String namespace, String localPart, |
||
| 1685 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1686 | throws javax.xml.stream.XMLStreamException { |
||
| 1687 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 1688 | |||
| 1689 | if (writerPrefix != null) { |
||
| 1690 | xmlWriter.writeStartElement(writerPrefix, localPart, namespace); |
||
| 1691 | } else { |
||
| 1692 | if (namespace.length() == 0) { |
||
| 1693 | prefix = ""; |
||
| 1694 | } else if (prefix == null) { |
||
| 1695 | prefix = generatePrefix(namespace); |
||
| 1696 | } |
||
| 1697 | |||
| 1698 | xmlWriter.writeStartElement(prefix, localPart, namespace); |
||
| 1699 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1700 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1701 | } |
||
| 1702 | } |
||
| 1703 | |||
| 1704 | /** |
||
| 1705 | * Util method to write an attribute with the ns prefix |
||
| 1706 | */ |
||
| 1707 | private void writeAttribute(String prefix, |
||
| 1708 | String namespace, String attName, |
||
| 1709 | String attValue, |
||
| 1710 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1711 | throws javax.xml.stream.XMLStreamException { |
||
| 1712 | String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 1713 | |||
| 1714 | if (writerPrefix != null) { |
||
| 1715 | xmlWriter.writeAttribute(writerPrefix, namespace, attName, |
||
| 1716 | attValue); |
||
| 1717 | } else { |
||
| 1718 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1719 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1720 | xmlWriter.writeAttribute(prefix, namespace, attName, attValue); |
||
| 1721 | } |
||
| 1722 | } |
||
| 1723 | |||
| 1724 | /** |
||
| 1725 | * Util method to write an attribute without the ns prefix |
||
| 1726 | */ |
||
| 1727 | private void writeAttribute(String namespace, |
||
| 1728 | String attName, String attValue, |
||
| 1729 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1730 | throws javax.xml.stream.XMLStreamException { |
||
| 1731 | if (namespace.equals("")) { |
||
| 1732 | xmlWriter.writeAttribute(attName, attValue); |
||
| 1733 | } else { |
||
| 1734 | xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), |
||
| 1735 | namespace, attName, attValue); |
||
| 1736 | } |
||
| 1737 | } |
||
| 1738 | |||
| 1739 | /** |
||
| 1740 | * Util method to write an attribute without the ns prefix |
||
| 1741 | */ |
||
| 1742 | private void writeQNameAttribute(String namespace, |
||
| 1743 | String attName, javax.xml.namespace.QName qname, |
||
| 1744 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1745 | throws javax.xml.stream.XMLStreamException { |
||
| 1746 | String attributeNamespace = qname.getNamespaceURI(); |
||
| 1747 | String attributePrefix = xmlWriter.getPrefix(attributeNamespace); |
||
| 1748 | |||
| 1749 | if (attributePrefix == null) { |
||
| 1750 | attributePrefix = registerPrefix(xmlWriter, attributeNamespace); |
||
| 1751 | } |
||
| 1752 | |||
| 1753 | String attributeValue; |
||
| 1754 | |||
| 1755 | if (attributePrefix.trim().length() > 0) { |
||
| 1756 | attributeValue = attributePrefix + ":" + qname.getLocalPart(); |
||
| 1757 | } else { |
||
| 1758 | attributeValue = qname.getLocalPart(); |
||
| 1759 | } |
||
| 1760 | |||
| 1761 | if (namespace.equals("")) { |
||
| 1762 | xmlWriter.writeAttribute(attName, attributeValue); |
||
| 1763 | } else { |
||
| 1764 | registerPrefix(xmlWriter, namespace); |
||
| 1765 | xmlWriter.writeAttribute(attributePrefix, namespace, attName, |
||
| 1766 | attributeValue); |
||
| 1767 | } |
||
| 1768 | } |
||
| 1769 | |||
| 1770 | /** |
||
| 1771 | * method to handle Qnames |
||
| 1772 | */ |
||
| 1773 | private void writeQName(javax.xml.namespace.QName qname, |
||
| 1774 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1775 | throws javax.xml.stream.XMLStreamException { |
||
| 1776 | String namespaceURI = qname.getNamespaceURI(); |
||
| 1777 | |||
| 1778 | if (namespaceURI != null) { |
||
| 1779 | String prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1780 | |||
| 1781 | if (prefix == null) { |
||
| 1782 | prefix = generatePrefix(namespaceURI); |
||
| 1783 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1784 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1785 | } |
||
| 1786 | |||
| 1787 | if (prefix.trim().length() > 0) { |
||
| 1788 | xmlWriter.writeCharacters(prefix + ":" + |
||
| 1789 | org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1790 | qname)); |
||
| 1791 | } else { |
||
| 1792 | // i.e this is the default namespace |
||
| 1793 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1794 | qname)); |
||
| 1795 | } |
||
| 1796 | } else { |
||
| 1797 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1798 | qname)); |
||
| 1799 | } |
||
| 1800 | } |
||
| 1801 | |||
| 1802 | private void writeQNames(javax.xml.namespace.QName[] qnames, |
||
| 1803 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1804 | throws javax.xml.stream.XMLStreamException { |
||
| 1805 | if (qnames != null) { |
||
| 1806 | // we have to store this data until last moment since it is not possible to write any |
||
| 1807 | // namespace data after writing the charactor data |
||
| 1808 | StringBuffer stringToWrite = new StringBuffer(); |
||
| 1809 | String namespaceURI = null; |
||
| 1810 | String prefix = null; |
||
| 1811 | |||
| 1812 | for (int i = 0; i < qnames.length; i++) { |
||
| 1813 | if (i > 0) { |
||
| 1814 | stringToWrite.append(" "); |
||
| 1815 | } |
||
| 1816 | |||
| 1817 | namespaceURI = qnames[i].getNamespaceURI(); |
||
| 1818 | |||
| 1819 | if (namespaceURI != null) { |
||
| 1820 | prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1821 | |||
| 1822 | if ((prefix == null) || (prefix.length() == 0)) { |
||
| 1823 | prefix = generatePrefix(namespaceURI); |
||
| 1824 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1825 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1826 | } |
||
| 1827 | |||
| 1828 | if (prefix.trim().length() > 0) { |
||
| 1829 | stringToWrite.append(prefix).append(":") |
||
| 1830 | .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1831 | qnames[i])); |
||
| 1832 | } else { |
||
| 1833 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1834 | qnames[i])); |
||
| 1835 | } |
||
| 1836 | } else { |
||
| 1837 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1838 | qnames[i])); |
||
| 1839 | } |
||
| 1840 | } |
||
| 1841 | |||
| 1842 | xmlWriter.writeCharacters(stringToWrite.toString()); |
||
| 1843 | } |
||
| 1844 | } |
||
| 1845 | |||
| 1846 | /** |
||
| 1847 | * Register a namespace prefix |
||
| 1848 | */ |
||
| 1849 | private String registerPrefix( |
||
| 1850 | javax.xml.stream.XMLStreamWriter xmlWriter, |
||
| 1851 | String namespace) |
||
| 1852 | throws javax.xml.stream.XMLStreamException { |
||
| 1853 | String prefix = xmlWriter.getPrefix(namespace); |
||
| 1854 | |||
| 1855 | if (prefix == null) { |
||
| 1856 | prefix = generatePrefix(namespace); |
||
| 1857 | |||
| 1858 | javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); |
||
| 1859 | |||
| 1860 | while (true) { |
||
| 1861 | String uri = nsContext.getNamespaceURI(prefix); |
||
| 1862 | |||
| 1863 | if ((uri == null) || (uri.length() == 0)) { |
||
| 1864 | break; |
||
| 1865 | } |
||
| 1866 | |||
| 1867 | prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1868 | } |
||
| 1869 | |||
| 1870 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1871 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1872 | } |
||
| 1873 | |||
| 1874 | return prefix; |
||
| 1875 | } |
||
| 1876 | |||
| 1877 | /** |
||
| 1878 | * Factory class that keeps the parse method |
||
| 1879 | */ |
||
| 1880 | public static class Factory { |
||
| 1881 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); |
||
| 1882 | |||
| 1883 | /** |
||
| 1884 | * static method to create the object |
||
| 1885 | * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable |
||
| 1886 | * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element |
||
| 1887 | * Postcondition: If this object is an element, the reader is positioned at its end element |
||
| 1888 | * If this object is a complex type, the reader is positioned at the end element of its outer element |
||
| 1889 | */ |
||
| 1890 | public static NfeDadosMsgZip parse( |
||
| 1891 | javax.xml.stream.XMLStreamReader reader) |
||
| 1892 | throws Exception { |
||
| 1893 | NfeDadosMsgZip object = new NfeDadosMsgZip(); |
||
| 1894 | |||
| 1895 | int event; |
||
| 1896 | javax.xml.namespace.QName currentQName = null; |
||
| 1897 | String nillableValue = null; |
||
| 1898 | String prefix = ""; |
||
| 1899 | String namespaceuri = ""; |
||
| 1900 | |||
| 1901 | try { |
||
| 1902 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1903 | reader.next(); |
||
| 1904 | |||
| 1905 | currentQName = reader.getName(); |
||
| 1906 | |||
| 1907 | // Note all attributes that were handled. Used to differ normal attributes |
||
| 1908 | // from anyAttributes. |
||
| 1909 | java.util.Vector handledAttributes = new java.util.Vector(); |
||
| 1910 | |||
| 1911 | while (!reader.isEndElement()) { |
||
| 1912 | if (reader.isStartElement()) { |
||
| 1913 | if ((reader.isStartElement() && |
||
| 1914 | new javax.xml.namespace.QName( |
||
| 1915 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4", |
||
| 1916 | "nfeDadosMsgZip").equals( |
||
| 1917 | reader.getName())) || |
||
| 1918 | new javax.xml.namespace.QName("", |
||
| 1919 | "nfeDadosMsgZip").equals( |
||
| 1920 | reader.getName())) { |
||
| 1921 | nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", |
||
| 1922 | "nil"); |
||
| 1923 | |||
| 1924 | if ("true".equals(nillableValue) || |
||
| 1925 | "1".equals(nillableValue)) { |
||
| 1926 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1927 | "The element: " + "nfeDadosMsgZip" + |
||
| 1928 | " cannot be null"); |
||
| 1929 | } |
||
| 1930 | |||
| 1931 | String content = reader.getElementText(); |
||
| 1932 | |||
| 1933 | object.setNfeDadosMsgZip(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1934 | content)); |
||
| 1935 | } // End of if for expected property start element |
||
| 1936 | |||
| 1937 | else { |
||
| 1938 | // 3 - A start element we are not expecting indicates an invalid parameter was passed |
||
| 1939 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1940 | "Unexpected subelement " + |
||
| 1941 | reader.getName()); |
||
| 1942 | } |
||
| 1943 | } else { |
||
| 1944 | reader.next(); |
||
| 1945 | } |
||
| 1946 | } // end of while loop |
||
| 1947 | } catch (javax.xml.stream.XMLStreamException e) { |
||
| 1948 | throw new Exception(e); |
||
| 1949 | } |
||
| 1950 | |||
| 1951 | return object; |
||
| 1952 | } |
||
| 1953 | } //end of factory class |
||
| 1954 | } |
||
| 1955 | } |