Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 695 | blopes | 1 | /** |
| 2 | * NFeRecepcaoEvento4Stub.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.NFeRecepcaoEvento; |
||
| 8 | |||
| 9 | |||
| 10 | import org.apache.axis2.client.Stub; |
||
| 11 | |||
| 12 | /* |
||
| 13 | * NFeRecepcaoEvento4Stub java implementation |
||
| 14 | */ |
||
| 15 | public class NFeRecepcaoEvento4Stub 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 NFeRecepcaoEvento4Stub( |
||
| 29 | org.apache.axis2.context.ConfigurationContext configurationContext, |
||
| 30 | java.lang.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 NFeRecepcaoEvento4Stub( |
||
| 38 | org.apache.axis2.context.ConfigurationContext configurationContext, |
||
| 39 | java.lang.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 NFeRecepcaoEvento4Stub( |
||
| 62 | org.apache.axis2.context.ConfigurationContext configurationContext) |
||
| 63 | throws org.apache.axis2.AxisFault { |
||
| 64 | this(configurationContext, |
||
| 65 | "https://nfe.fazenda.sp.gov.br/ws/nferecepcaoevento4.asmx"); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Default Constructor |
||
| 70 | */ |
||
| 71 | public NFeRecepcaoEvento4Stub() throws org.apache.axis2.AxisFault { |
||
| 72 | this("https://nfe.fazenda.sp.gov.br/ws/nferecepcaoevento4.asmx"); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Constructor taking the target endpoint |
||
| 77 | */ |
||
| 78 | public NFeRecepcaoEvento4Stub(java.lang.String targetEndpoint) |
||
| 79 | throws org.apache.axis2.AxisFault { |
||
| 80 | this(null, targetEndpoint); |
||
| 81 | } |
||
| 82 | |||
| 83 | private static synchronized java.lang.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 java.lang.Long.toString(java.lang.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 | "NFeRecepcaoEvento4" + getUniqueSuffix()); |
||
| 99 | addAnonymousOperations(); |
||
| 100 | |||
| 101 | //creating the operations |
||
| 102 | org.apache.axis2.description.AxisOperation __operation; |
||
| 103 | |||
| 104 | _operations = new org.apache.axis2.description.AxisOperation[1]; |
||
| 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/NFeRecepcaoEvento4", |
||
| 110 | "nfeRecepcaoEvento")); |
||
| 111 | _service.addOperation(__operation); |
||
| 112 | |||
| 113 | _operations[0] = __operation; |
||
| 114 | } |
||
| 115 | |||
| 116 | //populates the faults |
||
| 117 | private void populateFaults() { |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Auto generated method signature |
||
| 122 | * Registro de Eventos da NF-e |
||
| 123 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4#nfeRecepcaoEvento |
||
| 124 | * @param nfeDadosMsg0 |
||
| 125 | */ |
||
| 126 | public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento( |
||
| 127 | NFeRecepcaoEvento4Stub.NfeDadosMsg nfeDadosMsg0) |
||
| 128 | throws java.rmi.RemoteException { |
||
| 129 | org.apache.axis2.context.MessageContext _messageContext = null; |
||
| 130 | |||
| 131 | try { |
||
| 132 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); |
||
| 133 | _operationClient.getOptions() |
||
| 134 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4/nfeRecepcaoEvento"); |
||
| 135 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 136 | |||
| 137 | addPropertyToOperationClient(_operationClient, |
||
| 138 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 139 | "&"); |
||
| 140 | |||
| 141 | // create a message context |
||
| 142 | _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 143 | |||
| 144 | // create SOAP envelope with that payload |
||
| 145 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 146 | |||
| 147 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 148 | .getSoapVersionURI()), |
||
| 149 | nfeDadosMsg0, |
||
| 150 | optimizeContent( |
||
| 151 | new javax.xml.namespace.QName( |
||
| 152 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 153 | "nfeRecepcaoEvento")), |
||
| 154 | new javax.xml.namespace.QName( |
||
| 155 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 156 | "nfeDadosMsg")); |
||
| 157 | |||
| 158 | //adding SOAP soap_headers |
||
| 159 | _serviceClient.addHeadersToEnvelope(env); |
||
| 160 | // set the message context with that soap envelope |
||
| 161 | _messageContext.setEnvelope(env); |
||
| 162 | |||
| 163 | // add the message contxt to the operation client |
||
| 164 | _operationClient.addMessageContext(_messageContext); |
||
| 165 | |||
| 166 | //execute the operation client |
||
| 167 | _operationClient.execute(true); |
||
| 168 | |||
| 169 | org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); |
||
| 170 | org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); |
||
| 171 | |||
| 172 | java.lang.Object object = fromOM(_returnEnv.getBody() |
||
| 173 | .getFirstElement(), |
||
| 174 | NFeRecepcaoEvento4Stub.NfeResultMsg.class); |
||
| 175 | |||
| 176 | return (NFeRecepcaoEvento4Stub.NfeResultMsg) object; |
||
| 177 | } catch (org.apache.axis2.AxisFault f) { |
||
| 178 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 179 | |||
| 180 | if (faultElt != null) { |
||
| 181 | if (faultExceptionNameMap.containsKey( |
||
| 182 | new org.apache.axis2.client.FaultMapKey( |
||
| 183 | faultElt.getQName(), "nfeRecepcaoEvento"))) { |
||
| 184 | //make the fault by reflection |
||
| 185 | try { |
||
| 186 | java.lang.String exceptionClassName = (java.lang.String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 187 | faultElt.getQName(), "nfeRecepcaoEvento")); |
||
| 188 | java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); |
||
| 189 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(java.lang.String.class); |
||
| 190 | java.lang.Exception ex = (java.lang.Exception) constructor.newInstance(f.getMessage()); |
||
| 191 | |||
| 192 | //message class |
||
| 193 | java.lang.String messageClassName = (java.lang.String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 194 | faultElt.getQName(), "nfeRecepcaoEvento")); |
||
| 195 | java.lang.Class messageClass = java.lang.Class.forName(messageClassName); |
||
| 196 | java.lang.Object messageObject = fromOM(faultElt, |
||
| 197 | messageClass); |
||
| 198 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 199 | new java.lang.Class[] { messageClass }); |
||
| 200 | m.invoke(ex, new java.lang.Object[] { messageObject }); |
||
| 201 | |||
| 202 | throw new java.rmi.RemoteException(ex.getMessage(), ex); |
||
| 203 | } catch (java.lang.ClassCastException e) { |
||
| 204 | // we cannot intantiate the class - throw the original Axis fault |
||
| 205 | throw f; |
||
| 206 | } catch (java.lang.ClassNotFoundException e) { |
||
| 207 | // we cannot intantiate the class - throw the original Axis fault |
||
| 208 | throw f; |
||
| 209 | } catch (java.lang.NoSuchMethodException e) { |
||
| 210 | // we cannot intantiate the class - throw the original Axis fault |
||
| 211 | throw f; |
||
| 212 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 213 | // we cannot intantiate the class - throw the original Axis fault |
||
| 214 | throw f; |
||
| 215 | } catch (java.lang.IllegalAccessException e) { |
||
| 216 | // we cannot intantiate the class - throw the original Axis fault |
||
| 217 | throw f; |
||
| 218 | } catch (java.lang.InstantiationException e) { |
||
| 219 | // we cannot intantiate the class - throw the original Axis fault |
||
| 220 | throw f; |
||
| 221 | } |
||
| 222 | } else { |
||
| 223 | throw f; |
||
| 224 | } |
||
| 225 | } else { |
||
| 226 | throw f; |
||
| 227 | } |
||
| 228 | } finally { |
||
| 229 | if (_messageContext.getTransportOut() != null) { |
||
| 230 | _messageContext.getTransportOut().getSender() |
||
| 231 | .cleanup(_messageContext); |
||
| 232 | } |
||
| 233 | } |
||
| 234 | } |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Auto generated method signature for Asynchronous Invocations |
||
| 238 | * Registro de Eventos da NF-e |
||
| 239 | * @see br.com.swconsultoria.www.nfe_400.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4#startnfeRecepcaoEvento |
||
| 240 | * @param nfeDadosMsg0 |
||
| 241 | */ |
||
| 242 | public void startnfeRecepcaoEvento( |
||
| 243 | NFeRecepcaoEvento4Stub.NfeDadosMsg nfeDadosMsg0, |
||
| 244 | final NFeRecepcaoEvento4CallbackHandler callback) |
||
| 245 | throws java.rmi.RemoteException { |
||
| 246 | org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); |
||
| 247 | _operationClient.getOptions() |
||
| 248 | .setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4/nfeRecepcaoEvento"); |
||
| 249 | _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); |
||
| 250 | |||
| 251 | addPropertyToOperationClient(_operationClient, |
||
| 252 | org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, |
||
| 253 | "&"); |
||
| 254 | |||
| 255 | // create SOAP envelope with that payload |
||
| 256 | org.apache.axiom.soap.SOAPEnvelope env = null; |
||
| 257 | final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); |
||
| 258 | |||
| 259 | //Style is Doc. |
||
| 260 | env = toEnvelope(Stub.getFactory(_operationClient.getOptions() |
||
| 261 | .getSoapVersionURI()), |
||
| 262 | nfeDadosMsg0, |
||
| 263 | optimizeContent( |
||
| 264 | new javax.xml.namespace.QName( |
||
| 265 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 266 | "nfeRecepcaoEvento")), |
||
| 267 | new javax.xml.namespace.QName( |
||
| 268 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 269 | "nfeDadosMsg")); |
||
| 270 | |||
| 271 | // adding SOAP soap_headers |
||
| 272 | _serviceClient.addHeadersToEnvelope(env); |
||
| 273 | // create message context with that soap envelope |
||
| 274 | _messageContext.setEnvelope(env); |
||
| 275 | |||
| 276 | // add the message context to the operation client |
||
| 277 | _operationClient.addMessageContext(_messageContext); |
||
| 278 | |||
| 279 | _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { |
||
| 280 | public void onMessage( |
||
| 281 | org.apache.axis2.context.MessageContext resultContext) { |
||
| 282 | try { |
||
| 283 | org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); |
||
| 284 | |||
| 285 | java.lang.Object object = fromOM(resultEnv.getBody() |
||
| 286 | .getFirstElement(), |
||
| 287 | NFeRecepcaoEvento4Stub.NfeResultMsg.class); |
||
| 288 | callback.receiveResultnfeRecepcaoEvento((NFeRecepcaoEvento4Stub.NfeResultMsg) object); |
||
| 289 | } catch (org.apache.axis2.AxisFault e) { |
||
| 290 | callback.receiveErrornfeRecepcaoEvento(e); |
||
| 291 | } |
||
| 292 | } |
||
| 293 | |||
| 294 | public void onError(java.lang.Exception error) { |
||
| 295 | if (error instanceof org.apache.axis2.AxisFault) { |
||
| 296 | org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; |
||
| 297 | org.apache.axiom.om.OMElement faultElt = f.getDetail(); |
||
| 298 | |||
| 299 | if (faultElt != null) { |
||
| 300 | if (faultExceptionNameMap.containsKey( |
||
| 301 | new org.apache.axis2.client.FaultMapKey( |
||
| 302 | faultElt.getQName(), |
||
| 303 | "nfeRecepcaoEvento"))) { |
||
| 304 | //make the fault by reflection |
||
| 305 | try { |
||
| 306 | java.lang.String exceptionClassName = (java.lang.String) faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 307 | faultElt.getQName(), |
||
| 308 | "nfeRecepcaoEvento")); |
||
| 309 | java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); |
||
| 310 | java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(java.lang.String.class); |
||
| 311 | java.lang.Exception ex = (java.lang.Exception) constructor.newInstance(f.getMessage()); |
||
| 312 | |||
| 313 | //message class |
||
| 314 | java.lang.String messageClassName = (java.lang.String) faultMessageMap.get(new org.apache.axis2.client.FaultMapKey( |
||
| 315 | faultElt.getQName(), |
||
| 316 | "nfeRecepcaoEvento")); |
||
| 317 | java.lang.Class messageClass = java.lang.Class.forName(messageClassName); |
||
| 318 | java.lang.Object messageObject = fromOM(faultElt, |
||
| 319 | messageClass); |
||
| 320 | java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", |
||
| 321 | new java.lang.Class[] { messageClass }); |
||
| 322 | m.invoke(ex, |
||
| 323 | new java.lang.Object[] { messageObject }); |
||
| 324 | |||
| 325 | callback.receiveErrornfeRecepcaoEvento(new java.rmi.RemoteException( |
||
| 326 | ex.getMessage(), ex)); |
||
| 327 | } catch (java.lang.ClassCastException e) { |
||
| 328 | // we cannot intantiate the class - throw the original Axis fault |
||
| 329 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 330 | } catch (java.lang.ClassNotFoundException e) { |
||
| 331 | // we cannot intantiate the class - throw the original Axis fault |
||
| 332 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 333 | } catch (java.lang.NoSuchMethodException e) { |
||
| 334 | // we cannot intantiate the class - throw the original Axis fault |
||
| 335 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 336 | } catch (java.lang.reflect.InvocationTargetException e) { |
||
| 337 | // we cannot intantiate the class - throw the original Axis fault |
||
| 338 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 339 | } catch (java.lang.IllegalAccessException e) { |
||
| 340 | // we cannot intantiate the class - throw the original Axis fault |
||
| 341 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 342 | } catch (java.lang.InstantiationException e) { |
||
| 343 | // we cannot intantiate the class - throw the original Axis fault |
||
| 344 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 345 | } catch (org.apache.axis2.AxisFault e) { |
||
| 346 | // we cannot intantiate the class - throw the original Axis fault |
||
| 347 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 348 | } |
||
| 349 | } else { |
||
| 350 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 351 | } |
||
| 352 | } else { |
||
| 353 | callback.receiveErrornfeRecepcaoEvento(f); |
||
| 354 | } |
||
| 355 | } else { |
||
| 356 | callback.receiveErrornfeRecepcaoEvento(error); |
||
| 357 | } |
||
| 358 | } |
||
| 359 | |||
| 360 | public void onFault( |
||
| 361 | org.apache.axis2.context.MessageContext faultContext) { |
||
| 362 | org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext); |
||
| 363 | onError(fault); |
||
| 364 | } |
||
| 365 | |||
| 366 | public void onComplete() { |
||
| 367 | try { |
||
| 368 | _messageContext.getTransportOut().getSender() |
||
| 369 | .cleanup(_messageContext); |
||
| 370 | } catch (org.apache.axis2.AxisFault axisFault) { |
||
| 371 | callback.receiveErrornfeRecepcaoEvento(axisFault); |
||
| 372 | } |
||
| 373 | } |
||
| 374 | }); |
||
| 375 | |||
| 376 | org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; |
||
| 377 | |||
| 378 | if ((_operations[0].getMessageReceiver() == null) && |
||
| 379 | _operationClient.getOptions().isUseSeparateListener()) { |
||
| 380 | _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); |
||
| 381 | _operations[0].setMessageReceiver(_callbackReceiver); |
||
| 382 | } |
||
| 383 | |||
| 384 | //execute the operation client |
||
| 385 | _operationClient.execute(false); |
||
| 386 | } |
||
| 387 | |||
| 388 | private boolean optimizeContent(javax.xml.namespace.QName opName) { |
||
| 389 | if (opNameArray == null) { |
||
| 390 | return false; |
||
| 391 | } |
||
| 392 | |||
| 393 | for (int i = 0; i < opNameArray.length; i++) { |
||
| 394 | if (opName.equals(opNameArray[i])) { |
||
| 395 | return true; |
||
| 396 | } |
||
| 397 | } |
||
| 398 | |||
| 399 | return false; |
||
| 400 | } |
||
| 401 | |||
| 402 | private org.apache.axiom.om.OMElement toOM( |
||
| 403 | NFeRecepcaoEvento4Stub.NfeDadosMsg param, |
||
| 404 | boolean optimizeContent) throws org.apache.axis2.AxisFault { |
||
| 405 | try { |
||
| 406 | return param.getOMElement(NFeRecepcaoEvento4Stub.NfeDadosMsg.MY_QNAME, |
||
| 407 | org.apache.axiom.om.OMAbstractFactory.getOMFactory()); |
||
| 408 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 409 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 410 | } |
||
| 411 | } |
||
| 412 | |||
| 413 | private org.apache.axiom.om.OMElement toOM( |
||
| 414 | NFeRecepcaoEvento4Stub.NfeResultMsg param, |
||
| 415 | boolean optimizeContent) throws org.apache.axis2.AxisFault { |
||
| 416 | try { |
||
| 417 | return param.getOMElement(NFeRecepcaoEvento4Stub.NfeResultMsg.MY_QNAME, |
||
| 418 | org.apache.axiom.om.OMAbstractFactory.getOMFactory()); |
||
| 419 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 420 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 421 | } |
||
| 422 | } |
||
| 423 | |||
| 424 | private org.apache.axiom.soap.SOAPEnvelope toEnvelope( |
||
| 425 | org.apache.axiom.soap.SOAPFactory factory, |
||
| 426 | NFeRecepcaoEvento4Stub.NfeDadosMsg param, |
||
| 427 | boolean optimizeContent, javax.xml.namespace.QName elementQName) |
||
| 428 | throws org.apache.axis2.AxisFault { |
||
| 429 | try { |
||
| 430 | org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); |
||
| 431 | emptyEnvelope.getBody() |
||
| 432 | .addChild(param.getOMElement( |
||
| 433 | NFeRecepcaoEvento4Stub.NfeDadosMsg.MY_QNAME, |
||
| 434 | factory)); |
||
| 435 | |||
| 436 | return emptyEnvelope; |
||
| 437 | } catch (org.apache.axis2.databinding.ADBException e) { |
||
| 438 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 439 | } |
||
| 440 | } |
||
| 441 | |||
| 442 | /* methods to provide back word compatibility */ |
||
| 443 | |||
| 444 | /** |
||
| 445 | * get the default envelope |
||
| 446 | */ |
||
| 447 | private org.apache.axiom.soap.SOAPEnvelope toEnvelope( |
||
| 448 | org.apache.axiom.soap.SOAPFactory factory) { |
||
| 449 | return factory.getDefaultEnvelope(); |
||
| 450 | } |
||
| 451 | |||
| 452 | private java.lang.Object fromOM(org.apache.axiom.om.OMElement param, |
||
| 453 | java.lang.Class type) throws org.apache.axis2.AxisFault { |
||
| 454 | try { |
||
| 455 | if (NFeRecepcaoEvento4Stub.NfeDadosMsg.class.equals( |
||
| 456 | type)) { |
||
| 457 | return NFeRecepcaoEvento4Stub.NfeDadosMsg.Factory.parse(param.getXMLStreamReaderWithoutCaching()); |
||
| 458 | } |
||
| 459 | |||
| 460 | if (NFeRecepcaoEvento4Stub.NfeResultMsg.class.equals( |
||
| 461 | type)) { |
||
| 462 | return NFeRecepcaoEvento4Stub.NfeResultMsg.Factory.parse(param.getXMLStreamReaderWithoutCaching()); |
||
| 463 | } |
||
| 464 | } catch (java.lang.Exception e) { |
||
| 465 | throw org.apache.axis2.AxisFault.makeFault(e); |
||
| 466 | } |
||
| 467 | |||
| 468 | return null; |
||
| 469 | } |
||
| 470 | |||
| 471 | //https://nfe.fazenda.sp.gov.br/ws/nferecepcaoevento4.asmx |
||
| 472 | public static class ExtensionMapper { |
||
| 473 | public static java.lang.Object getTypeObject( |
||
| 474 | java.lang.String namespaceURI, java.lang.String typeName, |
||
| 475 | javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { |
||
| 476 | throw new org.apache.axis2.databinding.ADBException( |
||
| 477 | "Unsupported type " + namespaceURI + " " + typeName); |
||
| 478 | } |
||
| 479 | } |
||
| 480 | |||
| 481 | public static class NfeResultMsg implements org.apache.axis2.databinding.ADBBean { |
||
| 482 | public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 483 | "nfeResultMsg", "ns1"); |
||
| 484 | |||
| 485 | /** |
||
| 486 | * field for ExtraElement |
||
| 487 | */ |
||
| 488 | protected org.apache.axiom.om.OMElement localExtraElement; |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Auto generated getter method |
||
| 492 | * @return org.apache.axiom.om.OMElement |
||
| 493 | */ |
||
| 494 | public org.apache.axiom.om.OMElement getExtraElement() { |
||
| 495 | return localExtraElement; |
||
| 496 | } |
||
| 497 | |||
| 498 | /** |
||
| 499 | * Auto generated setter method |
||
| 500 | * @param param ExtraElement |
||
| 501 | */ |
||
| 502 | public void setExtraElement(org.apache.axiom.om.OMElement param) { |
||
| 503 | this.localExtraElement = param; |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * |
||
| 508 | * @param parentQName |
||
| 509 | * @param factory |
||
| 510 | * @return org.apache.axiom.om.OMElement |
||
| 511 | */ |
||
| 512 | public org.apache.axiom.om.OMElement getOMElement( |
||
| 513 | final javax.xml.namespace.QName parentQName, |
||
| 514 | final org.apache.axiom.om.OMFactory factory) |
||
| 515 | throws org.apache.axis2.databinding.ADBException { |
||
| 516 | return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( |
||
| 517 | this, MY_QNAME)); |
||
| 518 | } |
||
| 519 | |||
| 520 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 521 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 522 | throws javax.xml.stream.XMLStreamException, |
||
| 523 | org.apache.axis2.databinding.ADBException { |
||
| 524 | serialize(parentQName, xmlWriter, false); |
||
| 525 | } |
||
| 526 | |||
| 527 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 528 | javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) |
||
| 529 | throws javax.xml.stream.XMLStreamException, |
||
| 530 | org.apache.axis2.databinding.ADBException { |
||
| 531 | java.lang.String prefix = null; |
||
| 532 | java.lang.String namespace = null; |
||
| 533 | |||
| 534 | prefix = parentQName.getPrefix(); |
||
| 535 | namespace = parentQName.getNamespaceURI(); |
||
| 536 | writeStartElement(prefix, namespace, parentQName.getLocalPart(), |
||
| 537 | xmlWriter); |
||
| 538 | |||
| 539 | if (serializeType) { |
||
| 540 | java.lang.String namespacePrefix = registerPrefix(xmlWriter, |
||
| 541 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4"); |
||
| 542 | |||
| 543 | if ((namespacePrefix != null) && |
||
| 544 | (namespacePrefix.trim().length() > 0)) { |
||
| 545 | writeAttribute("xsi", |
||
| 546 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 547 | namespacePrefix + ":nfeResultMsg", xmlWriter); |
||
| 548 | } else { |
||
| 549 | writeAttribute("xsi", |
||
| 550 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 551 | "nfeResultMsg", xmlWriter); |
||
| 552 | } |
||
| 553 | } |
||
| 554 | |||
| 555 | if (localExtraElement != null) { |
||
| 556 | localExtraElement.serialize(xmlWriter); |
||
| 557 | } else { |
||
| 558 | throw new org.apache.axis2.databinding.ADBException( |
||
| 559 | "extraElement cannot be null!!"); |
||
| 560 | } |
||
| 561 | |||
| 562 | xmlWriter.writeEndElement(); |
||
| 563 | } |
||
| 564 | |||
| 565 | private static java.lang.String generatePrefix( |
||
| 566 | java.lang.String namespace) { |
||
| 567 | if (namespace.equals( |
||
| 568 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4")) { |
||
| 569 | return "ns1"; |
||
| 570 | } |
||
| 571 | |||
| 572 | return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 573 | } |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Utility method to write an element start tag. |
||
| 577 | */ |
||
| 578 | private void writeStartElement(java.lang.String prefix, |
||
| 579 | java.lang.String namespace, java.lang.String localPart, |
||
| 580 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 581 | throws javax.xml.stream.XMLStreamException { |
||
| 582 | java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 583 | |||
| 584 | if (writerPrefix != null) { |
||
| 585 | xmlWriter.writeStartElement(writerPrefix, localPart, namespace); |
||
| 586 | } else { |
||
| 587 | if (namespace.length() == 0) { |
||
| 588 | prefix = ""; |
||
| 589 | } else if (prefix == null) { |
||
| 590 | prefix = generatePrefix(namespace); |
||
| 591 | } |
||
| 592 | |||
| 593 | xmlWriter.writeStartElement(prefix, localPart, namespace); |
||
| 594 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 595 | xmlWriter.setPrefix(prefix, namespace); |
||
| 596 | } |
||
| 597 | } |
||
| 598 | |||
| 599 | /** |
||
| 600 | * Util method to write an attribute with the ns prefix |
||
| 601 | */ |
||
| 602 | private void writeAttribute(java.lang.String prefix, |
||
| 603 | java.lang.String namespace, java.lang.String attName, |
||
| 604 | java.lang.String attValue, |
||
| 605 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 606 | throws javax.xml.stream.XMLStreamException { |
||
| 607 | java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 608 | |||
| 609 | if (writerPrefix != null) { |
||
| 610 | xmlWriter.writeAttribute(writerPrefix, namespace, attName, |
||
| 611 | attValue); |
||
| 612 | } else { |
||
| 613 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 614 | xmlWriter.setPrefix(prefix, namespace); |
||
| 615 | xmlWriter.writeAttribute(prefix, namespace, attName, attValue); |
||
| 616 | } |
||
| 617 | } |
||
| 618 | |||
| 619 | /** |
||
| 620 | * Util method to write an attribute without the ns prefix |
||
| 621 | */ |
||
| 622 | private void writeAttribute(java.lang.String namespace, |
||
| 623 | java.lang.String attName, java.lang.String attValue, |
||
| 624 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 625 | throws javax.xml.stream.XMLStreamException { |
||
| 626 | if (namespace.equals("")) { |
||
| 627 | xmlWriter.writeAttribute(attName, attValue); |
||
| 628 | } else { |
||
| 629 | xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), |
||
| 630 | namespace, attName, attValue); |
||
| 631 | } |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Util method to write an attribute without the ns prefix |
||
| 636 | */ |
||
| 637 | private void writeQNameAttribute(java.lang.String namespace, |
||
| 638 | java.lang.String attName, javax.xml.namespace.QName qname, |
||
| 639 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 640 | throws javax.xml.stream.XMLStreamException { |
||
| 641 | java.lang.String attributeNamespace = qname.getNamespaceURI(); |
||
| 642 | java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); |
||
| 643 | |||
| 644 | if (attributePrefix == null) { |
||
| 645 | attributePrefix = registerPrefix(xmlWriter, attributeNamespace); |
||
| 646 | } |
||
| 647 | |||
| 648 | java.lang.String attributeValue; |
||
| 649 | |||
| 650 | if (attributePrefix.trim().length() > 0) { |
||
| 651 | attributeValue = attributePrefix + ":" + qname.getLocalPart(); |
||
| 652 | } else { |
||
| 653 | attributeValue = qname.getLocalPart(); |
||
| 654 | } |
||
| 655 | |||
| 656 | if (namespace.equals("")) { |
||
| 657 | xmlWriter.writeAttribute(attName, attributeValue); |
||
| 658 | } else { |
||
| 659 | registerPrefix(xmlWriter, namespace); |
||
| 660 | xmlWriter.writeAttribute(attributePrefix, namespace, attName, |
||
| 661 | attributeValue); |
||
| 662 | } |
||
| 663 | } |
||
| 664 | |||
| 665 | /** |
||
| 666 | * method to handle Qnames |
||
| 667 | */ |
||
| 668 | private void writeQName(javax.xml.namespace.QName qname, |
||
| 669 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 670 | throws javax.xml.stream.XMLStreamException { |
||
| 671 | java.lang.String namespaceURI = qname.getNamespaceURI(); |
||
| 672 | |||
| 673 | if (namespaceURI != null) { |
||
| 674 | java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 675 | |||
| 676 | if (prefix == null) { |
||
| 677 | prefix = generatePrefix(namespaceURI); |
||
| 678 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 679 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 680 | } |
||
| 681 | |||
| 682 | if (prefix.trim().length() > 0) { |
||
| 683 | xmlWriter.writeCharacters(prefix + ":" + |
||
| 684 | org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 685 | qname)); |
||
| 686 | } else { |
||
| 687 | // i.e this is the default namespace |
||
| 688 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 689 | qname)); |
||
| 690 | } |
||
| 691 | } else { |
||
| 692 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 693 | qname)); |
||
| 694 | } |
||
| 695 | } |
||
| 696 | |||
| 697 | private void writeQNames(javax.xml.namespace.QName[] qnames, |
||
| 698 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 699 | throws javax.xml.stream.XMLStreamException { |
||
| 700 | if (qnames != null) { |
||
| 701 | // we have to store this data until last moment since it is not possible to write any |
||
| 702 | // namespace data after writing the charactor data |
||
| 703 | java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); |
||
| 704 | java.lang.String namespaceURI = null; |
||
| 705 | java.lang.String prefix = null; |
||
| 706 | |||
| 707 | for (int i = 0; i < qnames.length; i++) { |
||
| 708 | if (i > 0) { |
||
| 709 | stringToWrite.append(" "); |
||
| 710 | } |
||
| 711 | |||
| 712 | namespaceURI = qnames[i].getNamespaceURI(); |
||
| 713 | |||
| 714 | if (namespaceURI != null) { |
||
| 715 | prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 716 | |||
| 717 | if ((prefix == null) || (prefix.length() == 0)) { |
||
| 718 | prefix = generatePrefix(namespaceURI); |
||
| 719 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 720 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 721 | } |
||
| 722 | |||
| 723 | if (prefix.trim().length() > 0) { |
||
| 724 | stringToWrite.append(prefix).append(":") |
||
| 725 | .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 726 | qnames[i])); |
||
| 727 | } else { |
||
| 728 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 729 | qnames[i])); |
||
| 730 | } |
||
| 731 | } else { |
||
| 732 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 733 | qnames[i])); |
||
| 734 | } |
||
| 735 | } |
||
| 736 | |||
| 737 | xmlWriter.writeCharacters(stringToWrite.toString()); |
||
| 738 | } |
||
| 739 | } |
||
| 740 | |||
| 741 | /** |
||
| 742 | * Register a namespace prefix |
||
| 743 | */ |
||
| 744 | private java.lang.String registerPrefix( |
||
| 745 | javax.xml.stream.XMLStreamWriter xmlWriter, |
||
| 746 | java.lang.String namespace) |
||
| 747 | throws javax.xml.stream.XMLStreamException { |
||
| 748 | java.lang.String prefix = xmlWriter.getPrefix(namespace); |
||
| 749 | |||
| 750 | if (prefix == null) { |
||
| 751 | prefix = generatePrefix(namespace); |
||
| 752 | |||
| 753 | javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); |
||
| 754 | |||
| 755 | while (true) { |
||
| 756 | java.lang.String uri = nsContext.getNamespaceURI(prefix); |
||
| 757 | |||
| 758 | if ((uri == null) || (uri.length() == 0)) { |
||
| 759 | break; |
||
| 760 | } |
||
| 761 | |||
| 762 | prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 763 | } |
||
| 764 | |||
| 765 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 766 | xmlWriter.setPrefix(prefix, namespace); |
||
| 767 | } |
||
| 768 | |||
| 769 | return prefix; |
||
| 770 | } |
||
| 771 | |||
| 772 | /** |
||
| 773 | * Factory class that keeps the parse method |
||
| 774 | */ |
||
| 775 | public static class Factory { |
||
| 776 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); |
||
| 777 | |||
| 778 | /** |
||
| 779 | * static method to create the object |
||
| 780 | * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable |
||
| 781 | * 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 |
||
| 782 | * Postcondition: If this object is an element, the reader is positioned at its end element |
||
| 783 | * If this object is a complex type, the reader is positioned at the end element of its outer element |
||
| 784 | */ |
||
| 785 | public static NfeResultMsg parse( |
||
| 786 | javax.xml.stream.XMLStreamReader reader) |
||
| 787 | throws java.lang.Exception { |
||
| 788 | NfeResultMsg object = new NfeResultMsg(); |
||
| 789 | |||
| 790 | int event; |
||
| 791 | javax.xml.namespace.QName currentQName = null; |
||
| 792 | java.lang.String nillableValue = null; |
||
| 793 | java.lang.String prefix = ""; |
||
| 794 | java.lang.String namespaceuri = ""; |
||
| 795 | |||
| 796 | try { |
||
| 797 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 798 | reader.next(); |
||
| 799 | |||
| 800 | currentQName = reader.getName(); |
||
| 801 | |||
| 802 | if (reader.getAttributeValue( |
||
| 803 | "http://www.w3.org/2001/XMLSchema-instance", |
||
| 804 | "type") != null) { |
||
| 805 | java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", |
||
| 806 | "type"); |
||
| 807 | |||
| 808 | if (fullTypeName != null) { |
||
| 809 | java.lang.String nsPrefix = null; |
||
| 810 | |||
| 811 | if (fullTypeName.indexOf(":") > -1) { |
||
| 812 | nsPrefix = fullTypeName.substring(0, |
||
| 813 | fullTypeName.indexOf(":")); |
||
| 814 | } |
||
| 815 | |||
| 816 | nsPrefix = (nsPrefix == null) ? "" : nsPrefix; |
||
| 817 | |||
| 818 | java.lang.String type = fullTypeName.substring(fullTypeName.indexOf( |
||
| 819 | ":") + 1); |
||
| 820 | |||
| 821 | if (!"nfeResultMsg".equals(type)) { |
||
| 822 | //find namespace for the prefix |
||
| 823 | java.lang.String nsUri = reader.getNamespaceContext() |
||
| 824 | .getNamespaceURI(nsPrefix); |
||
| 825 | |||
| 826 | return (NfeResultMsg) ExtensionMapper.getTypeObject(nsUri, |
||
| 827 | type, reader); |
||
| 828 | } |
||
| 829 | } |
||
| 830 | } |
||
| 831 | |||
| 832 | // Note all attributes that were handled. Used to differ normal attributes |
||
| 833 | // from anyAttributes. |
||
| 834 | java.util.Vector handledAttributes = new java.util.Vector(); |
||
| 835 | |||
| 836 | reader.next(); |
||
| 837 | |||
| 838 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 839 | reader.next(); |
||
| 840 | |||
| 841 | if (reader.isStartElement()) { |
||
| 842 | //use the QName from the parser as the name for the builder |
||
| 843 | javax.xml.namespace.QName startQname1 = reader.getName(); |
||
| 844 | |||
| 845 | // We need to wrap the reader so that it produces a fake START_DOCUMENT event |
||
| 846 | // this is needed by the builder classes |
||
| 847 | org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = |
||
| 848 | new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(new org.apache.axis2.util.StreamWrapper( |
||
| 849 | reader), startQname1); |
||
| 850 | object.setExtraElement(builder1.getOMElement()); |
||
| 851 | |||
| 852 | reader.next(); |
||
| 853 | } // End of if for expected property start element |
||
| 854 | |||
| 855 | else { |
||
| 856 | // 1 - A start element we are not expecting indicates an invalid parameter was passed |
||
| 857 | throw new org.apache.axis2.databinding.ADBException( |
||
| 858 | "Unexpected subelement " + reader.getName()); |
||
| 859 | } |
||
| 860 | |||
| 861 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 862 | reader.next(); |
||
| 863 | |||
| 864 | if (reader.isStartElement()) { |
||
| 865 | // 2 - A start element we are not expecting indicates a trailing invalid property |
||
| 866 | throw new org.apache.axis2.databinding.ADBException( |
||
| 867 | "Unexpected subelement " + reader.getName()); |
||
| 868 | } |
||
| 869 | } catch (javax.xml.stream.XMLStreamException e) { |
||
| 870 | throw new java.lang.Exception(e); |
||
| 871 | } |
||
| 872 | |||
| 873 | return object; |
||
| 874 | } |
||
| 875 | } //end of factory class |
||
| 876 | } |
||
| 877 | |||
| 878 | public static class NfeDadosMsg implements org.apache.axis2.databinding.ADBBean { |
||
| 879 | public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4", |
||
| 880 | "nfeDadosMsg", "ns1"); |
||
| 881 | |||
| 882 | /** |
||
| 883 | * field for ExtraElement |
||
| 884 | */ |
||
| 885 | protected org.apache.axiom.om.OMElement localExtraElement; |
||
| 886 | |||
| 887 | /** |
||
| 888 | * Auto generated getter method |
||
| 889 | * @return org.apache.axiom.om.OMElement |
||
| 890 | */ |
||
| 891 | public org.apache.axiom.om.OMElement getExtraElement() { |
||
| 892 | return localExtraElement; |
||
| 893 | } |
||
| 894 | |||
| 895 | /** |
||
| 896 | * Auto generated setter method |
||
| 897 | * @param param ExtraElement |
||
| 898 | */ |
||
| 899 | public void setExtraElement(org.apache.axiom.om.OMElement param) { |
||
| 900 | this.localExtraElement = param; |
||
| 901 | } |
||
| 902 | |||
| 903 | /** |
||
| 904 | * |
||
| 905 | * @param parentQName |
||
| 906 | * @param factory |
||
| 907 | * @return org.apache.axiom.om.OMElement |
||
| 908 | */ |
||
| 909 | public org.apache.axiom.om.OMElement getOMElement( |
||
| 910 | final javax.xml.namespace.QName parentQName, |
||
| 911 | final org.apache.axiom.om.OMFactory factory) |
||
| 912 | throws org.apache.axis2.databinding.ADBException { |
||
| 913 | return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( |
||
| 914 | this, MY_QNAME)); |
||
| 915 | } |
||
| 916 | |||
| 917 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 918 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 919 | throws javax.xml.stream.XMLStreamException, |
||
| 920 | org.apache.axis2.databinding.ADBException { |
||
| 921 | serialize(parentQName, xmlWriter, false); |
||
| 922 | } |
||
| 923 | |||
| 924 | public void serialize(final javax.xml.namespace.QName parentQName, |
||
| 925 | javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) |
||
| 926 | throws javax.xml.stream.XMLStreamException, |
||
| 927 | org.apache.axis2.databinding.ADBException { |
||
| 928 | java.lang.String prefix = null; |
||
| 929 | java.lang.String namespace = null; |
||
| 930 | |||
| 931 | prefix = parentQName.getPrefix(); |
||
| 932 | namespace = parentQName.getNamespaceURI(); |
||
| 933 | writeStartElement(prefix, namespace, parentQName.getLocalPart(), |
||
| 934 | xmlWriter); |
||
| 935 | |||
| 936 | if (serializeType) { |
||
| 937 | java.lang.String namespacePrefix = registerPrefix(xmlWriter, |
||
| 938 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4"); |
||
| 939 | |||
| 940 | if ((namespacePrefix != null) && |
||
| 941 | (namespacePrefix.trim().length() > 0)) { |
||
| 942 | writeAttribute("xsi", |
||
| 943 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 944 | namespacePrefix + ":nfeDadosMsg", xmlWriter); |
||
| 945 | } else { |
||
| 946 | writeAttribute("xsi", |
||
| 947 | "http://www.w3.org/2001/XMLSchema-instance", "type", |
||
| 948 | "nfeDadosMsg", xmlWriter); |
||
| 949 | } |
||
| 950 | } |
||
| 951 | |||
| 952 | if (localExtraElement != null) { |
||
| 953 | localExtraElement.serialize(xmlWriter); |
||
| 954 | } else { |
||
| 955 | throw new org.apache.axis2.databinding.ADBException( |
||
| 956 | "extraElement cannot be null!!"); |
||
| 957 | } |
||
| 958 | |||
| 959 | xmlWriter.writeEndElement(); |
||
| 960 | } |
||
| 961 | |||
| 962 | private static java.lang.String generatePrefix( |
||
| 963 | java.lang.String namespace) { |
||
| 964 | if (namespace.equals( |
||
| 965 | "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4")) { |
||
| 966 | return "ns1"; |
||
| 967 | } |
||
| 968 | |||
| 969 | return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 970 | } |
||
| 971 | |||
| 972 | /** |
||
| 973 | * Utility method to write an element start tag. |
||
| 974 | */ |
||
| 975 | private void writeStartElement(java.lang.String prefix, |
||
| 976 | java.lang.String namespace, java.lang.String localPart, |
||
| 977 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 978 | throws javax.xml.stream.XMLStreamException { |
||
| 979 | java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 980 | |||
| 981 | if (writerPrefix != null) { |
||
| 982 | xmlWriter.writeStartElement(writerPrefix, localPart, namespace); |
||
| 983 | } else { |
||
| 984 | if (namespace.length() == 0) { |
||
| 985 | prefix = ""; |
||
| 986 | } else if (prefix == null) { |
||
| 987 | prefix = generatePrefix(namespace); |
||
| 988 | } |
||
| 989 | |||
| 990 | xmlWriter.writeStartElement(prefix, localPart, namespace); |
||
| 991 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 992 | xmlWriter.setPrefix(prefix, namespace); |
||
| 993 | } |
||
| 994 | } |
||
| 995 | |||
| 996 | /** |
||
| 997 | * Util method to write an attribute with the ns prefix |
||
| 998 | */ |
||
| 999 | private void writeAttribute(java.lang.String prefix, |
||
| 1000 | java.lang.String namespace, java.lang.String attName, |
||
| 1001 | java.lang.String attValue, |
||
| 1002 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1003 | throws javax.xml.stream.XMLStreamException { |
||
| 1004 | java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); |
||
| 1005 | |||
| 1006 | if (writerPrefix != null) { |
||
| 1007 | xmlWriter.writeAttribute(writerPrefix, namespace, attName, |
||
| 1008 | attValue); |
||
| 1009 | } else { |
||
| 1010 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1011 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1012 | xmlWriter.writeAttribute(prefix, namespace, attName, attValue); |
||
| 1013 | } |
||
| 1014 | } |
||
| 1015 | |||
| 1016 | /** |
||
| 1017 | * Util method to write an attribute without the ns prefix |
||
| 1018 | */ |
||
| 1019 | private void writeAttribute(java.lang.String namespace, |
||
| 1020 | java.lang.String attName, java.lang.String attValue, |
||
| 1021 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1022 | throws javax.xml.stream.XMLStreamException { |
||
| 1023 | if (namespace.equals("")) { |
||
| 1024 | xmlWriter.writeAttribute(attName, attValue); |
||
| 1025 | } else { |
||
| 1026 | xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), |
||
| 1027 | namespace, attName, attValue); |
||
| 1028 | } |
||
| 1029 | } |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Util method to write an attribute without the ns prefix |
||
| 1033 | */ |
||
| 1034 | private void writeQNameAttribute(java.lang.String namespace, |
||
| 1035 | java.lang.String attName, javax.xml.namespace.QName qname, |
||
| 1036 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1037 | throws javax.xml.stream.XMLStreamException { |
||
| 1038 | java.lang.String attributeNamespace = qname.getNamespaceURI(); |
||
| 1039 | java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); |
||
| 1040 | |||
| 1041 | if (attributePrefix == null) { |
||
| 1042 | attributePrefix = registerPrefix(xmlWriter, attributeNamespace); |
||
| 1043 | } |
||
| 1044 | |||
| 1045 | java.lang.String attributeValue; |
||
| 1046 | |||
| 1047 | if (attributePrefix.trim().length() > 0) { |
||
| 1048 | attributeValue = attributePrefix + ":" + qname.getLocalPart(); |
||
| 1049 | } else { |
||
| 1050 | attributeValue = qname.getLocalPart(); |
||
| 1051 | } |
||
| 1052 | |||
| 1053 | if (namespace.equals("")) { |
||
| 1054 | xmlWriter.writeAttribute(attName, attributeValue); |
||
| 1055 | } else { |
||
| 1056 | registerPrefix(xmlWriter, namespace); |
||
| 1057 | xmlWriter.writeAttribute(attributePrefix, namespace, attName, |
||
| 1058 | attributeValue); |
||
| 1059 | } |
||
| 1060 | } |
||
| 1061 | |||
| 1062 | /** |
||
| 1063 | * method to handle Qnames |
||
| 1064 | */ |
||
| 1065 | private void writeQName(javax.xml.namespace.QName qname, |
||
| 1066 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1067 | throws javax.xml.stream.XMLStreamException { |
||
| 1068 | java.lang.String namespaceURI = qname.getNamespaceURI(); |
||
| 1069 | |||
| 1070 | if (namespaceURI != null) { |
||
| 1071 | java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1072 | |||
| 1073 | if (prefix == null) { |
||
| 1074 | prefix = generatePrefix(namespaceURI); |
||
| 1075 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1076 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1077 | } |
||
| 1078 | |||
| 1079 | if (prefix.trim().length() > 0) { |
||
| 1080 | xmlWriter.writeCharacters(prefix + ":" + |
||
| 1081 | org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1082 | qname)); |
||
| 1083 | } else { |
||
| 1084 | // i.e this is the default namespace |
||
| 1085 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1086 | qname)); |
||
| 1087 | } |
||
| 1088 | } else { |
||
| 1089 | xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1090 | qname)); |
||
| 1091 | } |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | private void writeQNames(javax.xml.namespace.QName[] qnames, |
||
| 1095 | javax.xml.stream.XMLStreamWriter xmlWriter) |
||
| 1096 | throws javax.xml.stream.XMLStreamException { |
||
| 1097 | if (qnames != null) { |
||
| 1098 | // we have to store this data until last moment since it is not possible to write any |
||
| 1099 | // namespace data after writing the charactor data |
||
| 1100 | java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); |
||
| 1101 | java.lang.String namespaceURI = null; |
||
| 1102 | java.lang.String prefix = null; |
||
| 1103 | |||
| 1104 | for (int i = 0; i < qnames.length; i++) { |
||
| 1105 | if (i > 0) { |
||
| 1106 | stringToWrite.append(" "); |
||
| 1107 | } |
||
| 1108 | |||
| 1109 | namespaceURI = qnames[i].getNamespaceURI(); |
||
| 1110 | |||
| 1111 | if (namespaceURI != null) { |
||
| 1112 | prefix = xmlWriter.getPrefix(namespaceURI); |
||
| 1113 | |||
| 1114 | if ((prefix == null) || (prefix.length() == 0)) { |
||
| 1115 | prefix = generatePrefix(namespaceURI); |
||
| 1116 | xmlWriter.writeNamespace(prefix, namespaceURI); |
||
| 1117 | xmlWriter.setPrefix(prefix, namespaceURI); |
||
| 1118 | } |
||
| 1119 | |||
| 1120 | if (prefix.trim().length() > 0) { |
||
| 1121 | stringToWrite.append(prefix).append(":") |
||
| 1122 | .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1123 | qnames[i])); |
||
| 1124 | } else { |
||
| 1125 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1126 | qnames[i])); |
||
| 1127 | } |
||
| 1128 | } else { |
||
| 1129 | stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( |
||
| 1130 | qnames[i])); |
||
| 1131 | } |
||
| 1132 | } |
||
| 1133 | |||
| 1134 | xmlWriter.writeCharacters(stringToWrite.toString()); |
||
| 1135 | } |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * Register a namespace prefix |
||
| 1140 | */ |
||
| 1141 | private java.lang.String registerPrefix( |
||
| 1142 | javax.xml.stream.XMLStreamWriter xmlWriter, |
||
| 1143 | java.lang.String namespace) |
||
| 1144 | throws javax.xml.stream.XMLStreamException { |
||
| 1145 | java.lang.String prefix = xmlWriter.getPrefix(namespace); |
||
| 1146 | |||
| 1147 | if (prefix == null) { |
||
| 1148 | prefix = generatePrefix(namespace); |
||
| 1149 | |||
| 1150 | javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); |
||
| 1151 | |||
| 1152 | while (true) { |
||
| 1153 | java.lang.String uri = nsContext.getNamespaceURI(prefix); |
||
| 1154 | |||
| 1155 | if ((uri == null) || (uri.length() == 0)) { |
||
| 1156 | break; |
||
| 1157 | } |
||
| 1158 | |||
| 1159 | prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); |
||
| 1160 | } |
||
| 1161 | |||
| 1162 | xmlWriter.writeNamespace(prefix, namespace); |
||
| 1163 | xmlWriter.setPrefix(prefix, namespace); |
||
| 1164 | } |
||
| 1165 | |||
| 1166 | return prefix; |
||
| 1167 | } |
||
| 1168 | |||
| 1169 | /** |
||
| 1170 | * Factory class that keeps the parse method |
||
| 1171 | */ |
||
| 1172 | public static class Factory { |
||
| 1173 | private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); |
||
| 1174 | |||
| 1175 | /** |
||
| 1176 | * static method to create the object |
||
| 1177 | * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable |
||
| 1178 | * 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 |
||
| 1179 | * Postcondition: If this object is an element, the reader is positioned at its end element |
||
| 1180 | * If this object is a complex type, the reader is positioned at the end element of its outer element |
||
| 1181 | */ |
||
| 1182 | public static NfeDadosMsg parse( |
||
| 1183 | javax.xml.stream.XMLStreamReader reader) |
||
| 1184 | throws java.lang.Exception { |
||
| 1185 | NfeDadosMsg object = new NfeDadosMsg(); |
||
| 1186 | |||
| 1187 | int event; |
||
| 1188 | javax.xml.namespace.QName currentQName = null; |
||
| 1189 | java.lang.String nillableValue = null; |
||
| 1190 | java.lang.String prefix = ""; |
||
| 1191 | java.lang.String namespaceuri = ""; |
||
| 1192 | |||
| 1193 | try { |
||
| 1194 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1195 | reader.next(); |
||
| 1196 | |||
| 1197 | currentQName = reader.getName(); |
||
| 1198 | |||
| 1199 | if (reader.getAttributeValue( |
||
| 1200 | "http://www.w3.org/2001/XMLSchema-instance", |
||
| 1201 | "type") != null) { |
||
| 1202 | java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", |
||
| 1203 | "type"); |
||
| 1204 | |||
| 1205 | if (fullTypeName != null) { |
||
| 1206 | java.lang.String nsPrefix = null; |
||
| 1207 | |||
| 1208 | if (fullTypeName.indexOf(":") > -1) { |
||
| 1209 | nsPrefix = fullTypeName.substring(0, |
||
| 1210 | fullTypeName.indexOf(":")); |
||
| 1211 | } |
||
| 1212 | |||
| 1213 | nsPrefix = (nsPrefix == null) ? "" : nsPrefix; |
||
| 1214 | |||
| 1215 | java.lang.String type = fullTypeName.substring(fullTypeName.indexOf( |
||
| 1216 | ":") + 1); |
||
| 1217 | |||
| 1218 | if (!"nfeDadosMsg".equals(type)) { |
||
| 1219 | //find namespace for the prefix |
||
| 1220 | java.lang.String nsUri = reader.getNamespaceContext() |
||
| 1221 | .getNamespaceURI(nsPrefix); |
||
| 1222 | |||
| 1223 | return (NfeDadosMsg) ExtensionMapper.getTypeObject(nsUri, |
||
| 1224 | type, reader); |
||
| 1225 | } |
||
| 1226 | } |
||
| 1227 | } |
||
| 1228 | |||
| 1229 | // Note all attributes that were handled. Used to differ normal attributes |
||
| 1230 | // from anyAttributes. |
||
| 1231 | java.util.Vector handledAttributes = new java.util.Vector(); |
||
| 1232 | |||
| 1233 | reader.next(); |
||
| 1234 | |||
| 1235 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1236 | reader.next(); |
||
| 1237 | |||
| 1238 | if (reader.isStartElement()) { |
||
| 1239 | //use the QName from the parser as the name for the builder |
||
| 1240 | javax.xml.namespace.QName startQname1 = reader.getName(); |
||
| 1241 | |||
| 1242 | // We need to wrap the reader so that it produces a fake START_DOCUMENT event |
||
| 1243 | // this is needed by the builder classes |
||
| 1244 | org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = |
||
| 1245 | new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(new org.apache.axis2.util.StreamWrapper( |
||
| 1246 | reader), startQname1); |
||
| 1247 | object.setExtraElement(builder1.getOMElement()); |
||
| 1248 | |||
| 1249 | reader.next(); |
||
| 1250 | } // End of if for expected property start element |
||
| 1251 | |||
| 1252 | else { |
||
| 1253 | // 1 - A start element we are not expecting indicates an invalid parameter was passed |
||
| 1254 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1255 | "Unexpected subelement " + reader.getName()); |
||
| 1256 | } |
||
| 1257 | |||
| 1258 | while (!reader.isStartElement() && !reader.isEndElement()) |
||
| 1259 | reader.next(); |
||
| 1260 | |||
| 1261 | if (reader.isStartElement()) { |
||
| 1262 | // 2 - A start element we are not expecting indicates a trailing invalid property |
||
| 1263 | throw new org.apache.axis2.databinding.ADBException( |
||
| 1264 | "Unexpected subelement " + reader.getName()); |
||
| 1265 | } |
||
| 1266 | } catch (javax.xml.stream.XMLStreamException e) { |
||
| 1267 | throw new java.lang.Exception(e); |
||
| 1268 | } |
||
| 1269 | |||
| 1270 | return object; |
||
| 1271 | } |
||
| 1272 | } //end of factory class |
||
| 1273 | } |
||
| 1274 | } |