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 pr...@apache.org on 2007/06/29 20:54:51 UTC
svn commit: r551999 [5/9] - in /webservices/axis2/branches/java/jaxws21:
modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/
modules/adb-codegen/test-resources/testsuite/ modules/adb-codegen/test/o...
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Fri Jun 29 11:54:44 2007
@@ -1,18 +1,20 @@
/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed 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
- *
+ * 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.
+ *
+ * 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.core.controller;
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Fri Jun 29 11:54:44 2007
@@ -38,15 +38,20 @@
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils;
+import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.XMLFault;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
import org.apache.axis2.jaxws.utility.SAAJFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class HandlerChainProcessor {
+ private static final Log log = LogFactory.getLog(HandlerChainProcessor.class);
+
public enum Direction {
IN, OUT
};
@@ -296,12 +301,22 @@
if (direction == Direction.OUT) {
for (; i <= end; i++) {
switchContext(direction, i);
- ((Handler) handlers.get(i)).handleMessage(currentMC);
+ Handler handler = (Handler) handlers.get(i);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking handleMessage on: " + handler.getClass().getName());
+ }
+ handler.handleMessage(currentMC);
}
} else { // IN case
for (; i >= end; i--) {
switchContext(direction, i);
- ((Handler) handlers.get(i)).handleMessage(currentMC);
+ Handler handler = (Handler) handlers.get(i);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking handleMessage on: " + handler.getClass().getName());
+ }
+ handler.handleMessage(currentMC);
}
}
}
@@ -316,16 +331,33 @@
private int handleMessage(Handler handler, Direction direction,
boolean expectResponse) throws RuntimeException {
try {
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking handleMessage on: " + handler.getClass().getName());
+ }
boolean success = handler.handleMessage(currentMC);
- if (success)
+ if (success) {
+ if (log.isDebugEnabled()) {
+ log.debug("handleMessage() returned true");
+ }
return SUCCESSFUL;
+ }
else {
+ if (log.isDebugEnabled()) {
+ log.debug("handleMessage() returned false");
+ }
if (expectResponse)
currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
(direction != Direction.OUT));
return FAILED;
}
- } catch (RuntimeException re) { // RuntimeException and ProtocolException
+ }
+ catch (RuntimeException re) {
+ // RuntimeException and ProtocolException
+ if(log.isDebugEnabled()) {
+ log.debug("An exception was thrown during the handleMessage() invocation");
+ log.debug("Exception: " + re.getClass().getName() + ":" +re.getMessage());
+ }
+
savedException = re;
if (expectResponse)
// mark it as reverse direction
@@ -355,24 +387,40 @@
for (; i <= end; i++) {
try {
switchContext(direction, i);
- ((Handler) handlers.get(i)).close(currentMC);
+ Handler handler = (Handler) handlers.get(i);
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking close on: " + handler.getClass().getName());
+ }
+ handler.close(currentMC);
+
// TODO when we close, are we done with the handler instance, and thus
// may call the PreDestroy annotated method? I don't think so, especially
// if we've cached the handler list somewhere.
} catch (Exception e) {
- // TODO: log it, but otherwise ignore
+ if (log.isDebugEnabled()) {
+ log.debug("An Exception occurred while calling handler.close()");
+ log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage());
+ }
}
}
} else { // IN case
for (; i >= end; i--) {
try {
switchContext(direction, i);
- ((Handler) handlers.get(i)).close(currentMC);
- // TODO when we close, are we done with the handler instance, and thus
+ Handler handler = (Handler) handlers.get(i);
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking close on: " + handler.getClass().getName());
+ }
+ handler.close(currentMC);
+
+ // TODO when we close, are we done with the handler instance, and thus
// may call the PreDestroy annotated method? I don't think so, especially
// if we've cached the handler list somewhere.
} catch (Exception e) {
- // TODO: log it, but otherwise ignore
+ if (log.isDebugEnabled()) {
+ log.debug("An Exception occurred while calling handler.close()");
+ log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage());
+ }
}
}
}
@@ -411,10 +459,10 @@
// we can close all the Handlers in reverse order
if (direction == Direction.OUT) {
initContext(Direction.IN);
- callCloseHandlers(handlers.size() - 1, 0, Direction.IN);
+ callCloseHandlers(0, handlers.size() - 1, Direction.OUT);
} else { // IN case
initContext(Direction.IN);
- callCloseHandlers(0, handlers.size() - 1, Direction.OUT);
+ callCloseHandlers(handlers.size() - 1, 0, Direction.IN);
}
}
}
@@ -437,14 +485,24 @@
if (direction == Direction.OUT) {
for (; i <= end; i++) {
- boolean success = ((Handler) handlers.get(i)).handleFault(currentMC);
+ Handler handler = (Handler) handlers.get(i);
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking handleFault on: " + handler.getClass().getName());
+ }
+ boolean success = handler.handleFault(currentMC);
+
if (!success)
break;
switchContext(direction, i + 1);
}
} else { // IN case
for (; i >= end; i--) {
- boolean success = ((Handler) handlers.get(i)).handleFault(currentMC);
+ Handler handler = (Handler) handlers.get(i);
+ if (log.isDebugEnabled()) {
+ log.debug("Invoking handleFault on: " + handler.getClass().getName());
+ }
+ boolean success = handler.handleFault(currentMC);
+
if (!success)
break;
switchContext(direction, i - 1);
@@ -457,12 +515,14 @@
// need to check if message is already a fault message or not,
// probably by way of a flag (isFault) in the MessageContext or Message
+ if (log.isDebugEnabled()) {
+ log.debug("Creating a fault Message object for the exception: " + e.getClass().getName());
+ }
+
try {
-
/* TODO TODO TODO
- * There has GOT to be a better way to do this.
- */
-
+ * There has GOT to be a better way to do this.
+ */
if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
String protocolNS = (protocol == Protocol.soap11) ?
SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE :
@@ -479,7 +539,9 @@
// TODO something is wrong here. The message should be a response message, not
// a request message. I don't see how to change that. (see the debugger...)
// TODO probably also need to turn on message.WRITE_XML_DECLARATION
- mepCtx.setMessage(((MessageFactory) (FactoryRegistry.getFactory(MessageFactory.class))).createFrom(message));
+ MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+ Message msg = msgFactory.createFrom(message);
+ mepCtx.setMessage(msg);
} else {
throw ExceptionFactory.makeWebServiceException("We only support SOAP11 and SOAP12 for JAXWS handlers");
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/LogicalMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/LogicalMessageImpl.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/LogicalMessageImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/handler/LogicalMessageImpl.java Fri Jun 29 11:54:44 2007
@@ -20,9 +20,15 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
import javax.xml.bind.JAXBContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
@@ -30,11 +36,17 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.LogicalMessage;
import javax.xml.ws.WebServiceException;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFault;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MEPContext;
import org.apache.axis2.jaxws.message.Block;
@@ -42,11 +54,17 @@
import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
public class LogicalMessageImpl implements LogicalMessage {
+ private static final Log log = LogFactory.getLog(LogicalMessageImpl.class);
private MEPContext mepCtx;
@@ -69,6 +87,10 @@
* @see javax.xml.ws.LogicalMessage#getPayload(javax.xml.bind.JAXBContext)
*/
public Object getPayload(JAXBContext context) {
+ if (log.isDebugEnabled()) {
+ log.debug("Retreiving the message payload as a Source object");
+ }
+
BlockFactory factory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
JAXBBlockContext jbc = new JAXBBlockContext(context);
Object payload = _getPayload(jbc, factory);
@@ -79,17 +101,30 @@
Object payload = null;
try {
Block block = mepCtx.getMessageObject().getBodyBlock(context, factory);
- Object content = block.getBusinessObject(true);
-
- // For now, we have to create a new Block from the original content
- // and set that back on the message. The Block is not currently
- // able to create a copy of itself just yet.
- Payloads payloads = createPayloads(content);
-
- Block cacheBlock = factory.createFrom(payloads.CACHE_PAYLOAD, context, block.getQName());
- mepCtx.getMessageObject().setBodyBlock(cacheBlock);
-
- payload = payloads.HANDLER_PAYLOAD;
+ if (block != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("A message payload was found.");
+ }
+ Object content = block.getBusinessObject(true);
+
+ // For now, we have to create a new Block from the original content
+ // and set that back on the message. The Block is not currently
+ // able to create a copy of itself just yet.
+ Payloads payloads = createPayloads(content);
+ _setPayload(payloads.CACHE_PAYLOAD, context, factory);
+
+ payload = payloads.HANDLER_PAYLOAD;
+ }
+ else {
+ // If the block was null, then let's return an empty
+ // Source object rather than a null.
+ if (log.isDebugEnabled()) {
+ log.debug("There was no payload to be found. Returning an empty Source object");
+ }
+ byte[] bytes = new byte[0];
+ payload = new StreamSource(new ByteArrayInputStream(bytes));
+ }
+
} catch (XMLStreamException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
@@ -120,7 +155,35 @@
Block block = factory.createFrom(object, context, null);
if (mepCtx.getMessageObject() != null) {
- mepCtx.getMessageObject().setBodyBlock(block);
+ if (!mepCtx.getMessageObject().isFault()) {
+ mepCtx.getMessageObject().setBodyBlock(block);
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("The payload contains a fault");
+ }
+
+ mepCtx.getMessageObject().setBodyBlock(block);
+
+ // If the payload is a fault, then we can't set it back on the message
+ // as a block. Blocks are OMSourcedElements, and faults cannot be OMSourcedElements.
+ try {
+ SOAPEnvelope env = (SOAPEnvelope) mepCtx.getMessageObject().getAsOMElement();
+ String content = env.toStringWithConsume();
+
+ MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+ StringReader sr = new StringReader(content);
+ XMLStreamReader stream = StAXUtils.createXMLStreamReader(sr);
+ Message msg = mf.createFrom(stream, mepCtx.getMessageObject().getProtocol());
+
+ // This is required for proper serialization of the OM structure.
+ msg.getAsOMElement().build();
+
+ mepCtx.setMessage(msg);
+ } catch (Exception e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
+ }
}
}
@@ -149,7 +212,24 @@
// we need to create another one with the original content
// and assign it back.
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- payloads.HANDLER_PAYLOAD = new StreamSource(bais);
+ try {
+ // The Source object returned to the handler should be a
+ // DOMSource so that the handler programmer can read the data
+ // multiple times and (as opposed to using a StreamSource) and
+ // they can more easily access the data in DOM form.
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document dom = db.parse(bais);
+ payloads.HANDLER_PAYLOAD = new DOMSource(dom);
+ } catch (ParserConfigurationException e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ } catch (IOException e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ } catch (SAXException e) {
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
// We need a different byte[] for the cache so that we're not just
// building two Source objects that point to the same array.
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Fri Jun 29 11:54:44 2007
@@ -319,23 +319,23 @@
Object jbo = b;
if (isList || (type!=null && type.isArray())) {
- if(log.isDebugEnabled()){
- log.debug("marshalling type which is a List or Array");
- }
- //We conver to xsdListString only if the type is not known
- // to the context. In case a jaxbcontext is created from package
- // the array types or list are not know to the context.
- if(ctype == JAXBUtils.CONSTRUCTION_TYPE.BY_CONTEXT_PATH){
- QName qName = XMLRootElementUtil
- .getXmlRootElementQNameFromObject(b);
- String text = XSDListUtils
- .toXSDListString(getTypeEnabledObject(b));
- jbo = new JAXBElement(qName, String.class, text);
- }
- else if(ctype == JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY){
- //do nothing common array types should be know to the jaxbcontext.
- //so do not use xsdListString conversion.
- }
+ if(log.isDebugEnabled()){
+ log.debug("marshalling type which is a List or Array");
+ }
+ //We conver to xsdListString only if the type is not known
+ // to the context. In case a jaxbcontext is created from package
+ // the array types or list are not know to the context.
+ if(ctype == JAXBUtils.CONSTRUCTION_TYPE.BY_CONTEXT_PATH){
+ QName qName = XMLRootElementUtil
+ .getXmlRootElementQNameFromObject(b);
+ String text = XSDListUtils
+ .toXSDListString(getTypeEnabledObject(b));
+ jbo = new JAXBElement(qName, String.class, text);
+ }
+ else if(ctype == JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY){
+ //do nothing common array types should be know to the jaxbcontext.
+ //so do not use xsdListString conversion.
+ }
}
// When JAXBContext is created using a context path, it will not include Enum classes
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java Fri Jun 29 11:54:44 2007
@@ -18,6 +18,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.i18n.Messages;
@@ -251,5 +252,56 @@
}
return cl;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.message.Block#getBusinessObject(boolean)
+ */
+ public Object getBusinessObject(boolean consume) throws XMLStreamException,
+ WebServiceException {
+ if (consumed) {
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("BlockImplErr1",
+ this.getClass()
+ .getName()));
+ }
+
+ if (busObject != null) {
+ busObject = _getBOFromBO(busObject, busContext, consume);
+ } else {
+ // If the message is a fault, there are some special gymnastics that we have to do
+ // to get this working for all of the handler scenarios.
+ boolean hasFault = false;
+ if ((parent != null && parent.isFault()) ||
+ omElement.getQName().getLocalPart().equals(SOAP11Constants.SOAPFAULT_LOCAL_NAME)) {
+ hasFault = true;
+ }
+
+ // Transform reader into business object
+ if (!hasFault) {
+ XMLStreamReader reader;
+ if (omElement.getBuilder() != null && !omElement.getBuilder().isCompleted()) {
+ reader = omElement.getXMLStreamReaderWithoutCaching();
+ } else {
+ reader = omElement.getXMLStreamReader();
+ }
+ busObject = _getBOFromReader(reader, busContext);
+ }
+ else {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ omElement.serialize(baos);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ busObject = new StreamSource(bais);
+ }
+
+ omElement = null;
+ }
+
+ // Save the businessObject in a local variable
+ // so that we can reset the Block if consume was indicated
+ Object newBusObject = busObject;
+ setConsumed(consume);
+ return newBusObject;
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java Fri Jun 29 11:54:44 2007
@@ -58,15 +58,15 @@
private static Log log = LogFactory.getLog(BlockImpl.class);
- private Object busObject;
- private Object busContext;
+ protected Object busObject;
+ protected Object busContext;
- private OMElement omElement = null;
+ protected OMElement omElement = null;
- private QName qName;
- private BlockFactory factory;
- private boolean consumed = false;
- private Message parent;
+ protected QName qName;
+ protected BlockFactory factory;
+ protected boolean consumed = false;
+ protected Message parent;
/**
* A Block has the following components
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java Fri Jun 29 11:54:44 2007
@@ -150,6 +150,8 @@
content = _createSpine(Protocol.rest, Style.DOCUMENT, 0, root);
contentType = SPINE;
}
+ } else {
+ this.protocol = protocol;
}
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java Fri Jun 29 11:54:44 2007
@@ -80,7 +80,7 @@
public static boolean isFault(SOAPEnvelope envelope) {
SOAPBody body = envelope.getBody();
if (body != null) {
- return (body.getFault() != null);
+ return (body.hasFault() || body.getFault() != null);
}
return false;
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java Fri Jun 29 11:54:44 2007
@@ -21,6 +21,9 @@
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.dom.ElementImpl;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.i18n.Messages;
@@ -30,6 +33,7 @@
import org.apache.axis2.util.XMLUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
@@ -114,6 +118,12 @@
*/
public org.apache.axiom.soap.SOAPEnvelope toOM(SOAPEnvelope saajEnvelope)
throws WebServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting SAAJ SOAPEnvelope to an OM SOAPEnvelope");
+ }
+
+ // Before we do the conversion, we have to fix the QNames for fault elements
+ _fixFaultElements(saajEnvelope);
// Get a XMLStreamReader backed by a SOAPElement tree
XMLStreamReader reader = new SOAPElementReader(saajEnvelope);
// Get a SOAP OM Builder. Passing null causes the version to be automatically triggered
@@ -169,6 +179,10 @@
* @see org.apache.axis2.jaxws.message.util.SAAJConverter#toOM(javax.xml.soap.SOAPElement)
*/
public OMElement toOM(SOAPElement soapElement) throws WebServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting SAAJ SOAPElement to an OMElement");
+ }
+
// Get a XMLStreamReader backed by a SOAPElement tree
XMLStreamReader reader = new SOAPElementReader(soapElement);
// Get a OM Builder.
@@ -190,7 +204,11 @@
* @see org.apache.axis2.jaxws.message.util.SAAJConverter#toSAAJ(org.apache.axiom.om.OMElement, javax.xml.soap.SOAPElement)
*/
public SOAPElement toSAAJ(OMElement omElement, SOAPElement parent) throws WebServiceException {
- XMLStreamReader reader = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Converting OMElement to an SAAJ SOAPElement");
+ }
+
+ XMLStreamReader reader = null;
// If the OM element is not attached to a parser (builder), then the OM
// is built and you cannot ask for XMLStreamReaderWithoutCaching.
@@ -219,7 +237,11 @@
*/
public SOAPElement toSAAJ(OMElement omElement, SOAPElement parent, SOAPFactory sf)
throws WebServiceException {
- XMLStreamReader reader = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Converting OMElement to an SAAJ SOAPElement");
+ }
+
+ XMLStreamReader reader = null;
// If the OM element is not attached to a parser (builder), then the OM
// is built and you cannot ask for XMLStreamReaderWithoutCaching.
@@ -487,6 +509,90 @@
// TODO NLS
throw ExceptionFactory
.makeWebServiceException(Messages.getMessage("SAAJConverterErr2", event));
+ }
+
+
+ /*
+ * A utility method to fix the localnames of elements with an Axis2 SAAJ
+ * tree. The SAAJ impl relies on the Axiom SOAP APIs, which represent
+ * all faults as SOAP 1.2. This has to be corrected before we can convert
+ * to OM or the faults will not be handled correctly.
+ */
+ private void _fixFaultElements(SOAPEnvelope env) {
+ try {
+ // If we have a SOAP 1.2 envelope, then there's nothing to do.
+ if (env.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+ return;
+ }
+
+ SOAPBody body = env.getBody();
+ if (body != null && !body.hasFault()) {
+ if (log.isDebugEnabled()) {
+ log.debug("No fault found. No conversion necessary.");
+ }
+ return;
+ }
+ else if (body != null && body.hasFault()) {
+ if (log.isDebugEnabled()) {
+ log.debug("A fault was found. Converting the fault child elements to SOAP 1.1 format");
+ }
+
+ SOAPFault fault = body.getFault();
+
+ Iterator itr = fault.getChildElements();
+ while (itr.hasNext()) {
+ SOAPElement se = (SOAPElement) itr.next();
+ if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting: faultcode");
+ }
+ // Axis2 SAAJ stores the acutal faultcode text under a SOAPFaultValue object, so we have to
+ // get that and add it as a text node under the original element.
+ Node value = se.getFirstChild();
+ if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
+ org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value;
+ ElementImpl e = valueElement.getElement();
+ String content = e.getText();
+
+ SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME));
+ child.addTextNode(content);
+
+ se.detachNode();
+ }
+ }
+ else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting: detail");
+ }
+ se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
+ }
+ else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Converting: faultstring");
+ }
+ se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
+ // Axis2 SAAJ stores the acutal faultstring text under a SOAPFaultValue object, so we have to
+ // get that and add it as a text node under the original element.
+ Node value = se.getFirstChild();
+ if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
+ org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value;
+ ElementImpl e = valueElement.getElement();
+ String content = e.getText();
+
+ SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
+ child.addTextNode(content);
+
+ se.detachNode();
+ }
+ }
+ }
+ }
+ } catch (SOAPException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("An error occured while converting fault elements: " + e.getMessage());
+ }
+ throw ExceptionFactory.makeWebServiceException(e);
+ }
}
/**
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Fri Jun 29 11:54:44 2007
@@ -170,22 +170,21 @@
EndpointDispatcher dispatcher = getEndpointDispatcher(implClass, serviceInstance);
try {
responseMsgContext = dispatcher.invoke(requestMsgCtx);
- // we want the responseMsgContext to have the same parent as the requestMC
- responseMsgContext.setMEPContext(requestMsgCtx.getMEPContext());
} finally {
// Passed pivot point
requestMsgCtx.getMessage().setPostPivot();
}
- // Invoke outbound application handlers. It's safe to use the first object on the iterator because there is
- // always exactly one EndpointDescription on a server invoke
- // Also, if the message is oneWay, don't bother with response handlers. The responseMsgContext is probably NULL
- // anyway, and would cause an NPE.
+ // Invoke the outbound response handlers.
+ // If the message is one way, we should not invoke the response handlers. There is no response
+ // MessageContext since a one way invocation is considered to have a "void" return.
if (!isOneWay(requestMsgCtx.getAxisMessageContext())) {
+ responseMsgContext.setMEPContext(requestMsgCtx.getMEPContext());
+
HandlerInvokerUtils.invokeOutboundHandlers(responseMsgContext.getMEPContext(),
- ic.getHandlers(),
- HandlerChainProcessor.MEP.RESPONSE,
- false);
+ ic.getHandlers(),
+ HandlerChainProcessor.MEP.RESPONSE,
+ false);
}
} else
{ // the inbound handler chain must have had a problem, and we've reversed directions
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Fri Jun 29 11:54:44 2007
@@ -115,10 +115,10 @@
}
// Register our WebServiceFeature configurators.
- for (WebServiceFeatureConfigurator configurator : CONFIGURATORS) {
- WebServiceFeatureConfigUtil.addWebServiceFeatureConfigurator(context,
- Constants.WEB_SERVICE_FEATURE_CONFIGURATOR_LIST_ID, configurator);
- }
+// for (WebServiceFeatureConfigurator configurator : CONFIGURATORS) {
+// WebServiceFeatureConfigUtil.addWebServiceFeatureConfigurator(context,
+// Constants.WEB_SERVICE_FEATURE_CONFIGURATOR_LIST_ID, configurator);
+// }
}
//================================================
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ApplicationContextMigratorUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ApplicationContextMigratorUtil.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ApplicationContextMigratorUtil.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/migrator/ApplicationContextMigratorUtil.java Fri Jun 29 11:54:44 2007
@@ -1,398 +1,401 @@
-/*
- * 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.spi.migrator;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.core.MEPContext;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.core.util.MessageContextUtils;
-import org.apache.axis2.jaxws.description.ServiceDescription;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Map.Entry;
-import javax.xml.ws.handler.MessageContext.Scope;
-
-public class ApplicationContextMigratorUtil {
-
- private static final Log log = LogFactory.getLog(ApplicationContextMigrator.class);
-
- /**
- * Register a new ContextPropertyMigrator.
- *
- * @param configurationContext
- * @param contextMigratorListID The name of the property in the ConfigurationContext that
- * contains the list of migrators.
- * @param migrator
- */
- public static void addApplicationContextMigrator(ConfigurationContext configurationContext,
- String contextMigratorListID,
- ApplicationContextMigrator migrator) {
- List<ApplicationContextMigrator> migratorList =
- (List<ApplicationContextMigrator>)configurationContext
- .getProperty(contextMigratorListID);
-
- if (migratorList == null) {
- migratorList = new LinkedList<ApplicationContextMigrator>();
- configurationContext.setProperty(contextMigratorListID, migratorList);
- }
-
- // Check to make sure we haven't already added this migrator to the list.
- ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
- while (itr.hasNext()) {
- ApplicationContextMigrator m = itr.next();
- if (m.getClass().equals(migrator.getClass())) {
- return;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Adding ApplicationContextMigrator: " + migrator.getClass().getName());
- }
- migratorList.add(migrator);
- }
-
- /**
- * @param contextMigratorListID
- * @param requestContext
- * @param messageContext
- */
- public static void performMigrationToMessageContext(String contextMigratorListID,
- Map<String, Object> requestContext,
- MessageContext messageContext) {
- if (messageContext == null) {
- throw ExceptionFactory.makeWebServiceException("Null MessageContext");
- }
-
- ServiceDescription sd = messageContext.getEndpointDescription().getServiceDescription();
- if (sd != null) {
- ConfigurationContext configCtx = sd.getAxisConfigContext();
- List<ApplicationContextMigrator> migratorList =
- (List<ApplicationContextMigrator>)configCtx.getProperty(contextMigratorListID);
-
- if (migratorList != null) {
- ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
- while (itr.hasNext()) {
- ApplicationContextMigrator cpm = itr.next();
- if (log.isDebugEnabled()) {
- log.debug("migrator: " + cpm.getClass().getName() +
- ".migratePropertiesToMessageContext");
- }
- cpm.migratePropertiesToMessageContext(requestContext, messageContext);
- }
- }
- }
- }
-
- /**
- * @param contextMigratorListID
- * @param responseContext
- * @param messageContext
- */
- public static void performMigrationFromMessageContext(String contextMigratorListID,
- Map<String, Object> responseContext,
- MessageContext messageContext) {
- if (messageContext == null) {
- throw ExceptionFactory.makeWebServiceException("Null MessageContext");
- }
-
- ServiceDescription sd = messageContext.getEndpointDescription().getServiceDescription();
- if (sd != null) {
- ConfigurationContext configCtx = sd.getAxisConfigContext();
- List<ApplicationContextMigrator> migratorList =
- (List<ApplicationContextMigrator>)configCtx.getProperty(contextMigratorListID);
-
- if (migratorList != null) {
- ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
- while (itr.hasNext()) {
- ApplicationContextMigrator cpm = itr.next();
- if (log.isDebugEnabled()) {
- log.debug("migrator: " + cpm.getClass().getName() +
- ".migratePropertiesFromMessageContext");
- }
- cpm.migratePropertiesFromMessageContext(new ApplicationPropertyMapWriter(responseContext, messageContext.getMEPContext()), messageContext);
- }
- }
- }
- }
-
-
- /**
- *
- * ApplicationPropertyMapReader is a wrapper for the SOURCE property map passed to individual
- * property migrators. When a property migrator copies properties from a request context map
- * to a JAXWS MessageContext object, all of those properties should be marked APPLICATION
- * scope so they can later be retrieved from the request context or response context
- * in the client application.
- *
- * We override the EntrySet and Iterator to make sure the scope is properly set in the
- * "request context to JAXWS message context" case where the property migrator uses
- * get(String key) or putAll(Map source). This is not guaranteed to be correct, however,
- * because a property migrator could simply be doing a get(String key) to observe properties
- * rather than copy them. This just means we might be setting scope for a property that
- * never actually makes its way into the JAXWS message context. If someone (a hander,
- * perhaps) later sets a property with the same key, its scope may be "pre-set" and
- * therefore incorrect.
- *
- * TODO: find solution to above problem. The MEPContext.put sets an explicit scope whenever
- * a property is and a scope is not already present for that property. An example
- * of where this idea would produce unexpected results is where a scope was set to APPLICATION
- * in the property migrator for key/value pair "myKey/someValue", but myKey never actually made
- * it into the messagecontext. Later a handler might put a "myKey/theHandlerValue". In this
- * case the scope was already set to APPLICATION and would therefore not be set by the
- * MEPContext.put and therefore be incorrect.
- *
- * ApplicationPropertyMapReader only sets the scope if a migrator calls "get" on this map or
- * iterates over the entrySet, which may occur explicitly in the migrator, or implicitly when
- * this map is the source for a call such as otherMap.putAll(Map source).
- *
- * @author rott
- *
- */
- private static class ApplicationPropertyMapReader extends HashMap<String, Object> {
-
- private Map<String, Object> userMap;
- private MEPContext mepCtx;
-
- public ApplicationPropertyMapReader(Map<String, Object> userMap, MEPContext mepCtx) {
- this.userMap = userMap;
- this.mepCtx = mepCtx;
- }
-
- @Override
- public Object put(String key, Object value) {
- //mepCtx.setScope(key, Scope.APPLICATION);
- return userMap.put(key, value);
- }
-
- @Override
- public void putAll(Map<? extends String, ? extends Object> m) {
- // we need to take advantage of the smarter put(String, Object)
- for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry)it.next();
- put((String)entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public boolean containsKey(Object key) {
- return userMap.containsKey(key);
- }
-
- @Override
- public boolean containsValue(Object value) {
- return userMap.containsValue(value);
- }
-
- @Override
- public Set entrySet() {
- return new ApplicationPropertyMapEntrySet(userMap.entrySet(), mepCtx);
- }
-
- @Override
- public Object get(Object key) {
- // WARNING: there's no real guarantee that the reason a migrator is getting
- // a property is due to it being put on the MessageContext.
- // We would therefore be setting scope for a property that never actually makes
- // its way into the messageContext.
- Object obj = userMap.get(key);
- if (obj != null) {
- mepCtx.setScope((String)key, Scope.APPLICATION);
- }
- return obj;
- }
-
- @Override
- public boolean isEmpty() {
- return userMap.isEmpty();
- }
-
- @Override
- public Set keySet() {
- return userMap.keySet();
- }
-
- @Override
- public Object remove(Object key) {
- return userMap.remove(key);
- }
-
- @Override
- public int size() {
- return userMap.size();
- }
-
- @Override
- public Collection values() {
- return userMap.values();
- }
-
- private class ApplicationPropertyMapEntrySet extends AbstractSet {
-
- Set containedSet;
- MEPContext mepCtx;
-
- public ApplicationPropertyMapEntrySet(Set set, MEPContext mepCtx) {
- containedSet = set;
- this.mepCtx = mepCtx;
- }
-
- @Override
- public EntrySetIterator iterator() {
- return new EntrySetIterator(containedSet.iterator(), mepCtx);
- }
-
- @Override
- public int size() {
- return containedSet.size();
- }
-
- }
-
- private class EntrySetIterator implements Iterator {
-
- private Iterator containedIterator;
- private MEPContext mepCtx;
-
- private EntrySetIterator(Iterator containedIterator, MEPContext mepCtx) {
- this.containedIterator = containedIterator;
- this.mepCtx = mepCtx;
- }
-
- // override remove() to make this Iterator class read-only
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- return containedIterator.hasNext();
- }
-
- public Object next() {
- // WARNING: there's no real guarantee that the reason a migrator is iterating
- // over the properties is due to this being the source object for a putAll(source)
- // We would therefore be setting scope for a property that never actually makes
- // its way into the messageContext
- Entry entry = (Entry)containedIterator.next();
- mepCtx.setScope((String)entry.getKey(), Scope.APPLICATION);
- return entry;
- }
- }
- }
-
- /**
- * ApplicationPropertyMapWriter is similar to the ApplicationPropertyMapReader in that it
- * observes scope to determine what can be returned to a property migrator. Individual
- * property migrators should only be allowed to retrieve APPLICATION-scoped properties.
- *
- * TODO: There's quite a bit of expensive logic that would need to go into this to be
- * fully correct. For example, if a migrator calls size, we cannot simply return
- * userMap.size(). Rather, we would have to count only the APPLICATION scoped properties
- * and return those.
- *
- * @author rott
- *
- */
- private static class ApplicationPropertyMapWriter extends HashMap<String, Object> {
-
- private Map<String, Object> userMap;
- private MEPContext mepCtx;
-
- public ApplicationPropertyMapWriter(Map<String, Object> userMap, MEPContext mepCtx) {
- this.userMap = userMap;
- this.mepCtx = mepCtx;
- }
-
- @Override
- public Object put(String key, Object value) {
- // notice the logic here! We won't put a property on the userMap that is not APPLICATION scoped
- if (mepCtx.getScope(key) == Scope.APPLICATION) {
- return userMap.put(key, value);
- }
- return null;
- }
-
- @Override
- public void putAll(Map<? extends String, ? extends Object> m) {
- // we need to take advantage of the smarter put(String, Object)
- for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry)it.next();
- put((String)entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public boolean containsKey(Object key) {
- if (mepCtx.getScope((String)key) == Scope.APPLICATION) {
- return userMap.containsKey(key);
- }
- return false;
- }
-
- @Override
- public boolean containsValue(Object value) {
- return userMap.containsValue(value);
- }
-
- @Override
- public Set entrySet() {
- return userMap.entrySet();
- }
-
- @Override
- public Object get(Object key) {
- return userMap.get(key);
- }
-
- @Override
- public boolean isEmpty() {
- return userMap.isEmpty();
- }
-
- @Override
- public Set keySet() {
- return userMap.keySet();
- }
-
- @Override
- public Object remove(Object key) {
- return userMap.remove(key);
- }
-
- @Override
- public int size() {
- return userMap.size();
- }
-
- @Override
- public Collection values() {
- return userMap.values();
- }
- }
-}
+/*
+ * 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.spi.migrator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.MEPContext;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.core.util.MessageContextUtils;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map.Entry;
+import javax.xml.ws.handler.MessageContext.Scope;
+
+public class ApplicationContextMigratorUtil {
+
+ private static final Log log = LogFactory.getLog(ApplicationContextMigrator.class);
+
+ /**
+ * Register a new ContextPropertyMigrator.
+ *
+ * @param configurationContext
+ * @param contextMigratorListID The name of the property in the ConfigurationContext that
+ * contains the list of migrators.
+ * @param migrator
+ */
+ public static void addApplicationContextMigrator(ConfigurationContext configurationContext,
+ String contextMigratorListID,
+ ApplicationContextMigrator migrator) {
+ List<ApplicationContextMigrator> migratorList =
+ (List<ApplicationContextMigrator>)configurationContext
+ .getProperty(contextMigratorListID);
+
+ if (migratorList == null) {
+ migratorList = new LinkedList<ApplicationContextMigrator>();
+ configurationContext.setProperty(contextMigratorListID, migratorList);
+ }
+
+ synchronized (migratorList) {
+ // Check to make sure we haven't already added this migrator to the
+ // list.
+ ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
+ while (itr.hasNext()) {
+ ApplicationContextMigrator m = itr.next();
+ if (m.getClass().equals(migrator.getClass())) {
+ return;
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Adding ApplicationContextMigrator: " + migrator.getClass().getName());
+ }
+ migratorList.add(migrator);
+ }
+ }
+
+ /**
+ * @param contextMigratorListID
+ * @param requestContext
+ * @param messageContext
+ */
+ public static void performMigrationToMessageContext(String contextMigratorListID,
+ Map<String, Object> requestContext,
+ MessageContext messageContext) {
+ if (messageContext == null) {
+ throw ExceptionFactory.makeWebServiceException("Null MessageContext");
+ }
+
+ ServiceDescription sd = messageContext.getEndpointDescription().getServiceDescription();
+ if (sd != null) {
+ ConfigurationContext configCtx = sd.getAxisConfigContext();
+ List<ApplicationContextMigrator> migratorList = (List<ApplicationContextMigrator>)configCtx.getProperty(contextMigratorListID);
+ synchronized(migratorList){
+ if (migratorList != null) {
+ ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
+ while (itr.hasNext()) {
+ ApplicationContextMigrator cpm = itr.next();
+ if (log.isDebugEnabled()) {
+ log.debug("migrator: " + cpm.getClass().getName() + ".migratePropertiesToMessageContext");
+ }
+ cpm.migratePropertiesToMessageContext(new ApplicationPropertyMapReader(requestContext, messageContext.getMEPContext()), messageContext);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @param contextMigratorListID
+ * @param responseContext
+ * @param messageContext
+ */
+ public static void performMigrationFromMessageContext(String contextMigratorListID,
+ Map<String, Object> responseContext,
+ MessageContext messageContext) {
+ if (messageContext == null) {
+ throw ExceptionFactory.makeWebServiceException("Null MessageContext");
+ }
+
+ ServiceDescription sd = messageContext.getEndpointDescription().getServiceDescription();
+ if (sd != null) {
+ ConfigurationContext configCtx = sd.getAxisConfigContext();
+ List<ApplicationContextMigrator> migratorList =
+ (List<ApplicationContextMigrator>)configCtx.getProperty(contextMigratorListID);
+
+ synchronized(migratorList){
+ if (migratorList != null) {
+ ListIterator<ApplicationContextMigrator> itr = migratorList.listIterator();
+ while (itr.hasNext()) {
+ ApplicationContextMigrator cpm = itr.next();
+ if (log.isDebugEnabled()) {
+ log.debug("migrator: " + cpm.getClass().getName() + ".migratePropertiesFromMessageContext");
+ }
+ cpm.migratePropertiesFromMessageContext(new ApplicationPropertyMapWriter(responseContext, messageContext.getMEPContext()), messageContext);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ *
+ * ApplicationPropertyMapReader is a wrapper for the SOURCE property map passed to individual
+ * property migrators. When a property migrator copies properties from a request context map
+ * to a JAXWS MessageContext object, all of those properties should be marked APPLICATION
+ * scope so they can later be retrieved from the request context or response context
+ * in the client application.
+ *
+ * We override the EntrySet and Iterator to make sure the scope is properly set in the
+ * "request context to JAXWS message context" case where the property migrator uses
+ * get(String key) or putAll(Map source). This is not guaranteed to be correct, however,
+ * because a property migrator could simply be doing a get(String key) to observe properties
+ * rather than copy them. This just means we might be setting scope for a property that
+ * never actually makes its way into the JAXWS message context. If someone (a hander,
+ * perhaps) later sets a property with the same key, its scope may be "pre-set" and
+ * therefore incorrect.
+ *
+ * TODO: find solution to above problem. The MEPContext.put sets an explicit scope whenever
+ * a property is and a scope is not already present for that property. An example
+ * of where this idea would produce unexpected results is where a scope was set to APPLICATION
+ * in the property migrator for key/value pair "myKey/someValue", but myKey never actually made
+ * it into the messagecontext. Later a handler might put a "myKey/theHandlerValue". In this
+ * case the scope was already set to APPLICATION and would therefore not be set by the
+ * MEPContext.put and therefore be incorrect.
+ *
+ * ApplicationPropertyMapReader only sets the scope if a migrator calls "get" on this map or
+ * iterates over the entrySet, which may occur explicitly in the migrator, or implicitly when
+ * this map is the source for a call such as otherMap.putAll(Map source).
+ *
+ * @author rott
+ *
+ */
+ private static class ApplicationPropertyMapReader extends HashMap<String, Object> {
+
+ private Map<String, Object> userMap;
+ private MEPContext mepCtx;
+
+ public ApplicationPropertyMapReader(Map<String, Object> userMap, MEPContext mepCtx) {
+ this.userMap = userMap;
+ this.mepCtx = mepCtx;
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ //mepCtx.setScope(key, Scope.APPLICATION);
+ return userMap.put(key, value);
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends Object> m) {
+ // we need to take advantage of the smarter put(String, Object)
+ for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
+ Entry entry = (Entry)it.next();
+ put((String)entry.getKey(), entry.getValue());
+ }
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return userMap.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return userMap.containsValue(value);
+ }
+
+ @Override
+ public Set entrySet() {
+ return new ApplicationPropertyMapEntrySet(userMap.entrySet(), mepCtx);
+ }
+
+ @Override
+ public Object get(Object key) {
+ // WARNING: there's no real guarantee that the reason a migrator is getting
+ // a property is due to it being put on the MessageContext.
+ // We would therefore be setting scope for a property that never actually makes
+ // its way into the messageContext.
+ Object obj = userMap.get(key);
+ if (obj != null) {
+ mepCtx.setScope((String)key, Scope.APPLICATION);
+ }
+ return obj;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return userMap.isEmpty();
+ }
+
+ @Override
+ public Set keySet() {
+ return userMap.keySet();
+ }
+
+ @Override
+ public Object remove(Object key) {
+ return userMap.remove(key);
+ }
+
+ @Override
+ public int size() {
+ return userMap.size();
+ }
+
+ @Override
+ public Collection values() {
+ return userMap.values();
+ }
+
+ private class ApplicationPropertyMapEntrySet extends AbstractSet {
+
+ Set containedSet;
+ MEPContext mepCtx;
+
+ public ApplicationPropertyMapEntrySet(Set set, MEPContext mepCtx) {
+ containedSet = set;
+ this.mepCtx = mepCtx;
+ }
+
+ @Override
+ public EntrySetIterator iterator() {
+ return new EntrySetIterator(containedSet.iterator(), mepCtx);
+ }
+
+ @Override
+ public int size() {
+ return containedSet.size();
+ }
+
+ }
+
+ private class EntrySetIterator implements Iterator {
+
+ private Iterator containedIterator;
+ private MEPContext mepCtx;
+
+ private EntrySetIterator(Iterator containedIterator, MEPContext mepCtx) {
+ this.containedIterator = containedIterator;
+ this.mepCtx = mepCtx;
+ }
+
+ // override remove() to make this Iterator class read-only
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasNext() {
+ return containedIterator.hasNext();
+ }
+
+ public Object next() {
+ // WARNING: there's no real guarantee that the reason a migrator is iterating
+ // over the properties is due to this being the source object for a putAll(source)
+ // We would therefore be setting scope for a property that never actually makes
+ // its way into the messageContext
+ Entry entry = (Entry)containedIterator.next();
+ mepCtx.setScope((String)entry.getKey(), Scope.APPLICATION);
+ return entry;
+ }
+ }
+ }
+
+ /**
+ * ApplicationPropertyMapWriter is similar to the ApplicationPropertyMapReader in that it
+ * observes scope to determine what can be returned to a property migrator. Individual
+ * property migrators should only be allowed to retrieve APPLICATION-scoped properties.
+ *
+ * TODO: There's quite a bit of expensive logic that would need to go into this to be
+ * fully correct. For example, if a migrator calls size, we cannot simply return
+ * userMap.size(). Rather, we would have to count only the APPLICATION scoped properties
+ * and return those.
+ *
+ * @author rott
+ *
+ */
+ private static class ApplicationPropertyMapWriter extends HashMap<String, Object> {
+
+ private Map<String, Object> userMap;
+ private MEPContext mepCtx;
+
+ public ApplicationPropertyMapWriter(Map<String, Object> userMap, MEPContext mepCtx) {
+ this.userMap = userMap;
+ this.mepCtx = mepCtx;
+ }
+
+ @Override
+ public Object put(String key, Object value) {
+ // notice the logic here! We won't put a property on the userMap that is not APPLICATION scoped
+ if (mepCtx.getScope(key) == Scope.APPLICATION) {
+ return userMap.put(key, value);
+ }
+ return null;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends Object> m) {
+ // we need to take advantage of the smarter put(String, Object)
+ for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
+ Entry entry = (Entry)it.next();
+ put((String)entry.getKey(), entry.getValue());
+ }
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ if (mepCtx.getScope((String)key) == Scope.APPLICATION) {
+ return userMap.containsKey(key);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return userMap.containsValue(value);
+ }
+
+ @Override
+ public Set entrySet() {
+ return userMap.entrySet();
+ }
+
+ @Override
+ public Object get(Object key) {
+ return userMap.get(key);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return userMap.isEmpty();
+ }
+
+ @Override
+ public Set keySet() {
+ return userMap.keySet();
+ }
+
+ @Override
+ public Object remove(Object key) {
+ return userMap.remove(key);
+ }
+
+ @Override
+ public int size() {
+ return userMap.size();
+ }
+
+ @Override
+ public Collection values() {
+ return userMap.values();
+ }
+ }
+}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Fri Jun 29 11:54:44 2007
@@ -40,6 +40,7 @@
import org.apache.axis2.jaxws.endpoint.BasicEndpointTests;
import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
import org.apache.axis2.jaxws.handler.HandlerChainProcessorTests;
+import org.apache.axis2.jaxws.handler.context.CompositeMessageContextTests;
import org.apache.axis2.jaxws.handler.context.LogicalMessageContextTests;
import org.apache.axis2.jaxws.i18n.JaxwsMessageBundleTests;
import org.apache.axis2.jaxws.injection.ResourceInjectionTests;
@@ -141,6 +142,7 @@
// ------ Handler Tests ------
suite.addTestSuite(LogicalMessageContextTests.class);
+ suite.addTestSuite(CompositeMessageContextTests.class);
suite.addTestSuite(HandlerChainProcessorTests.class);
// ------ Message Tests ------
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerChainProcessorTests.java Fri Jun 29 11:54:44 2007
@@ -780,7 +780,7 @@
mc1.setMEPContext(new MEPContext(mc1));
processor.processFault(mc1.getMEPContext(), HandlerChainProcessor.Direction.OUT);
- assertEquals("L2f:L1f:S1f:S2f:S2c:S1c:L1c:L2c:", result);
+ assertEquals("L2f:L1f:S1f:S2f:L2c:L1c:S1c:S2c:", result);
}
/*
@@ -809,7 +809,7 @@
processor.processFault(mc1.getMEPContext(), HandlerChainProcessor.Direction.OUT);
// notice all handlers are closed in this scenario
- assertEquals("L2f:L1f:S2c:S1c:L1c:L2c:", result);
+ assertEquals("L2f:L1f:L2c:L1c:S1c:S2c:", result);
}
/*
@@ -844,7 +844,7 @@
}
assertNotNull(e);
- assertEquals("S2f:S1f:L1f:L2c:L1c:S1c:S2c:", result);
+ assertEquals("S2f:S1f:L1f:S2c:S1c:L1c:L2c:", result);
}
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/LogicalMessageContextTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/LogicalMessageContextTests.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/LogicalMessageContextTests.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/handler/context/LogicalMessageContextTests.java Fri Jun 29 11:54:44 2007
@@ -59,6 +59,11 @@
private final String INPUT = "sample input";
private final String FAULT_INPUT = "sample fault input";
+ private final String sampleSOAP11FaultPayload =
+ "<soapenv:Fault xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ + "<faultcode>soapenv:Server</faultcode>" + "<faultstring>" + FAULT_INPUT
+ + "</faultstring>" + "</soapenv:Fault>";
+
public LogicalMessageContextTests(String name) {
super(name);
}
@@ -206,6 +211,31 @@
EchoString echo = (EchoString) obj;
assertTrue("The EchoString object had null input", echo.getInput() != null);
assertTrue("The EchoString object had bad input: " + echo.getInput(), echo.getInput().equals(INPUT));
+ }
+
+
+ public void testConvertMessageToFault() throws Exception {
+ LogicalMessageContext lmc = createSampleContext();
+
+ LogicalMessage msg = lmc.getMessage();
+ assertTrue("The returned LogicalMessage was null", msg != null);
+
+ Source payload = msg.getPayload();
+ assertTrue("The returned payload (Source) was null", payload != null);
+
+ String resultContent = _getStringFromSource(payload);
+ assertTrue("The content returned was null", resultContent != null);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(sampleSOAP11FaultPayload.getBytes());
+ StreamSource faultSource = new StreamSource(bais);
+
+ msg.setPayload(faultSource);
+
+ Source newFaultSource = msg.getPayload();
+ assertTrue("The new fault content returned was null", faultSource != null);
+
+ String newFaultContent = _getStringFromSource(newFaultSource);
+ assertTrue("The new fault content returned was invalid", newFaultContent.equals(sampleSOAP11FaultPayload));
}
private LogicalMessageContext createSampleContext() throws Exception {
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java Fri Jun 29 11:54:44 2007
@@ -16,16 +16,23 @@
*/
package org.apache.axis2.jaxws.message;
+import java.io.ByteArrayOutputStream;
import java.io.StringReader;
import java.util.Locale;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
import junit.framework.TestCase;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
/**
@@ -275,6 +282,55 @@
fail(e.toString());
}
}
+
+
+ public void testGetSOAP11XMLFaultAsOM() throws Exception {
+ MessageFactory factory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+ Message msg = factory.create(Protocol.soap11);
+
+ XMLFaultReason reason = new XMLFaultReason("sample fault reason");
+ XMLFault fault = new XMLFault(XMLFaultCode.SENDER, reason);
+ msg.setXMLFault(fault);
+
+ OMElement om = msg.getAsOMElement();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ om.serializeAndConsume(baos);
+
+ String env = new String(baos.toByteArray());
+ assertTrue(env.indexOf("faultcode") > 0);
+ assertTrue(env.indexOf("faultstring") > 0);
+ }
+
+ public void testGetSOAP11XMLFaultAsBlock() throws Exception {
+ MessageFactory factory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+ Message msg = factory.create(Protocol.soap11);
+
+ XMLFaultReason reason = new XMLFaultReason("sample fault reason");
+ XMLFault fault = new XMLFault(XMLFaultCode.SENDER, reason);
+ msg.setXMLFault(fault);
+
+ BlockFactory bf = (BlockFactory) FactoryRegistry.getFactory(SourceBlockFactory.class);
+ Block b = msg.getBodyBlock(null, bf);
+
+ Source content = (Source) b.getBusinessObject(true);
+ byte[] bytes = _getBytes(content);
+ String faultContent = new String(bytes);
+
+ System.out.println(">> fault content: " + faultContent);
+ assertTrue(faultContent.indexOf("faultcode") > 0);
+ assertTrue(faultContent.indexOf("faultstring") > 0);
+ }
+
+ private byte[] _getBytes(Source input) throws Exception {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t = tf.newTransformer();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StreamResult output = new StreamResult(baos);
+
+ t.transform(input, output);
+
+ return baos.toByteArray();
+ }
}
-
Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java Fri Jun 29 11:54:44 2007
@@ -171,7 +171,7 @@
}
// TODO: disabled until handler support is more complete
- public void _testAddNumbersHandlerWithFault() {
+ public void testAddNumbersHandlerWithFault() {
try{
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
@@ -287,7 +287,7 @@
// TODO: disabled until handler support is more complete
- public void _testAddNumbersClientProtoAndLogicalHandler() {
+ public void testAddNumbersClientProtoAndLogicalHandler() {
try{
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
@@ -315,13 +315,16 @@
} catch(Exception e) {
e.printStackTrace();
assertTrue("Exception should be SOAPFaultException", e instanceof SOAPFaultException);
- assertEquals(((SOAPFaultException)e).getMessage(), "AddNumbersLogicalHandler2 was here");
+ //AXIS2-2417 - assertEquals(((SOAPFaultException)e).getMessage(), "AddNumbersLogicalHandler2 was here");
+ assertEquals(((SOAPFaultException)e).getMessage(), "Got value 101. " +
+ "AddNumbersHandlerPortTypeImpl.addNumbersHandler method is " +
+ "correctly throwing this exception as part of testing");
+
}
TestLogger.logger.debug("----------------------------------");
}
- // TODO: disabled until handler support is more complete
- public void _testAddNumbersClientHandlerWithFault() {
+ public void testAddNumbersClientHandlerWithFault() {
try{
TestLogger.logger.debug("----------------------------------");
TestLogger.logger.debug("test: " + getName());
Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/pom.xml?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/pom.xml (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/pom.xml Fri Jun 29 11:54:44 2007
@@ -75,6 +75,16 @@
<dependency>
<groupId>org.apache.woden</groupId>
<artifactId>woden</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>annogen</groupId>
@@ -100,6 +110,11 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
<profile>
Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/project.xml?view=diff&rev=551999&r1=551998&r2=551999
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/project.xml (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/project.xml Fri Jun 29 11:54:44 2007
@@ -201,6 +201,12 @@
<artifactId>jakarta-httpcore-niossl</artifactId>
<version>4.0-alpha4</version>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>${xmlunit.version}</version>
+ </dependency>
+
</dependencies>
<build>
<sourceModifications>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org