axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McCullough, Ryan" <rmccullo...@rightnow.com>
Subject RE: How to dump SOAP message contents?
Date Tue, 10 Jun 2008 05:46:09 GMT
Enabling log4j was relatively painless.

Just create the log4j.properties text file with these contents:
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=ERROR, LOGFILE
log4j.logger.org.apache.axis.transport.http.HTTPSender=DEBUG

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}
[%t] %-5p %c %x - %m%n

I have had mixed success with placing this file in the classpath, but adding
this code works:
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;
PropertyConfigurator.configure("c:/path/to/log4j.properties");

The log output loosk like this:

2008-05-20 10:18:25,707 [invoke] DEBUG
org.apache.axis.transport.http.HTTPSender  - Enter:  HTTPSender::invoke
2008-05-20 10:18:25,816 [writeToSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - XML sent:
2008-05-20 10:18:25,816 [writeToSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  -
---------------------------------------------------
2008-05-20 10:18:25,816 [writeToSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - POST
/cgi-bin/XXXXXXXX.cfg/php/xml_api/soap_api.php HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/#axisVersion#
Host: teton
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "urn:Service/exec"
Content-Length: 581

<-xml version="1.0" encoding="UTF-8"-><soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<SessionHeader><ClientType>Toolkit-Java</ClientType><RequestTime>2008-05-20T
16:18:23.363Z</RequestTime></SessionHeader>
</soapenv:Header>
<soapenv:Body>
<exec xmlns="urn:obj.api.rightnow.com"><transaction>
<account_login><login>XXXXXXXX</login><opt>0</opt><password>XXXXXXXX</passwo
rd></account_login>
</transaction></exec></soapenv:Body></soapenv:Envelope>
2008-05-20 10:18:26,019 [readHeadersFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - HTTP/1.1 200 OK
2008-05-20 10:18:26,019 [readHeadersFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - Date Tue, 20 May 2008 16:18:25
GMT
2008-05-20 10:18:26,019 [readHeadersFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - Server Apache/2.2.6 (Unix)
2008-05-20 10:18:26,035 [readHeadersFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - Connection close
2008-05-20 10:18:26,035 [readHeadersFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - Content-Type text/xml;
charset=UTF-8
2008-05-20 10:18:26,035 [readFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - 
no Content-Length
2008-05-20 10:18:26,051 [readFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - 
XML received:
2008-05-20 10:18:26,051 [readFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  -
-----------------------------------------------
2008-05-20 10:18:26,098 [readFromSocket] DEBUG
org.apache.axis.transport.http.HTTPSender  - <soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header><ResponseHeader
xmlns="urn:obj.api.rightnow.com"><Version>8.8.0.47</Version></ResponseHeader
></soap:Header>
<soap:Body><exec_rv xmlns="urn:obj.api.rightnow.com">
<transaction_rv errlog_cnt="0">
<account_login_rv><acct_id>X</acct_id>
<session_id>XXXXXXXXXX</session_id>
</account_login_rv>

</transaction_rv>
    </exec_rv></soap:Body></soap:Envelope>
2008-05-20 10:18:26,098 [invoke] DEBUG
org.apache.axis.transport.http.HTTPSender  - Exit:
HTTPDispatchHandler::invoke

Notice the http header for both the request and response are present.

-Ryan

-----Original Message-----
From: Martin [mailto:mgainty@hotmail.com] 
Sent: Friday, June 06, 2008 2:07 PM
To: satish_madanwad@yahoo.com; gary.weaver@duke.edu
Cc: axis-user@ws.apache.org
Subject: Re: How to dump SOAP message contents?

Satish/Gary
Take a look at InterfaceImplementationTemplate.xsl which WSDL2Java uses to 
generate Service and Stub.java
which could be modified to log the discovered soap_headers

        // create SOAP envelope with that payload
        org.apache.axiom.soap.SOAPEnvelope env = null;

//initialise
       <xsl:choose>
          <xsl:when test="(($isbackcompatible='true') and 
(string-length(normalize-space($inputElementComplexType)) > 0))">
                                   <xsl:if 
test="count(input/param[@location='soap_header']) &gt; 0">
                                               env.build();
                                    </xsl:if>
                                    <xsl:for-each 
select="input/param[@location='soap_header']">
                                        // add the children only if the 
parameter is not null
                                        if (<xsl:value-of 
select="@name"/>!=null){
                                            <xsl:choose>
                                                <xsl:when 
test="@mustUnderstand = 'true'">
 
org.apache.axiom.om.OMElement 
omElement<xsl:value-of select="@name"/> = toOM(<xsl:value-of 
select="@name"/>, optimizeContent(new 
javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", 
"<xsl:value-of select="$method-name"/>")));
 
addHeader(omElement<xsl:value-of 
select="@name"/>,env,true);
                                                </xsl:when>
                                                <xsl:otherwise>
 
org.apache.axiom.om.OMElement 
omElement<xsl:value-of select="@name"/> = toOM(<xsl:value-of 
select="@name"/>, optimizeContent(new 
javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", 
"<xsl:value-of select="$method-name"/>")));
 
addHeader(omElement<xsl:value-of 
select="@name"/>,env);
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        }
                                    </xsl:for-each>

                                    <xsl:for-each 
select="input/param[@location='http_header']">
                                        // add the children only if the 
parameter is not null
                                        if (<xsl:value-of 
select="@name"/>!=null){
 
addHttpHeader(_messageContext,"<xsl:value-of 
select="@headername"/>",<xsl:value-of select="@name"/>);
                                        }
                                    </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                    //Unknown style detected !! No code is 
generated
                                </xsl:otherwise>

        //adding SOAP soap_headers
         _serviceClient.addHeadersToEnvelope(env);
        // set the message context with that soap envelope
        _messageContext.setEnvelope(env);

        // add the message contxt to the operation client
        _operationClient.addMessageContext(_messageContext);

        //execute the operation client
        _operationClient.execute(true);

HTH
Martin
----- Original Message ----- 
From: "Gary Weaver" <gary.weaver@duke.edu>
To: <axis-user@ws.apache.org>; <satish_madanwad@yahoo.com>
Sent: Friday, June 06, 2008 1:36 PM
Subject: Re: How to dump SOAP message contents?


> In addition to using tcp tunnel or tcpmon you can just use logging to log 
> the request and response:
>
> log4j.logger.httpclient.wire.content=DEBUG
>
> (within log4j.properties file in classpath (or within common/classes/, 
> shared/classes/, or (webapp)/WEB-INF/classes/, etc.)
>
> That won't print the HTTPHeaders though, although the only thing in the 
> header that seems of much importance is SOAPAction.
>
> Hope this helps,
> Gary
>
> -- 
> Gary Weaver
> Internet Framework Services
> Office of Information Technology
> Duke University
>
>
>
>
> Juergen Weber wrote:
>> see http://articles.techrepublic.com.com/5100-10878_11-1049605.html
>>
>> On Fri, Jun 6, 2008 at 3:18 PM, satish madanwad
>> <satish_madanwad@yahoo.com> wrote:
>>
>>> Hi,
>>>
>>>   I am using WebServices with Apache Axis in my programs. I have 
>>> generated
>>> client stubs and can prepare and  send the WebService request properly.
>>>
>>>   I am trying to dump SOAP message (XML format) which is sent to 
>>> WebServer
>>> for processing (to examine exact message being sent). I am not able to 
>>> find
>>> any APIs for the same.
>>>
>>>   Can you please suggest, if there is any API to dump SOAP messages sent
>>> from Apache Axis to WebServer?
>>>
>>> Thanks in advance,
>>> Satish
>>>
>>>
>>>
>>> ________________________________
>>> Download prohibited? No problem. CHAT from any browser, without 
>>> download.
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message