martes, 22 de septiembre de 2015

WSO2 ESB: Habilitando log WIRE para visualizar mensajes HTTP

En la entrada anterior les explicaba como identificar la fuente de un error usando el TCPMON para ver los mensajes intercambiados. Aquellos que no deseen usar esta herramienta pueden activar los log WIRE en el WSO2 ESB y de esta forma ver por la consola los mensajes intercambiados.

Los pasos son los siguientes:
  1. Autenticarse en el WSO2 ESB e ir a la pestaña Configure.
  2. Buscar la opción Logging y darle clic.
  3. En la sección "Configure Log4J Loggers", escribir "wire"  en "Filter Loggers by" y dar clic en el botón Contains.
  4. En el logger "org.apache.synapse.transport.http.wire" marcar el LEVEL como DEBUG.

Eso es todo. Si volvemos a invocar al servicio sin los ajustes mecionados en la entrada anterior veremos lo siguiente.

[2015-09-18 11:26:14,820] DEBUG - wire >> "POST /services/JsonToXMLProxy HTTP/1.1[\r][\n]"
[2015-09-18 11:26:14,820] DEBUG - wire >> "Host: localhost:8281[\r][\n]"
[2015-09-18 11:26:14,821] DEBUG - wire >> "User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0[\r][\n]"
[2015-09-18 11:26:14,821] DEBUG - wire >> "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[\r][\n]"
[2015-09-18 11:26:14,821] DEBUG - wire >> "Accept-Language: null[\r][\n]"
[2015-09-18 11:26:14,822] DEBUG - wire >> "Accept-Encoding: gzip, deflate[\r][\n]"
[2015-09-18 11:26:14,822] DEBUG - wire >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2015-09-18 11:26:14,822] DEBUG - wire >> "Content-Length: 19[\r][\n]"
[2015-09-18 11:26:14,822] DEBUG - wire >> "Cookie: region3_registry_menu=visible; menuPanel=visible; menuPanelType=config; requestedURI="../../carbon/log-admin/log-admin.jsp?region=r
egion1&item=logging_menu"; region1_configure_menu=none; region4_monitor_menu=none; region5_tools_menu=none; current-breadcrumb=configure_menu%2Clogging_menu%23[\r][\n]"
[2015-09-18 11:26:14,823] DEBUG - wire >> "Connection: keep-alive[\r][\n]"
[2015-09-18 11:26:14,823] DEBUG - wire >> "Pragma: no-cache[\r][\n]"
[2015-09-18 11:26:14,823] DEBUG - wire >> "Cache-Control: no-cache[\r][\n]"
[2015-09-18 11:26:14,823] DEBUG - wire >> "[\r][\n]"
[2015-09-18 11:26:14,823] DEBUG - wire >> "{"celsius": "200" }"
[2015-09-18 11:26:14,825]  INFO - LogMediator To: /services/JsonToXMLProxy, MessageID: urn:uuid:236d5499-44bf-42e3-bc24-036f7e4b693d, Direction: request, TEMPERATURA_ENTRADA = 200
[2015-09-18 11:26:14,831] DEBUG - wire << "POST /webservices/tempconvert.asmx HTTP/1.1[\r][\n]"
[2015-09-18 11:26:14,831] DEBUG - wire << "Accept-Language: null[\r][\n]"
[2015-09-18 11:26:14,832] DEBUG - wire << "Cookie: region3_registry_menu=visible; menuPanel=visible; menuPanelType=config; requestedURI="../../carbon/log-admin/log-admin.jsp?region=r
egion1&item=logging_menu"; region1_configure_menu=none; region4_monitor_menu=none; region5_tools_menu=none; current-breadcrumb=configure_menu%2Clogging_menu%23[\r][\n]"
[2015-09-18 11:26:14,832] DEBUG - wire << "Accept-Encoding: gzip, deflate[\r][\n]"
[2015-09-18 11:26:14,832] DEBUG - wire << "Content-Type: text/xml[\r][\n]"
[2015-09-18 11:26:14,833] DEBUG - wire << "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[\r][\n]"
[2015-09-18 11:26:14,833] DEBUG - wire << "Pragma: no-cache[\r][\n]"
[2015-09-18 11:26:14,833] DEBUG - wire << "Cache-Control: no-cache[\r][\n]"
[2015-09-18 11:26:14,833] DEBUG - wire << "SOAPAction: "http://www.w3schools.com/webservices/CelsiusToFahrenheit"[\r][\n]"
[2015-09-18 11:26:14,833] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2015-09-18 11:26:14,834] DEBUG - wire << "Host: localhost:5555[\r][\n]"
[2015-09-18 11:26:14,834] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2015-09-18 11:26:14,834] DEBUG - wire << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2015-09-18 11:26:14,834] DEBUG - wire << "[\r][\n]"
[2015-09-18 11:26:14,835] DEBUG - wire << "125[\r][\n]"
[2015-09-18 11:26:14,835] DEBUG - wire << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><web:Celsiu
sToFahrenheit xmlns:web="http://www.w3schools.com/webservices/"><web:Celsius>200</web:Celsius></web:CelsiusToFahrenheit></soapenv:Body></soapenv:Envelope>[\r][\n]"
[2015-09-18 11:26:14,835] DEBUG - wire << "0[\r][\n]"
[2015-09-18 11:26:14,836] DEBUG - wire << "[\r][\n]"
[2015-09-18 11:26:15,423] DEBUG - wire >> "HTTP/1.1 411 Length Required[\r][\n]"
[2015-09-18 11:26:15,424] DEBUG - wire >> "Via: 1.1 FWSOAINT[\r][\n]"
[2015-09-18 11:26:15,424] DEBUG - wire >> "Connection: Keep-Alive[\r][\n]"
[2015-09-18 11:26:15,424] DEBUG - wire >> "Proxy-Connection: Keep-Alive[\r][\n]"
[2015-09-18 11:26:15,425] DEBUG - wire >> "Content-Length: 357[\r][\n]"
[2015-09-18 11:26:15,425] DEBUG - wire >> "Date: Fri, 18 Sep 2015 15:26:15 GMT[\r][\n]"
[2015-09-18 11:26:15,425] DEBUG - wire >> "Content-Type: text/html[\r][\n]"
[2015-09-18 11:26:15,426] DEBUG - wire >> "Server: ECSF (mia/1770)[\r][\n]"
[2015-09-18 11:26:15,426] DEBUG - wire >> "[\r][\n]"
[2015-09-18 11:26:15,426] DEBUG - wire >> "<?xml version="1.0" encoding="iso-8859-1"?>[\n]"
[2015-09-18 11:26:15,426] DEBUG - wire >> "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"[\n]"
[2015-09-18 11:26:15,427] DEBUG - wire >> "         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[\n]"
[2015-09-18 11:26:15,427] DEBUG - wire >> "<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">[\n]"
[2015-09-18 11:26:15,428] DEBUG - wire >> "[0x9]<head>[\n]"
[2015-09-18 11:26:15,428] DEBUG - wire >> "[0x9][0x9]<title>411 - Length Required</title>[\n]"
[2015-09-18 11:26:15,428] DEBUG - wire >> "[0x9]</head>[\n]"
[2015-09-18 11:26:15,428] DEBUG - wire >> "[0x9]<body>[\n]"
[2015-09-18 11:26:15,428] DEBUG - wire >> "[0x9][0x9]<h1>411 - Length Required</h1>[\n]"
[2015-09-18 11:26:15,429] DEBUG - wire >> "[0x9]</body>[\n]"
[2015-09-18 11:26:15,429] DEBUG - wire >> "</html>[\n]"
[2015-09-18 11:26:15,431] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
        at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
        at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:149)
        at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
        at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
        at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
        at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
        at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:297)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
        at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:247)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
Caused by: javax.xml.stream.XMLStreamException: DOCTYPE is not allowed
        at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:36)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
        at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)



Como se aprecia se muestra el mensaje que genera el backend por lo que es facilmente detectable la fuente del error.

0 comentarios:

Publicar un comentario