You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2008/04/11 23:38:04 UTC
svn commit: r647325 - in
/webservices/axis2/trunk/java/modules/samples/jaxws-samples/src:
main/org/apache/axis2/jaxws/samples/echo/
main/org/apache/axis2/jaxws/samples/handler/ webapp/WEB-INF/classes/org/
webapp/WEB-INF/classes/org/apache/ webapp/WEB-I...
Author: dims
Date: Fri Apr 11 14:38:02 2008
New Revision: 647325
URL: http://svn.apache.org/viewvc?rev=647325&view=rev
Log:
Add a logging handler into the sample
Added:
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/LoggingSOAPHandler.java
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/loghandler.xml
Modified:
webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/echo/EchoServicePortImpl.java
Modified: webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/echo/EchoServicePortImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/echo/EchoServicePortImpl.java?rev=647325&r1=647324&r2=647325&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/echo/EchoServicePortImpl.java (original)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/echo/EchoServicePortImpl.java Fri Apr 11 14:38:02 2008
@@ -19,9 +19,11 @@
package org.apache.axis2.jaxws.samples.echo;
import javax.jws.WebService;
+import javax.jws.HandlerChain;
@WebService(endpointInterface = "org.apache.axis2.jaxws.samples.echo.EchoServicePortType", targetNamespace = "http://org/apache/axis2/jaxws/samples/echo/", serviceName = "EchoService", portName = "EchoServicePort", wsdlLocation = "WEB-INF/wsdl/Echo.wsdl")
+@HandlerChain(file="loghandler.xml")
public class EchoServicePortImpl {
public EchoStringResponse echoOperation(EchoStringInput parameter) {
Added: webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/LoggingSOAPHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/LoggingSOAPHandler.java?rev=647325&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/LoggingSOAPHandler.java (added)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/main/org/apache/axis2/jaxws/samples/handler/LoggingSOAPHandler.java Fri Apr 11 14:38:02 2008
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.samples.handler;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Set;
+
+public class LoggingSOAPHandler implements SOAPHandler<SOAPMessageContext> {
+
+ private PrintStream out;
+
+ public LoggingSOAPHandler() {
+ setLogStream(System.out);
+ }
+
+ protected final void setLogStream(PrintStream ps) {
+ out = ps;
+ }
+
+ public void init(Map c) {
+ System.out.println("LoggingHandler : init() Called....");
+ }
+
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ public boolean handleMessage(SOAPMessageContext smc) {
+ System.out.println("LoggingHandler : handleMessage Called....");
+ logToSystemOut(smc);
+ return true;
+ }
+
+ public boolean handleFault(SOAPMessageContext smc) {
+ System.out.println("LoggingHandler : handleFault Called....");
+ logToSystemOut(smc);
+ return true;
+ }
+
+ // nothing to clean up
+ public void close(MessageContext messageContext) {
+ System.out.println("LoggingHandler : close() Called....");
+ }
+
+ // nothing to clean up
+ public void destroy() {
+ System.out.println("LoggingHandler : destroy() Called....");
+ }
+
+ /*
+ * Check the MESSAGE_OUTBOUND_PROPERTY in the context
+ * to see if this is an outgoing or incoming message.
+ * Write a brief message to the print stream and
+ * output the message. The writeTo() method can throw
+ * SOAPException or IOException
+ */
+ protected void logToSystemOut(SOAPMessageContext smc) {
+ Boolean outboundProperty = (Boolean)
+ smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ out.println("===============================================");
+ if (outboundProperty.booleanValue()) {
+ out.println("Outbound message:");
+ } else {
+ out.println("Inbound message:");
+ }
+
+ SOAPMessage message = smc.getMessage();
+ try {
+ message.writeTo(out);
+ out.println();
+ } catch (Exception e) {
+ out.println("Exception in handler: " + e);
+ }
+ out.println("===============================================");
+ }
+}
Added: webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/loghandler.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/loghandler.xml?rev=647325&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/loghandler.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/org/apache/axis2/jaxws/samples/echo/loghandler.xml Fri Apr 11 14:38:02 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <service-name-pattern xmlns:ns1="http://org/apache/axis2/jaxws/samples/echo/">ns1:*</service-name-pattern>
+ <handler>
+ <handler-class>org.apache.axis2.jaxws.samples.handler.LoggingSOAPHandler</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org