You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2006/11/28 15:46:12 UTC
svn commit: r480071 - in /incubator/cxf/trunk:
distribution/src/main/release/samples/ws_addressing/
distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/
distribution/src/main/release/samples/ws_addressing/src/demo/ws_addre...
Author: eglynn
Date: Tue Nov 28 06:46:07 2006
New Revision: 480071
URL: http://svn.apache.org/viewvc?view=rev&rev=480071
Log:
Replaced usage of snoop Handler in WS-A demo with demo-specific logging
formatter, to avoid JDK bug #6467808 which breaks the construction of the
SAAJ SOAPMessage when a (legal) repeated namespace is present.
Added:
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties (with props)
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java (with props)
Removed:
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/HeaderSnooper.java
Modified:
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/README.txt
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/build.xml
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/Client.java
incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/server/GreeterImpl.java
incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/README.txt?view=diff&rev=480071&r1=480070&r2=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/README.txt (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/README.txt Tue Nov 28 06:46:07 2006
@@ -9,8 +9,8 @@
the current message, and a protocol interceptor (MAPCodec) responsible for
encoding/decoding these properties as SOAP Headers.
-An additional demo-specific protocol handler (HeaderSnooper) is used to
-snoop the SOAP Headers and display these to the console.
+A demo-specific logging.properties file is used to snoop the log messages
+relating to WS-A Headers and display these to the console in concise form.
Normally the WS-Addressing MessageAddressProperties are generated and
propagated implicitly, without any intravention from the
@@ -106,11 +106,11 @@
From the samples/ws_addressing directory run the commands (entered on a single command line):
For UNIX (must use forward slashes):
- java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
+ java -Djava.util.logging.config.file=./logging.properties
-Dcxf.config.file=file:///$CXF_HOME/samples/ws_addressing/server.xml
demo.ws_addressing.server.Server &
- java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
+ java -Djava.util.logging.config.file=./logging.properties
-Dcxf.config.file=file:///$CXF_HOME/samples/ws_addressing/client.xml
demo.ws_addressing.client.Client ./wsdl/hello_world_addr.wsdl
@@ -118,11 +118,11 @@
For Windows (may use either forward or back slashes):
start
- java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
+ java -Djava.util.logging.config.file=.\logging.properties
-Dcxf.config.file=file:///%CXF_HOME%\samples\ws_addressing\client.xml
demo.ws_addressing.server.Server
- java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
+ java -Djava.util.logging.config.file=.\logging.properties
-Dcxf.config.file=file:///%CXF_HOME%\samples\ws_addressing\client.xml
demo.ws_addressing.client.Client .\wsdl\hello_world_addr.wsdl
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/build.xml?view=diff&rev=480071&r1=480070&r2=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/build.xml Tue Nov 28 06:46:07 2006
@@ -24,13 +24,15 @@
<target name="client" description="run demo client" depends="build">
<cxfrun classname="demo.ws_addressing.client.Client"
param1="${basedir}/wsdl/hello_world_addr.wsdl"
- jvmarg1="-Dcxf.config.file=client.xml"/>
+ jvmarg1="-Dcxf.config.file=client.xml"
+ logging-properties-file="./logging.properties"/>
</target>
<target name="server" description="run demo server" depends="build">
<cxfrun classname="demo.ws_addressing.server.Server"
param1="${basedir}/wsdl/hello_world_addr.wsdl"
- jvmarg1="-Dcxf.config.file=server.xml"/>
+ jvmarg1="-Dcxf.config.file=server.xml"
+ logging-properties-file="./logging.properties"/>
</target>
<target name="generate.code">
Added: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties?view=auto&rev=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties Tue Nov 28 06:46:07 2006
@@ -0,0 +1,73 @@
+# 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.
+
+############################################################
+# Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+# Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes. These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers. For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= WARNING
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = INFO
+#java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.ConsoleHandler.formatter = demos.ws_addressing.common.ConciseFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+com.xyz.foo.level = SEVERE
+org.apache.cxf.ws.addressing.soap.MAPCodec.level = INFO
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/logging.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/Client.java?view=diff&rev=480071&r1=480070&r2=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/Client.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/client/Client.java Tue Nov 28 06:46:07 2006
@@ -21,14 +21,9 @@
import java.io.File;
import java.lang.reflect.UndeclaredThrowableException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
-import javax.xml.ws.handler.Handler;
-
-import demo.ws_addressing.common.HeaderSnooper;
import org.apache.cxf.ws.addressing.AddressingBuilder;
import org.apache.cxf.ws.addressing.AddressingProperties;
@@ -65,10 +60,6 @@
SOAPService service = new SOAPService(wsdl.toURL(), SERVICE_NAME);
Greeter port = service.getSoapPort();
- List<Handler> handlerChain = new ArrayList<Handler>();
- handlerChain.add(new HeaderSnooper());
- ((BindingProvider)port).getBinding().setHandlerChain(handlerChain);
-
implicitPropagation(port);
explicitPropagation(port);
@@ -129,7 +120,7 @@
// set MessageID property
AttributedURIType messageID =
WSA_OBJECT_FACTORY.createAttributedURIType();
- messageID.setValue("urn:uuid:12345");
+ messageID.setValue("urn:uuid:" + System.currentTimeMillis());
maps.setMessageID(messageID);
// associate MAPs with request context
Added: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java?view=auto&rev=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java (added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java Tue Nov 28 06:46:07 2006
@@ -0,0 +1,33 @@
+/**
+ * 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 demos.ws_addressing.common;
+
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+
+public class ConciseFormatter extends SimpleFormatter {
+ public synchronized String format(LogRecord record) {
+ String longForm = super.format(record);
+ String shortForm = longForm.indexOf("INFO: ") > 0
+ ? longForm.substring(longForm.indexOf("INFO: ") + 6)
+ : longForm;
+ return shortForm;
+ }
+}
Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/common/ConciseFormatter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/server/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/server/GreeterImpl.java?view=diff&rev=480071&r1=480070&r2=480071
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/server/GreeterImpl.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/ws_addressing/src/demo/ws_addressing/server/GreeterImpl.java Tue Nov 28 06:46:07 2006
@@ -21,7 +21,6 @@
import java.util.logging.Logger;
-import javax.jws.HandlerChain;
import javax.jws.WebService;
import org.apache.hello_world_soap_http.Greeter;
@@ -32,7 +31,6 @@
serviceName = "SOAPService",
targetNamespace = "http://apache.org/hello_world_soap_http",
wsdlLocation = "file:./wsdl/hello_world_addr.wsdl")
-@HandlerChain(file = "../common/handler_chain.xml", name = "HandlerChain")
public class GreeterImpl implements Greeter {
Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?view=diff&rev=480071&r1=480070&r2=480071
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Tue Nov 28 06:46:07 2006
@@ -137,7 +137,7 @@
AddressingProperties maps) {
if (maps != null) {
cacheExchange(message, maps);
- LOG.log(Level.INFO, "encoding MAPs in SOAP headers");
+ LOG.log(Level.INFO, "\nOutbound WS-Addressing headers");
try {
Element header = message.getHeaders(Element.class);
discardMAPs(header, maps);
@@ -151,42 +151,42 @@
maps.getNamespaceURI());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getMessageID(),
- Names.WSA_MESSAGEID_NAME,
- AttributedURIType.class,
- header,
- marshaller);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getTo(),
- Names.WSA_TO_NAME,
- AttributedURIType.class,
- header,
- marshaller);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getReplyTo(),
- Names.WSA_REPLYTO_NAME,
- EndpointReferenceType.class,
- header,
- marshaller);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getFaultTo(),
- Names.WSA_FAULTTO_NAME,
- EndpointReferenceType.class,
- header,
- marshaller);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getRelatesTo(),
- Names.WSA_RELATESTO_NAME,
- RelatesToType.class,
- header,
- marshaller);
- transformer.encodeAsExposed(maps.getNamespaceURI(),
- maps.getAction(),
- Names.WSA_ACTION_NAME,
- AttributedURIType.class,
- header,
- marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getMessageID(),
+ Names.WSA_MESSAGEID_NAME,
+ AttributedURIType.class,
+ header,
+ marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getTo(),
+ Names.WSA_TO_NAME,
+ AttributedURIType.class,
+ header,
+ marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getReplyTo(),
+ Names.WSA_REPLYTO_NAME,
+ EndpointReferenceType.class,
+ header,
+ marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getFaultTo(),
+ Names.WSA_FAULTTO_NAME,
+ EndpointReferenceType.class,
+ header,
+ marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getRelatesTo(),
+ Names.WSA_RELATESTO_NAME,
+ RelatesToType.class,
+ header,
+ marshaller);
+ encodeAsExposed(maps.getNamespaceURI(),
+ maps.getAction(),
+ Names.WSA_ACTION_NAME,
+ AttributedURIType.class,
+ header,
+ marshaller);
propogateAction(maps.getAction(), message);
applyMAPValidation(message);
} catch (SOAPException se) {
@@ -196,7 +196,36 @@
}
}
}
-
+
+ /**
+ * Encode message in exposed version.
+ *
+ * @param exposeAs specifies the WS-Addressing version to expose
+ * @param value the value to encode
+ * @param localName the localName for the header
+ * @param clz the class
+ * @param header the SOAP header element
+ * @param marshaller the JAXB marshaller to use
+ */
+ private <T> void encodeAsExposed(String exposeAs,
+ T value,
+ String localName,
+ Class<T> clz,
+ Element header,
+ Marshaller marshaller) throws JAXBException {
+ if (value != null) {
+ LOG.log(Level.INFO,
+ "{0} : {1}",
+ new Object[] {localName, getLogText(value)});
+ transformer.encodeAsExposed(exposeAs,
+ value,
+ localName,
+ clz,
+ header,
+ marshaller);
+ }
+ }
+
/**
* Decode the MAPs from protocol-specific headers.
*
@@ -211,6 +240,7 @@
try {
Element header = message.getHeaders(Element.class);
if (header != null) {
+ LOG.log(Level.INFO, "\nInbound WS-Addressing headers");
Unmarshaller unmarshaller = null;
NodeList headerElements = header.getChildNodes();
int headerCount = headerElements.getLength();
@@ -230,43 +260,42 @@
maps.exposeAs(headerURI);
}
String localName = headerElement.getLocalName();
- LOG.log(Level.INFO, "decoding WSA header {0}", localName);
if (Names.WSA_MESSAGEID_NAME.equals(localName)) {
- maps.setMessageID(transformer.decodeAsNative(
- headerURI,
- AttributedURIType.class,
- headerElement,
- unmarshaller));
+ maps.setMessageID(decodeAsNative(
+ headerURI,
+ AttributedURIType.class,
+ headerElement,
+ unmarshaller));
} else if (Names.WSA_TO_NAME.equals(localName)) {
- maps.setTo(transformer.decodeAsNative(
- headerURI,
- AttributedURIType.class,
- headerElement,
- unmarshaller));
+ maps.setTo(decodeAsNative(
+ headerURI,
+ AttributedURIType.class,
+ headerElement,
+ unmarshaller));
} else if (Names.WSA_REPLYTO_NAME.equals(localName)) {
- maps.setReplyTo(transformer.decodeAsNative(
- headerURI,
- EndpointReferenceType.class,
- headerElement,
- unmarshaller));
+ maps.setReplyTo(decodeAsNative(
+ headerURI,
+ EndpointReferenceType.class,
+ headerElement,
+ unmarshaller));
} else if (Names.WSA_FAULTTO_NAME.equals(localName)) {
- maps.setFaultTo(transformer.decodeAsNative(
- headerURI,
- EndpointReferenceType.class,
- headerElement,
- unmarshaller));
+ maps.setFaultTo(decodeAsNative(
+ headerURI,
+ EndpointReferenceType.class,
+ headerElement,
+ unmarshaller));
} else if (Names.WSA_RELATESTO_NAME.equals(localName)) {
- maps.setRelatesTo(transformer.decodeAsNative(
- headerURI,
- RelatesToType.class,
- headerElement,
- unmarshaller));
+ maps.setRelatesTo(decodeAsNative(
+ headerURI,
+ RelatesToType.class,
+ headerElement,
+ unmarshaller));
} else if (Names.WSA_ACTION_NAME.equals(localName)) {
- maps.setAction(transformer.decodeAsNative(
- headerURI,
- AttributedURIType.class,
- headerElement,
- unmarshaller));
+ maps.setAction(decodeAsNative(
+ headerURI,
+ AttributedURIType.class,
+ headerElement,
+ unmarshaller));
}
} else if (headerURI.contains(Names.WSA_NAMESPACE_PATTERN)) {
LOG.log(Level.WARNING,
@@ -284,6 +313,55 @@
}
/**
+ * Decodes a MAP from a exposed version.
+ *
+ * @param encodedAs specifies the encoded version
+ * @param clz the class
+ * @param headerElement the SOAP header element
+ * @param marshaller the JAXB marshaller to use
+ * @return the decoded value
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T decodeAsNative(String encodedAs,
+ Class<T> clz,
+ Element headerElement,
+ Unmarshaller unmarshaller)
+ throws JAXBException {
+ T value = transformer.decodeAsNative(encodedAs,
+ clz,
+ headerElement,
+ unmarshaller);
+ LOG.log(Level.INFO,
+ "{0} : {1}",
+ new Object[] {headerElement.getLocalName(), getLogText(value)});
+ return value;
+ }
+
+ /**
+ * Return a text representation of a header value for logging.
+ *
+ * @param <T> header type
+ * @param value header value
+ * @return
+ */
+ private <T> String getLogText(T value) {
+ String text = "unknown";
+ if (value == null) {
+ text = "null";
+ } else if (value instanceof AttributedURIType) {
+ text = ((AttributedURIType)value).getValue();
+ } else if (value instanceof EndpointReferenceType) {
+ text = ((EndpointReferenceType)value).getAddress() != null
+ ? ((EndpointReferenceType)value).getAddress().getValue()
+ : "null";
+ } else if (value instanceof RelatesToType) {
+ text = ((RelatesToType)value).getValue();
+ }
+ return text;
+ }
+
+
+ /**
* Decode the MAPs from protocol-specific headers.
*
* @param message the messsage
@@ -310,7 +388,6 @@
Class<T> clz,
Element header,
Marshaller marshaller) throws JAXBException {
- LOG.log(Level.INFO, "encoding WSA header {0}", qname);
if (value != null) {
marshaller.marshal(new JAXBElement<T>(qname, clz, value), header);
}