JBossWS SVN: r1456 - branches/jbossws-1.0
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2006-11-17 04:38:46 -0500 (Fri, 17 Nov 2006)
New Revision: 1456
Added:
branches/jbossws-1.0/jbossws-1.0/
Log:
Initial import.
18 years, 1 month
JBossWS SVN: r1455 - in trunk/src: main/java/org/jboss/ws/common main/java/org/jboss/ws/deployment main/java/org/jboss/ws/integration/jboss50 main/java/org/jboss/ws/jaxrpc main/java/org/jboss/ws/jaxws/client main/java/org/jboss/ws/jaxws/core main/java/org/jboss/ws/metadata main/java/org/jboss/ws/server test test/java/org/jboss/test/ws/common/soap test/java/org/jboss/test/ws/jaxrpc/encoded/marshalltest test/java/org/jboss/test/ws/jaxrpc/jbws807 test/java/org/jboss/test/ws/jaxrpc/samples/exc
by jbossws-commits@lists.jboss.org
Author: alex.guizar(a)jboss.com
Date: 2006-11-17 02:56:40 -0500 (Fri, 17 Nov 2006)
New Revision: 1455
Added:
trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultHelperJAXRPC.java
trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPFaultHelperJAXWS.java
Removed:
trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java
Modified:
trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP11BindingJAXRPC.java
trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP12BindingJAXRPC.java
trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java
trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java
trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP11BindingJAXWS.java
trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP12BindingJAXWS.java
trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java
trunk/src/main/java/org/jboss/ws/server/ServiceEndpoint.java
trunk/src/main/java/org/jboss/ws/server/ServiceEndpointInvokerJSE.java
trunk/src/test/build.xml
trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPFaultTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxrpc/encoded/marshalltest/MarshallTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxrpc/jbws807/JBWS807TestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxrpc/samples/exception/ExceptionTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/exception/ExceptionTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webmethod/JSR181WebMethodTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ObjectFactory.java
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/replyto/AddressingReplyToTestCase.java
Log:
JBWS-1297
Modified: trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -31,7 +31,6 @@
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
-import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
@@ -49,12 +48,10 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
-import org.jboss.ws.xop.XOPContext;
import org.jboss.ws.binding.BindingException;
import org.jboss.ws.binding.EndpointInvocation;
import org.jboss.ws.binding.UnboundHeader;
import org.jboss.ws.jaxrpc.ParameterWrapping;
-import org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper;
import org.jboss.ws.jaxrpc.Style;
import org.jboss.ws.metadata.OperationMetaData;
import org.jboss.ws.metadata.ParameterMetaData;
@@ -75,6 +72,7 @@
import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.utils.JavaUtils;
import org.jboss.ws.utils.MimeUtils;
+import org.jboss.ws.xop.XOPContext;
import org.jboss.xb.binding.NamespaceRegistry;
import org.w3c.dom.Element;
@@ -642,6 +640,8 @@
handleException(e);
}
}
+
+ public abstract SOAPMessage exceptionToFaultMessage(Exception ex);
private void verifySOAPVersion(OperationMetaData opMetaData, SOAPEnvelope soapEnvelope)
{
Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -298,13 +298,22 @@
{
for (OperationMetaData operation : epMetaData.getOperations())
{
+ // parameters
for (ParameterMetaData paramMetaData : operation.getParameters())
{
populateXmlType(paramMetaData);
}
+
+ // return value
ParameterMetaData returnParameter = operation.getReturnParameter();
if (returnParameter != null)
populateXmlType(returnParameter);
+
+ // faults
+ for (FaultMetaData faultMetaData : operation.getFaults())
+ {
+ populateXmlType(faultMetaData);
+ }
}
}
@@ -344,6 +353,17 @@
types.addTypeMapping(new TypeMappingMetaData(types, xmlType, javaName));
}
+
+ private void populateXmlType(FaultMetaData faultMetaData)
+ {
+ EndpointMetaData epMetaData = faultMetaData.getOperationMetaData().getEndpointMetaData();
+ TypesMetaData types = epMetaData.getServiceMetaData().getTypesMetaData();
+
+ QName xmlType = faultMetaData.getXmlType();
+ String faultBeanName = faultMetaData.getFaultBeanName();
+
+ types.addTypeMapping(new TypeMappingMetaData(types, xmlType, faultBeanName));
+ }
protected void processSOAPBinding(EndpointMetaData epMetaData, Class wsClass)
{
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -91,7 +91,7 @@
}
/** Invoke an instance of the SEI implementation bean */
- public void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv) throws SOAPFaultException
+ public void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv) throws SOAPFaultException, Exception
{
log.debug("invokeServiceEndpoint: " + epInv.getJavaMethod().getName());
@@ -125,9 +125,9 @@
Object retObj = container.localInvoke(implMethod, args);
epInv.setReturnValue(retObj);
}
- catch (Throwable e)
+ catch (Throwable th)
{
- handleInvocationException(e);
+ handleInvocationException(th);
}
}
Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP11BindingJAXRPC.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP11BindingJAXRPC.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP11BindingJAXRPC.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -23,7 +23,6 @@
//$Id:SOAP11BindingJAXRPC.java 1054 2006-09-26 10:33:43Z thomas.diesler(a)jboss.com $
-import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.SOAPMessage;
import org.jboss.ws.common.CommonSOAP11Binding;
@@ -49,6 +48,12 @@
@Override
protected void throwFaultException(SOAPFaultImpl fault) throws Exception
{
- throw SOAPFaultExceptionHelper.getSOAPFaultException(fault);
+ throw SOAPFaultHelperJAXRPC.getSOAPFaultException(fault);
}
+
+ @Override
+ public SOAPMessage exceptionToFaultMessage(Exception ex)
+ {
+ return SOAPFaultHelperJAXRPC.exceptionToFaultMessage(ex);
+ }
}
Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP12BindingJAXRPC.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP12BindingJAXRPC.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/SOAP12BindingJAXRPC.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -48,6 +48,12 @@
@Override
protected void throwFaultException(SOAPFaultImpl fault) throws Exception
{
- throw SOAPFaultExceptionHelper.getSOAPFaultException(fault);
+ throw SOAPFaultHelperJAXRPC.getSOAPFaultException(fault);
}
+
+ @Override
+ public SOAPMessage exceptionToFaultMessage(Exception ex)
+ {
+ return SOAPFaultHelperJAXRPC.exceptionToFaultMessage(ex);
+ }
}
Deleted: trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -1,317 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.ws.jaxrpc;
-
-// $Id$
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.rpc.JAXRPCException;
-import javax.xml.rpc.encoding.TypeMapping;
-import javax.xml.rpc.soap.SOAPFaultException;
-import javax.xml.soap.Detail;
-import javax.xml.soap.DetailEntry;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.utils.DOMUtils;
-import org.jboss.ws.utils.DOMWriter;
-import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
-import org.jboss.ws.binding.BindingException;
-import org.jboss.ws.binding.DeserializerSupport;
-import org.jboss.ws.binding.SerializationContext;
-import org.jboss.ws.binding.SerializerSupport;
-import org.jboss.ws.common.CommonMessageContext;
-import org.jboss.ws.jaxrpc.encoding.DeserializerFactoryBase;
-import org.jboss.ws.jaxrpc.encoding.SerializerFactoryBase;
-import org.jboss.ws.metadata.FaultMetaData;
-import org.jboss.ws.metadata.OperationMetaData;
-import org.jboss.ws.soap.MessageContextAssociation;
-import org.jboss.ws.soap.MessageFactoryImpl;
-import org.jboss.ws.soap.NameImpl;
-import org.jboss.ws.soap.SOAPEnvelopeImpl;
-import org.jboss.ws.soap.SOAPFactoryImpl;
-import org.jboss.xb.binding.NamespaceRegistry;
-import org.w3c.dom.Element;
-
-/**
- * A Helper that translates between SOAPFaultException and SOAPFault.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 03-Feb-2005
- */
-public class SOAPFaultExceptionHelper
-{
- // provide logging
- private static Logger log = Logger.getLogger(SOAPFaultExceptionHelper.class);
-
- private static List<QName> allowedFaultCodes = new ArrayList<QName>();
- static
- {
- allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_CLIENT);
- allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_SERVER);
- allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_VERSION_MISMATCH);
- allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_MUST_UNDERSTAND);
- }
-
- /** Hide constructor */
- private SOAPFaultExceptionHelper()
- {
- }
-
- /** Factory method for FaultException for a given SOAPFault */
- public static SOAPFaultException getSOAPFaultException(SOAPFault soapFault)
- {
- QName faultCode = ((NameImpl)soapFault.getFaultCodeAsName()).toQName();
- String faultString = soapFault.getFaultString();
- String faultActor = soapFault.getFaultActor();
- Detail detail = soapFault.getDetail();
-
- SOAPFaultException faultEx = new SOAPFaultException(faultCode, faultString, faultActor, detail);
-
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- if (detail != null && msgContext != null)
- {
- SerializationContext serContext = msgContext.getSerializationContext();
- TypeMapping typeMapping = serContext.getTypeMapping();
-
- Iterator it = detail.getDetailEntries();
- while (it.hasNext())
- {
- DetailEntry deElement = (DetailEntry)it.next();
- Name deName = deElement.getElementName();
- QName xmlName = new QName(deName.getURI(), deName.getLocalName());
-
- OperationMetaData opMetaData = msgContext.getOperationMetaData();
- FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
- if (faultMetaData != null)
- {
- log.debug("Deserialize fault: " + faultMetaData);
- QName xmlType = faultMetaData.getXmlType();
- Class javaType = faultMetaData.getJavaType();
-
- // Get the deserializer from the type mapping
- DeserializerFactoryBase desFactory = (DeserializerFactoryBase)typeMapping.getDeserializer(javaType, xmlType);
- if (desFactory == null)
- throw new JAXRPCException("Cannot obtain deserializer factory for: " + xmlType);
-
- // Try jaxb deserialization
- try
- {
- // http://jira.jboss.org/jira/browse/JBWS-955
- // Cannot deserialize fault detail
- String prefix = deName.getPrefix();
- if (prefix.length() > 0)
- {
- String nsURI = deName.getURI();
- String attrValue = deElement.getAttribute("xmlns:" + prefix);
- if (nsURI.length() > 0 && attrValue.length() == 0)
- deElement.addNamespaceDeclaration(prefix, nsURI);
- }
-
- String xmlFragment = DOMWriter.printNode(deElement, false);
- DeserializerSupport des = (DeserializerSupport)desFactory.getDeserializer();
- Object userEx = des.deserialize(xmlName, xmlType, xmlFragment, serContext);
- if (userEx == null || (userEx instanceof Exception) == false)
- throw new WSException("Invalid deserialization result: " + userEx);
-
- faultEx.initCause((Exception)userEx);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- log.error("Cannot deserialize fault detail", ex);
- }
- }
- else
- {
- log.debug("Cannot find fault meta data for: " + xmlName);
- }
- }
- }
-
- return faultEx;
- }
-
- /** Translate the request exception into a SOAPFault message.
- */
- public static SOAPMessage exceptionToFaultMessage(Exception reqEx)
- {
- // Get or create the SOAPFaultException
- SOAPFaultException faultEx;
- if (reqEx instanceof SOAPFaultException)
- {
- faultEx = (SOAPFaultException)reqEx;
- }
- else
- {
- QName faultCode = Constants.SOAP11_FAULT_CODE_CLIENT;
- String faultString = (reqEx.getMessage() != null ? reqEx.getMessage() : reqEx.toString());
- faultEx = new SOAPFaultException(faultCode, faultString, null, null);
- faultEx.initCause(reqEx);
- }
-
- Throwable faultCause = faultEx.getCause();
- log.error("SOAP request exception", faultCause != null ? faultCause : faultEx);
-
- try
- {
- SOAPMessage faultMessage = toSOAPMessage(faultEx);
- return faultMessage;
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- log.error("Error creating SOAPFault message", ex);
- throw new JAXRPCException("Cannot create SOAPFault message for: " + faultEx);
- }
- }
-
- private static SOAPMessage toSOAPMessage(SOAPFaultException faultEx) throws SOAPException
- {
- assertFaultCode(faultEx.getFaultCode());
-
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- SerializationContext serContext = (msgContext != null ? msgContext.getSerializationContext() : new SerializationContextJAXRPC());
- NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
-
- MessageFactory factory = new MessageFactoryImpl();
- SOAPMessage soapMessage = factory.createMessage();
-
- SOAPEnvelopeImpl soapEnvelope = (SOAPEnvelopeImpl)soapMessage.getSOAPPart().getEnvelope();
- SOAPBody soapBody = soapEnvelope.getBody();
-
- QName faultCode = faultEx.getFaultCode();
- if (faultCode.getNamespaceURI().length() > 0)
- faultCode = nsRegistry.registerQName(faultCode);
-
- String faultString = getValidFaultString(faultEx);
- SOAPFault soapFault = soapBody.addFault(new NameImpl(faultCode), faultString);
-
- String faultActor = faultEx.getFaultActor();
- if (faultActor != null)
- {
- SOAPElement soapElement = soapFault.addChildElement("faultactor");
- soapElement.addTextNode(faultActor);
- }
-
- Exception faultCause = (Exception)faultEx.getCause();
- Detail detail = faultEx.getDetail();
- if (detail != null)
- {
- soapFault.addChildElement(detail);
- }
- else if (faultCause != null && (faultCause instanceof RuntimeException) == false)
- {
- Class javaType = faultCause.getClass();
-
- TypeMapping typeMapping = serContext.getTypeMapping();
-
- OperationMetaData opMetaData = msgContext.getOperationMetaData();
- if (opMetaData != null && opMetaData.getFault(javaType) != null)
- {
- FaultMetaData faultMetaData = opMetaData.getFault(javaType);
- QName xmlName = faultMetaData.getXmlName();
- QName xmlType = faultMetaData.getXmlType();
-
- xmlName = nsRegistry.registerQName(xmlName);
-
- // Get the serializer from the type mapping
- SerializerFactoryBase serFactory = (SerializerFactoryBase)typeMapping.getSerializer(javaType, xmlType);
- if (serFactory == null)
- throw new JAXRPCException("Cannot obtain serializer factory for: " + xmlType);
-
- try
- {
- SerializerSupport ser = (SerializerSupport)serFactory.getSerializer();
- String xmlFragment = ser.serialize(xmlName, xmlType, faultCause, serContext, null);
-
- SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
- Element domElement = DOMUtils.parse(xmlFragment);
- SOAPElement soapElement = soapFactory.createElement(domElement, true);
-
- detail = soapFault.addDetail();
- detail.addChildElement(soapElement);
- }
- catch (BindingException e)
- {
- throw new JAXRPCException(e);
- }
- catch (IOException e)
- {
- throw new JAXRPCException(e);
- }
- }
- else
- {
- log.debug("Cannot obtain fault meta data for: " + javaType);
- }
- }
-
- return soapMessage;
- }
-
- private static String getValidFaultString(SOAPFaultException faultEx)
- {
- String faultString = faultEx.getFaultString();
- if (faultString == null || faultString.length() == 0)
- faultString = "Unqualified " + faultEx.getFaultCode() + " fault";
-
- return faultString;
- }
-
- private static void assertFaultCode(QName faultCode)
- {
- if (faultCode == null)
- throw new IllegalArgumentException("faultcode cannot be null");
-
- // For lazy folkes like the CTS that don't bother to give
- // a namesapce URI, assume they use a standard code
- String nsURI = faultCode.getNamespaceURI();
- if ("".equals(nsURI))
- {
- log.warn("Empty namespace URI with fault code '" + faultCode + "', assuming: " + Constants.NS_SOAP11_ENV);
- faultCode = new QName(Constants.NS_SOAP11_ENV, faultCode.getLocalPart());
- }
-
- // WS-I allows non custom faultcodes if you use a non soap namespace
- if (Constants.NS_SOAP11_ENV.equals(nsURI) && allowedFaultCodes.contains(faultCode) == false)
- throw new IllegalArgumentException("Illegal faultcode '" + faultCode + "', allowed values are: " + allowedFaultCodes);
- }
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultHelperJAXRPC.java (from rev 1453, trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultExceptionHelper.java 2006-11-16 22:51:43 UTC (rev 1453)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/SOAPFaultHelperJAXRPC.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -0,0 +1,317 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ws.jaxrpc;
+
+// $Id$
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.JAXRPCException;
+import javax.xml.rpc.encoding.TypeMapping;
+import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.utils.DOMUtils;
+import org.jboss.ws.utils.DOMWriter;
+import org.jboss.ws.Constants;
+import org.jboss.ws.WSException;
+import org.jboss.ws.binding.BindingException;
+import org.jboss.ws.binding.DeserializerSupport;
+import org.jboss.ws.binding.SerializationContext;
+import org.jboss.ws.binding.SerializerSupport;
+import org.jboss.ws.common.CommonMessageContext;
+import org.jboss.ws.jaxrpc.encoding.DeserializerFactoryBase;
+import org.jboss.ws.jaxrpc.encoding.SerializerFactoryBase;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.soap.MessageContextAssociation;
+import org.jboss.ws.soap.MessageFactoryImpl;
+import org.jboss.ws.soap.NameImpl;
+import org.jboss.ws.soap.SOAPEnvelopeImpl;
+import org.jboss.ws.soap.SOAPFactoryImpl;
+import org.jboss.xb.binding.NamespaceRegistry;
+import org.w3c.dom.Element;
+
+/**
+ * A Helper that translates between SOAPFaultException and SOAPFault.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 03-Feb-2005
+ */
+public class SOAPFaultHelperJAXRPC
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(SOAPFaultHelperJAXRPC.class);
+
+ private static List<QName> allowedFaultCodes = new ArrayList<QName>();
+ static
+ {
+ allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_CLIENT);
+ allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_SERVER);
+ allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_VERSION_MISMATCH);
+ allowedFaultCodes.add(Constants.SOAP11_FAULT_CODE_MUST_UNDERSTAND);
+ }
+
+ /** Hide constructor */
+ private SOAPFaultHelperJAXRPC()
+ {
+ }
+
+ /** Factory method for FaultException for a given SOAPFault */
+ public static SOAPFaultException getSOAPFaultException(SOAPFault soapFault)
+ {
+ QName faultCode = ((NameImpl)soapFault.getFaultCodeAsName()).toQName();
+ String faultString = soapFault.getFaultString();
+ String faultActor = soapFault.getFaultActor();
+ Detail detail = soapFault.getDetail();
+
+ SOAPFaultException faultEx = new SOAPFaultException(faultCode, faultString, faultActor, detail);
+
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ if (detail != null && msgContext != null)
+ {
+ SerializationContext serContext = msgContext.getSerializationContext();
+ TypeMapping typeMapping = serContext.getTypeMapping();
+
+ Iterator it = detail.getDetailEntries();
+ while (it.hasNext())
+ {
+ DetailEntry deElement = (DetailEntry)it.next();
+ Name deName = deElement.getElementName();
+ QName xmlName = new QName(deName.getURI(), deName.getLocalName());
+
+ OperationMetaData opMetaData = msgContext.getOperationMetaData();
+ FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
+ if (faultMetaData != null)
+ {
+ log.debug("Deserialize fault: " + faultMetaData);
+ QName xmlType = faultMetaData.getXmlType();
+ Class javaType = faultMetaData.getJavaType();
+
+ // Get the deserializer from the type mapping
+ DeserializerFactoryBase desFactory = (DeserializerFactoryBase)typeMapping.getDeserializer(javaType, xmlType);
+ if (desFactory == null)
+ throw new JAXRPCException("Cannot obtain deserializer factory for: " + xmlType);
+
+ // Try jaxb deserialization
+ try
+ {
+ // http://jira.jboss.org/jira/browse/JBWS-955
+ // Cannot deserialize fault detail
+ String prefix = deName.getPrefix();
+ if (prefix.length() > 0)
+ {
+ String nsURI = deName.getURI();
+ String attrValue = deElement.getAttribute("xmlns:" + prefix);
+ if (nsURI.length() > 0 && attrValue.length() == 0)
+ deElement.addNamespaceDeclaration(prefix, nsURI);
+ }
+
+ String xmlFragment = DOMWriter.printNode(deElement, false);
+ DeserializerSupport des = (DeserializerSupport)desFactory.getDeserializer();
+ Object userEx = des.deserialize(xmlName, xmlType, xmlFragment, serContext);
+ if (userEx == null || (userEx instanceof Exception) == false)
+ throw new WSException("Invalid deserialization result: " + userEx);
+
+ faultEx.initCause((Exception)userEx);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot deserialize fault detail", ex);
+ }
+ }
+ else
+ {
+ log.debug("Cannot find fault meta data for: " + xmlName);
+ }
+ }
+ }
+
+ return faultEx;
+ }
+
+ /** Translate the request exception into a SOAPFault message.
+ */
+ public static SOAPMessage exceptionToFaultMessage(Exception reqEx)
+ {
+ // Get or create the SOAPFaultException
+ SOAPFaultException faultEx;
+ if (reqEx instanceof SOAPFaultException)
+ {
+ faultEx = (SOAPFaultException)reqEx;
+ }
+ else
+ {
+ QName faultCode = Constants.SOAP11_FAULT_CODE_CLIENT;
+ String faultString = (reqEx.getMessage() != null ? reqEx.getMessage() : reqEx.toString());
+ faultEx = new SOAPFaultException(faultCode, faultString, null, null);
+ faultEx.initCause(reqEx);
+ }
+
+ Throwable faultCause = faultEx.getCause();
+ log.error("SOAP request exception", faultCause != null ? faultCause : faultEx);
+
+ try
+ {
+ SOAPMessage faultMessage = toSOAPMessage(faultEx);
+ return faultMessage;
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.error("Error creating SOAPFault message", ex);
+ throw new JAXRPCException("Cannot create SOAPFault message for: " + faultEx);
+ }
+ }
+
+ private static SOAPMessage toSOAPMessage(SOAPFaultException faultEx) throws SOAPException
+ {
+ assertFaultCode(faultEx.getFaultCode());
+
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ SerializationContext serContext = (msgContext != null ? msgContext.getSerializationContext() : new SerializationContextJAXRPC());
+ NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
+
+ MessageFactory factory = new MessageFactoryImpl();
+ SOAPMessage soapMessage = factory.createMessage();
+
+ SOAPEnvelopeImpl soapEnvelope = (SOAPEnvelopeImpl)soapMessage.getSOAPPart().getEnvelope();
+ SOAPBody soapBody = soapEnvelope.getBody();
+
+ QName faultCode = faultEx.getFaultCode();
+ if (faultCode.getNamespaceURI().length() > 0)
+ faultCode = nsRegistry.registerQName(faultCode);
+
+ String faultString = getValidFaultString(faultEx);
+ SOAPFault soapFault = soapBody.addFault(new NameImpl(faultCode), faultString);
+
+ String faultActor = faultEx.getFaultActor();
+ if (faultActor != null)
+ {
+ SOAPElement soapElement = soapFault.addChildElement("faultactor");
+ soapElement.addTextNode(faultActor);
+ }
+
+ Exception faultCause = (Exception)faultEx.getCause();
+ Detail detail = faultEx.getDetail();
+ if (detail != null)
+ {
+ soapFault.addChildElement(detail);
+ }
+ else if (faultCause != null && (faultCause instanceof RuntimeException) == false)
+ {
+ Class javaType = faultCause.getClass();
+
+ TypeMapping typeMapping = serContext.getTypeMapping();
+
+ OperationMetaData opMetaData = msgContext.getOperationMetaData();
+ if (opMetaData != null && opMetaData.getFault(javaType) != null)
+ {
+ FaultMetaData faultMetaData = opMetaData.getFault(javaType);
+ QName xmlName = faultMetaData.getXmlName();
+ QName xmlType = faultMetaData.getXmlType();
+
+ xmlName = nsRegistry.registerQName(xmlName);
+
+ // Get the serializer from the type mapping
+ SerializerFactoryBase serFactory = (SerializerFactoryBase)typeMapping.getSerializer(javaType, xmlType);
+ if (serFactory == null)
+ throw new JAXRPCException("Cannot obtain serializer factory for: " + xmlType);
+
+ try
+ {
+ SerializerSupport ser = (SerializerSupport)serFactory.getSerializer();
+ String xmlFragment = ser.serialize(xmlName, xmlType, faultCause, serContext, null);
+
+ SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
+ Element domElement = DOMUtils.parse(xmlFragment);
+ SOAPElement soapElement = soapFactory.createElement(domElement, true);
+
+ detail = soapFault.addDetail();
+ detail.addChildElement(soapElement);
+ }
+ catch (BindingException e)
+ {
+ throw new JAXRPCException(e);
+ }
+ catch (IOException e)
+ {
+ throw new JAXRPCException(e);
+ }
+ }
+ else
+ {
+ log.debug("Cannot obtain fault meta data for: " + javaType);
+ }
+ }
+
+ return soapMessage;
+ }
+
+ private static String getValidFaultString(SOAPFaultException faultEx)
+ {
+ String faultString = faultEx.getFaultString();
+ if (faultString == null || faultString.length() == 0)
+ faultString = "Unqualified " + faultEx.getFaultCode() + " fault";
+
+ return faultString;
+ }
+
+ private static void assertFaultCode(QName faultCode)
+ {
+ if (faultCode == null)
+ throw new IllegalArgumentException("faultcode cannot be null");
+
+ // For lazy folkes like the CTS that don't bother to give
+ // a namesapce URI, assume they use a standard code
+ String nsURI = faultCode.getNamespaceURI();
+ if ("".equals(nsURI))
+ {
+ log.warn("Empty namespace URI with fault code '" + faultCode + "', assuming: " + Constants.NS_SOAP11_ENV);
+ faultCode = new QName(Constants.NS_SOAP11_ENV, faultCode.getLocalPart());
+ }
+
+ // WS-I allows non custom faultcodes if you use a non soap namespace
+ if (Constants.NS_SOAP11_ENV.equals(nsURI) && allowedFaultCodes.contains(faultCode) == false)
+ throw new IllegalArgumentException("Illegal faultcode '" + faultCode + "', allowed values are: " + allowedFaultCodes);
+ }
+}
\ No newline at end of file
Modified: trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -53,7 +53,6 @@
import org.jboss.ws.metadata.OperationMetaData;
import org.jboss.ws.metadata.HandlerMetaData.HandlerType;
import org.jboss.ws.soap.MessageContextAssociation;
-import org.jboss.ws.soap.SOAPFaultImpl;
/**
* Provides support for the dynamic invocation of a service endpoint.
@@ -177,7 +176,7 @@
}
/**
- * 4.13 Conformance (Remote Exceptions): If an error occurs during a remote operation invocation, an implemention
+ * 4.2.4 Conformance (Remote Exceptions): If an error occurs during a remote operation invocation, an implemention
* MUST throw a service specific exception if possible. If the error cannot be mapped to a service
* specific exception, an implementation MUST throw a ProtocolException or one of its subclasses, as
* appropriate for the binding in use. See section 6.4.1 for more details.
@@ -187,7 +186,14 @@
String bindingId = opMetaData.getEndpointMetaData().getBindingId();
if (SOAPBinding.SOAP11HTTP_BINDING.equals(bindingId) || SOAPBinding.SOAP12HTTP_BINDING.equals(bindingId))
{
- throw new SOAPFaultException(ex);
+ if (ex instanceof SOAPFaultException)
+ {
+ throw (SOAPFaultException)ex;
+ }
+ else
+ {
+ throw new SOAPFaultException(ex);
+ }
}
else if (HTTPBinding.HTTP_BINDING.equals(bindingId))
{
Modified: trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -35,6 +35,7 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Response;
import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
@@ -183,9 +184,24 @@
return response;
}
+ /**
+ * 4.2.4 Conformance (Remote Exceptions): If an error occurs during a remote operation invocation, an implemention
+ * MUST throw a service specific exception if possible. If the error cannot be mapped to a service
+ * specific exception, an implementation MUST throw a ProtocolException or one of its subclasses, as
+ * appropriate for the binding in use. See section 6.4.1 for more details.
+ */
private void handleException(Exception ex) throws Throwable
{
Throwable th = ex;
+ if (ex instanceof SOAPFaultException)
+ {
+ // The cause of a SOAPFaultException, if any, is the service specific exception
+ Throwable cause = ex.getCause();
+ if (cause != null)
+ {
+ th = cause;
+ }
+ }
throw th;
}
Modified: trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP11BindingJAXWS.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP11BindingJAXWS.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP11BindingJAXWS.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -31,7 +31,6 @@
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
-import javax.xml.ws.soap.SOAPFaultException;
import org.jboss.ws.Constants;
import org.jboss.ws.common.CommonSOAP11Binding;
@@ -92,6 +91,12 @@
@Override
protected void throwFaultException(SOAPFaultImpl fault) throws Exception
{
- throw new SOAPFaultException(fault);
+ throw SOAPFaultHelperJAXWS.getSOAPFaultException(fault);
}
+
+ @Override
+ public SOAPMessage exceptionToFaultMessage(Exception ex)
+ {
+ return SOAPFaultHelperJAXWS.exceptionToFaultMessage(ex);
+ }
}
Modified: trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP12BindingJAXWS.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP12BindingJAXWS.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxws/core/SOAP12BindingJAXWS.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -32,7 +32,6 @@
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
-import javax.xml.ws.soap.SOAPFaultException;
import org.jboss.ws.Constants;
import org.jboss.ws.common.CommonSOAP12Binding;
@@ -100,6 +99,12 @@
@Override
protected void throwFaultException(SOAPFaultImpl fault) throws Exception
{
- throw new SOAPFaultException(fault);
+ throw SOAPFaultHelperJAXWS.getSOAPFaultException(fault);
}
+
+ @Override
+ public SOAPMessage exceptionToFaultMessage(Exception ex)
+ {
+ return SOAPFaultHelperJAXWS.exceptionToFaultMessage(ex);
+ }
}
Added: trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPFaultHelperJAXWS.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPFaultHelperJAXWS.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPFaultHelperJAXWS.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -0,0 +1,503 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as
+ * published by JBoss Inc.; either version 1.0 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+package org.jboss.ws.jaxws.core;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.encoding.TypeMapping;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.binding.BindingException;
+import org.jboss.ws.binding.DeserializerSupport;
+import org.jboss.ws.binding.SerializationContext;
+import org.jboss.ws.binding.SerializerSupport;
+import org.jboss.ws.common.CommonMessageContext;
+import org.jboss.ws.jaxrpc.SOAPFaultHelperJAXRPC;
+import org.jboss.ws.jaxrpc.encoding.DeserializerFactoryBase;
+import org.jboss.ws.jaxrpc.encoding.SerializerFactoryBase;
+import org.jboss.ws.metadata.FaultMetaData;
+import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.soap.MessageContextAssociation;
+import org.jboss.ws.soap.NameImpl;
+import org.jboss.ws.soap.SOAPFactoryImpl;
+import org.jboss.ws.utils.DOMUtils;
+import org.jboss.ws.utils.DOMWriter;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:alex.guizar@jboss.com">Alejandro Guizar</a>
+ * @version $Revision$
+ */
+public class SOAPFaultHelperJAXWS
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(SOAPFaultHelperJAXWS.class);
+
+ private static final Collection<String> excludedGetters = Arrays.asList(new String[] { "getCause", "getLocalizedMessage", "getStackTrace", "getClass" });
+
+ /** Factory method for FaultException for a given SOAPFault */
+ public static SOAPFaultException getSOAPFaultException(SOAPFault soapFault)
+ {
+ SOAPFaultException faultEx = new SOAPFaultException(soapFault);
+ Detail detail = soapFault.getDetail();
+
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ if (detail != null && msgContext != null)
+ {
+ SerializationContext serContext = msgContext.getSerializationContext();
+ TypeMapping typeMapping = serContext.getTypeMapping();
+
+ Iterator it = detail.getDetailEntries();
+ while (it.hasNext())
+ {
+ DetailEntry deElement = (DetailEntry)it.next();
+ QName xmlName = new QName(deElement.getNamespaceURI(), deElement.getLocalName());
+
+ OperationMetaData opMetaData = msgContext.getOperationMetaData();
+ FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
+ if (faultMetaData != null)
+ {
+ log.debug("Deserialize fault: " + faultMetaData);
+ QName xmlType = faultMetaData.getXmlType();
+ Class<?> faultBeanClass = faultMetaData.getFaultBean();
+
+ // Get the deserializer from the type mapping
+ DeserializerFactoryBase desFactory = (DeserializerFactoryBase)typeMapping.getDeserializer(faultBeanClass, xmlType);
+ if (desFactory == null)
+ throw new WebServiceException("Cannot obtain deserializer factory: xmlType=" + xmlType + ", javaType=" + faultBeanClass);
+
+ // http://jira.jboss.org/jira/browse/JBWS-955
+ // Cannot deserialize fault detail
+ String prefix = deElement.getPrefix();
+ if (prefix.length() > 0)
+ {
+ String nsURI = deElement.getNamespaceURI();
+ String attrValue = deElement.getAttribute("xmlns:" + prefix);
+ if (nsURI.length() > 0 && attrValue.length() == 0)
+ {
+ try
+ {
+ deElement.addNamespaceDeclaration(prefix, nsURI);
+ }
+ catch (SOAPException e)
+ {
+ log.warn("Declaration of detail entry namespace failed", e);
+ }
+ }
+ }
+
+ // Try jaxb deserialization
+ try
+ {
+ String xmlFragment = DOMWriter.printNode(deElement, false);
+ DeserializerSupport des = (DeserializerSupport)desFactory.getDeserializer();
+ Object faultBean = des.deserialize(xmlName, xmlType, xmlFragment, serContext);
+
+ /* JAX-WS 2.5: A wsdl:fault element refers to a wsdl:message that contains
+ * a single part. The global element declaration referred to by that part
+ * is mapped to a Java bean. A wrapper exception class contains the
+ * following methods:
+ * - WrapperException(String message, FaultBean faultInfo)
+ * - WrapperException(String message, FaultBean faultInfo, Throwable cause)
+ * - FaultBean getFaultInfo() */
+ Class<?> serviceExGenericClass = faultMetaData.getJavaType();
+ Class<? extends Exception> serviceExClass = serviceExGenericClass.asSubclass(Exception.class);
+
+ Exception serviceEx;
+ try
+ {
+ Constructor<? extends Exception> serviceExCtor = serviceExClass.getConstructor(String.class, faultBeanClass);
+ serviceEx = serviceExCtor.newInstance(soapFault.getFaultString(), faultBean);
+ }
+ catch (NoSuchMethodException e)
+ {
+ serviceEx = toServiceException(faultBean, serviceExClass);
+ }
+ catch (InstantiationException e)
+ {
+ throw new WebServiceException("Service specific exception class is not instantiable", e);
+ }
+
+ faultEx.initCause(serviceEx);
+ }
+ catch (BindingException e)
+ {
+ throw new WebServiceException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new WebServiceException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new WebServiceException(e.getTargetException());
+ }
+ }
+ else
+ {
+ log.debug("Cannot find fault meta data for: " + xmlName);
+ }
+ }
+ }
+
+ return faultEx;
+ }
+
+ private static Exception toServiceException(Object faultBean, Class<? extends Exception> serviceExClass) throws IllegalAccessException, InvocationTargetException
+ {
+ Class<?> faultBeanClass = faultBean.getClass();
+ XmlType xmlType = faultBeanClass.getAnnotation(XmlType.class);
+
+ if (xmlType == null)
+ throw new WebServiceException("@XmlType annotation missing from fault bean class: " + faultBeanClass.getName());
+
+ String[] propertyNames = xmlType.propOrder();
+ Class<?>[] propertyTypes = new Class<?>[propertyNames.length];
+ Object[] propertyValues = new Object[propertyNames.length];
+
+ for (int i = 0; i < propertyNames.length; i++)
+ {
+ String propertyName = propertyNames[i];
+ propertyName = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
+
+ Method propertyGetter;
+ try
+ {
+ propertyGetter = faultBeanClass.getMethod("get" + propertyName);
+ }
+ catch (NoSuchMethodException e)
+ {
+ try
+ {
+ propertyGetter = faultBeanClass.getMethod("is" + propertyName);
+ }
+ catch (NoSuchMethodException ee)
+ {
+ throw new WebServiceException("Fault bean has no getter for property: " + propertyName, ee);
+ }
+ }
+ propertyValues[i] = propertyGetter.invoke(faultBean);
+ propertyTypes[i] = propertyGetter.getReturnType();
+ }
+
+ try
+ {
+ Constructor<? extends Exception> serviceExCtor = serviceExClass.getConstructor(propertyTypes);
+ return serviceExCtor.newInstance(propertyValues);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new WebServiceException("Service exception has no constructor for parameter types: " + Arrays.toString(propertyTypes));
+ }
+ catch (InstantiationException e)
+ {
+ throw new WebServiceException("Service exception is not instantiable", e);
+ }
+ }
+
+ /** Translate the request exception into a SOAPFault message. */
+ public static SOAPMessage exceptionToFaultMessage(Exception reqEx)
+ {
+ log.error("SOAP request exception", reqEx);
+
+ try
+ {
+ SOAPMessage faultMessage;
+ if (reqEx instanceof SOAPFaultException)
+ {
+ faultMessage = toSOAPMessage((SOAPFaultException)reqEx);
+ }
+ else if (reqEx instanceof javax.xml.rpc.soap.SOAPFaultException)
+ {
+ /* this exception should not occur in JAX-WS endpoints, but JBossWS
+ * throws it to signal internal error conditions */
+ faultMessage = SOAPFaultHelperJAXRPC.exceptionToFaultMessage(reqEx);
+ }
+ else
+ {
+ faultMessage = toSOAPMessage(reqEx);
+ }
+
+ return faultMessage;
+ }
+ catch (SOAPException ex)
+ {
+ log.error("Error creating SOAPFault message", ex);
+ throw new WebServiceException("Cannot create SOAPFault message for: " + reqEx);
+ }
+ }
+
+ private static SOAPMessage toSOAPMessage(SOAPFaultException faultEx) throws SOAPException
+ {
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = factory.createMessage();
+
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+ populateSOAPFault(soapBody, faultEx);
+
+ /* detail
+ * X. Serialized service specific exception
+ * 2. SOAPFaultException.getFault().getDetail() */
+ Detail detail = faultEx.getFault().getDetail();
+ if (detail != null)
+ soapBody.getFault().addChildElement(detail);
+
+ return soapMessage;
+ }
+
+ private static void populateSOAPFault(SOAPBody soapBody, SOAPFaultException faultEx) throws SOAPException
+ {
+ SOAPFault sourceFault = faultEx.getFault();
+
+ /* JAX-WS 10.2.2.3: the fields of the fault message are populated according to the
+ * following rules of precedence: */
+
+ /* faultcode
+ * 1. SOAPFaultException.getFault().getFaultCodeAsQName()
+ * X. env:Server (Subcode omitted for SOAP 1.2) */
+ Name faultCode = sourceFault.getFaultCodeAsName();
+ if (faultCode != null)
+ {
+ faultCode = new NameImpl(faultCode.getLocalName(), "codeNS", faultCode.getURI());
+ }
+ else
+ {
+ faultCode = getFallbackFaultCode();
+ }
+
+ /* faultstring
+ * 1. SOAPFaultException.getFault().getFaultString()
+ * X. Exception.getMessage()
+ * X. Exception.toString() */
+ String faultString = sourceFault.getFaultString();
+ if (faultString == null)
+ faultString = getFallbackFaultString(faultEx);
+
+ SOAPFault targetFault = soapBody.addFault(faultCode, faultString);
+
+ /* faultactor
+ * 1. SOAPFaultException.getFault().getFaultActor()
+ * 2. Empty */
+ String faultActor = sourceFault.getFaultActor();
+ if (faultActor != null)
+ targetFault.setFaultActor(faultActor);
+ }
+
+ private static SOAPMessage toSOAPMessage(Exception ex) throws SOAPException
+ {
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = factory.createMessage();
+
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+ SOAPFault soapFault;
+
+ /* JAX-WS 6.4.1: When an implementation catches an exception thrown by a
+ * service endpoint implementation and the cause of that exception is an
+ * instance of the appropriate ProtocolException subclass for the protocol
+ * in use, an implementation MUST reflect the information contained in the
+ * ProtocolException subclass within the generated protocol level fault. */
+ Throwable cause = ex.getCause();
+ if (cause instanceof SOAPFaultException)
+ {
+ populateSOAPFault(soapBody, (SOAPFaultException)cause);
+ soapFault = soapBody.getFault();
+ }
+ else
+ {
+ soapFault = soapBody.addFault(getFallbackFaultCode(), getFallbackFaultString(ex));
+ }
+
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ SerializationContext serContext = msgContext.getSerializationContext();
+
+ NameImpl faultCode = (NameImpl)soapFault.getFaultCodeAsName();
+ if (faultCode.getURI().length() > 0)
+ serContext.getNamespaceRegistry().registerQName(faultCode.toQName());
+
+ OperationMetaData opMetaData = msgContext.getOperationMetaData();
+ Class<? extends Exception> exClass = ex.getClass();
+ if (opMetaData != null && opMetaData.getFault(exClass) != null)
+ {
+ FaultMetaData faultMetaData = opMetaData.getFault(exClass);
+ Class faultBeanClass = faultMetaData.getFaultBean();
+ Object faultBean;
+ try
+ {
+ try
+ {
+ /* JAX-WS 3.7: For exceptions that match the pattern described in section
+ * 2.5 (i.e. exceptions that have a getFaultInfo method), the FaultBean
+ * is used as input to JAXB */
+ Method getFaultInfo = exClass.getMethod("getFaultInfo");
+ faultBean = getFaultInfo.invoke(ex);
+ }
+ catch (NoSuchMethodException e)
+ {
+ /* JAX-WS 3.7: For exceptions that do not match the pattern described in
+ * section 2.5, JAX-WS maps those exceptions to Java beans and then uses
+ * those Java beans as input to the JAXB mapping. */
+ faultBean = toFaultBean(ex, faultBeanClass);
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new WebServiceException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new WebServiceException(e.getTargetException());
+ }
+
+ Detail detail = soapFault.addDetail();
+ SOAPElement detailEntry = toDetailEntry(faultBean, serContext, faultMetaData);
+ detail.addChildElement(detailEntry);
+ }
+ else
+ {
+ log.debug("Cannot obtain fault meta data for: " + exClass);
+ }
+
+ return soapMessage;
+ }
+
+ private static Name getFallbackFaultCode()
+ {
+ /* faultcode
+ * X. SOAPFaultException.getFault().getFaultCodeAsQName()
+ * 2. env:Server (Subcode omitted for SOAP 1.2) */
+ return new NameImpl(Constants.SOAP11_FAULT_CODE_SERVER);
+ }
+
+ private static String getFallbackFaultString(Exception ex)
+ {
+ /* faultstring
+ * X. SOAPFaultException.getFault().getFaultString()
+ * 2. Exception.getMessage()
+ * 3. Exception.toString() */
+ String faultString = ex.getMessage();
+
+ if (faultString == null)
+ faultString = ex.toString();
+
+ return faultString;
+ }
+
+ private static Object toFaultBean(Exception userEx, Class faultBeanClass) throws IllegalAccessException, InvocationTargetException
+ {
+ Object faultBean;
+ try
+ {
+ faultBean = faultBeanClass.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new WebServiceException("Fault bean class is not instantiable", e);
+ }
+
+ /* For each getter in the exception and its superclasses, a property of
+ * the same type and name is added to the bean. The getCause, getLocalizedMessage
+ * and getStackTrace getters from java.lang.Throwable and the getClass getter
+ * from java.lang.Object are excluded from the list of getters to be mapped. */
+ for (Method exMethod : userEx.getClass().getMethods())
+ {
+ if (exMethod.getParameterTypes().length > 0)
+ continue;
+
+ String exMethodName = exMethod.getName();
+
+ if (excludedGetters.contains(exMethodName))
+ continue;
+
+ String propertyName;
+ if (exMethodName.startsWith("get"))
+ {
+ propertyName = exMethodName.substring(3);
+ }
+ else if (exMethodName.startsWith("is"))
+ {
+ propertyName = exMethodName.substring(2);
+ }
+ else continue;
+
+ // get the property value from the exception
+ Object propertyValue = exMethod.invoke(userEx);
+ Class propertyClass = exMethod.getReturnType();
+
+ try
+ {
+ // set the value to the bean
+ Method beanSetter = faultBeanClass.getMethod("set" + propertyName, propertyClass);
+ beanSetter.invoke(faultBean, propertyValue);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new WebServiceException("Fault bean has no setter for property: " + propertyName, e);
+ }
+ }
+
+ return faultBean;
+ }
+
+ private static SOAPElement toDetailEntry(Object faultObject, SerializationContext serContext, FaultMetaData faultMetaData) throws SOAPException
+ {
+ QName xmlName = faultMetaData.getXmlName();
+ xmlName = serContext.getNamespaceRegistry().registerQName(xmlName);
+
+ // Get the serializer from the type mapping
+ QName xmlType = faultMetaData.getXmlType();
+ Class javaType = faultMetaData.getFaultBean() != null ? faultMetaData.getFaultBean() : faultMetaData.getJavaType();
+ SerializerFactoryBase serFactory = (SerializerFactoryBase)serContext.getTypeMapping().getSerializer(javaType, xmlType);
+ if (serFactory == null)
+ throw new WebServiceException("Cannot obtain serializer factory: xmlType=" + xmlType + ", javaType=" + javaType);
+
+ try
+ {
+ SerializerSupport ser = serFactory.getSerializer();
+ String xmlFragment = ser.serialize(xmlName, xmlType, faultObject, serContext, null);
+
+ SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
+ Element domElement = DOMUtils.parse(xmlFragment);
+ return soapFactory.createElement(domElement, true);
+ }
+ catch (BindingException e)
+ {
+ throw new WebServiceException(e);
+ }
+ catch (IOException e)
+ {
+ throw new WebServiceException(e);
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/jboss/ws/jaxws/core/SOAPFaultHelperJAXWS.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/metadata/FaultMetaData.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.ws.metadata;
// $Id$
@@ -26,7 +26,6 @@
import javax.xml.namespace.QName;
import org.jboss.ws.WSException;
-import org.jboss.ws.jaxrpc.ParameterWrapping;
import org.jboss.ws.jaxws.DynamicWrapperGenerator;
import org.jboss.ws.utils.JavaUtils;
@@ -97,12 +96,12 @@
public Class getJavaType()
{
- ClassLoader loader = getClassLoader();
-
if (javaTypeName == null)
return null;
- if (javaType == null || ((!javaType.isPrimitive()) && javaType.getClassLoader() != loader))
+ ClassLoader loader = getClassLoader();
+
+ if (javaType == null || (!javaType.isPrimitive() && javaType.getClassLoader() != loader))
{
try
{
@@ -119,15 +118,20 @@
public Class getFaultBean()
{
- if (faultBean == null && faultBeanName != null)
+ if (faultBeanName == null)
+ return null;
+
+ ClassLoader loader = getClassLoader();
+
+ if (faultBean == null || (!faultBean.isPrimitive() && faultBean.getClassLoader() != loader))
{
try
{
- faultBean = JavaUtils.loadJavaType(faultBeanName, getClassLoader());
+ faultBean = JavaUtils.loadJavaType(faultBeanName, loader);
}
catch (ClassNotFoundException ex)
{
- throw new WSException("Cannot load java type: " + javaTypeName, ex);
+ throw new WSException("Cannot load fault bean: " + faultBeanName, ex);
}
}
@@ -167,7 +171,7 @@
buffer.append("\n xmlName=" + xmlName);
buffer.append("\n xmlType=" + xmlType);
buffer.append("\n javaType=" + javaTypeName);
- buffer.append("\n faultbean=" + faultBeanName);
+ buffer.append("\n faultBean=" + faultBeanName);
return buffer.toString();
}
}
\ No newline at end of file
Modified: trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -25,6 +25,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
import javax.management.MBeanException;
import javax.xml.namespace.QName;
@@ -45,7 +46,7 @@
import org.jboss.ws.common.CommonBinding;
import org.jboss.ws.common.CommonBindingProvider;
import org.jboss.ws.common.CommonMessageContext;
-import org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper;
+import org.jboss.ws.common.CommonSOAPBinding;
import org.jboss.ws.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.jaxws.core.BindingProviderImpl;
import org.jboss.ws.jaxws.handler.HandlerDelegateJAXWS;
@@ -97,7 +98,7 @@
InstantiationException;
/** Invoke the instance of the SEI implementation bean */
- protected abstract void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv);
+ protected abstract void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv) throws Exception;
/** Destroy the instance of the SEI implementation bean if necessary */
protected abstract void destroyServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl);
@@ -139,7 +140,7 @@
// call the handler chain
boolean handlersPass = callRequestHandlerChain(seInfo, HandlerType.PRE);
-
+
// Unbind the request message
if (handlersPass)
{
@@ -154,7 +155,7 @@
// Unbind the request message
epInv = binding.unbindRequestMessage(opMetaData, reqMessage);
}
-
+
handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.ENDPOINT);
handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.POST);
@@ -164,7 +165,7 @@
log.debug("Handler modified body payload, unbind message again");
epInv = binding.unbindRequestMessage(opMetaData, reqMessage);
}
-
+
if (handlersPass)
{
// Invoke the service endpoint
@@ -202,7 +203,8 @@
{
try
{
- SOAPMessage faultMessage = SOAPFaultExceptionHelper.exceptionToFaultMessage(ex);
+ CommonSOAPBinding soapBinding = (CommonSOAPBinding)bindingProvider.getCommonBinding();
+ SOAPMessage faultMessage = soapBinding.exceptionToFaultMessage(ex);
msgContext.setSOAPMessage(faultMessage);
// call the handler chain
@@ -278,48 +280,37 @@
return implMethod;
}
- /** handle invokation exceptions */
- public void handleInvocationException(Throwable th) throws SOAPFaultException
+ /** handle invocation exceptions */
+ public void handleInvocationException(Throwable th) throws Exception
{
- if (th instanceof RuntimeException)
- throw (RuntimeException)th;
-
if (th instanceof InvocationTargetException)
{
- InvocationTargetException targetException = (InvocationTargetException)th;
- Throwable targetEx = targetException.getTargetException();
- if (targetEx instanceof SOAPFaultException)
- {
- throw (SOAPFaultException)targetEx;
- }
- else
- {
- String faultString = targetEx.toString();
- SOAPFaultException soapFaultEx = new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, faultString, null, null);
- soapFaultEx.initCause(targetEx);
- throw soapFaultEx;
- }
+ // unwrap the throwable raised by the service endpoint implementation
+ Throwable targetEx = ((InvocationTargetException)th).getTargetException();
+ handleInvocationThrowable(targetEx);
}
if (th instanceof MBeanException)
{
- Exception targetEx = ((MBeanException)th).getTargetException();
- if (targetEx instanceof SOAPFaultException)
- {
- throw (SOAPFaultException)targetEx;
- }
- else
- {
- String faultString = targetEx.toString();
- SOAPFaultException soapFaultEx = new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, faultString, null, null);
- soapFaultEx.initCause(targetEx);
- throw soapFaultEx;
- }
+ throw ((MBeanException)th).getTargetException();
}
- String faultString = th.toString();
- SOAPFaultException soapFaultEx = new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, faultString, null, null);
- soapFaultEx.initCause(th);
- throw soapFaultEx;
+ handleInvocationThrowable(th);
}
+
+ private void handleInvocationThrowable(Throwable th) throws Exception
+ {
+ if (th instanceof Exception)
+ {
+ throw (Exception)th;
+ }
+ else if (th instanceof Error)
+ {
+ throw (Error)th;
+ }
+ else
+ {
+ throw new UndeclaredThrowableException(th);
+ }
+ }
}
Modified: trunk/src/main/java/org/jboss/ws/server/ServiceEndpoint.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/ServiceEndpoint.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/server/ServiceEndpoint.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -37,11 +37,11 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
-import org.jboss.ws.utils.DOMWriter;
import org.jboss.ws.Constants;
import org.jboss.ws.binding.BindingException;
+import org.jboss.ws.common.CommonBindingProvider;
import org.jboss.ws.common.CommonMessageContext;
-import org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper;
+import org.jboss.ws.common.CommonSOAPBinding;
import org.jboss.ws.metadata.EndpointMetaData;
import org.jboss.ws.metadata.ServerEndpointMetaData;
import org.jboss.ws.metadata.UnifiedMetaData;
@@ -50,6 +50,7 @@
import org.jboss.ws.soap.SOAPElementImpl;
import org.jboss.ws.soap.SOAPElementWriter;
import org.jboss.ws.soap.SOAPMessageImpl;
+import org.jboss.ws.utils.DOMWriter;
import org.w3c.dom.Document;
/**
@@ -201,7 +202,10 @@
// we create the fault message here.
if (resMessage == null || ((SOAPMessageImpl)resMessage).isFaultMessage() == false)
{
- resMessage = SOAPFaultExceptionHelper.exceptionToFaultMessage(ex);
+ CommonBindingProvider bindingProvider = getCommonBindingProvider();
+ CommonSOAPBinding soapBinding = (CommonSOAPBinding)bindingProvider.getCommonBinding();
+
+ resMessage = soapBinding.exceptionToFaultMessage(ex);
msgContext.setSOAPMessage(resMessage);
}
@@ -267,6 +271,11 @@
}
}
+ private CommonBindingProvider getCommonBindingProvider()
+ {
+ return new CommonBindingProvider(seInfo.getServerEndpointMetaData());
+ }
+
/**
* Returns a string representation of the object.
*/
Modified: trunk/src/main/java/org/jboss/ws/server/ServiceEndpointInvokerJSE.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/ServiceEndpointInvokerJSE.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/main/java/org/jboss/ws/server/ServiceEndpointInvokerJSE.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -81,7 +81,7 @@
}
/** Invoke an instance of the SEI implementation bean */
- public void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv) throws SOAPFaultException
+ public void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv) throws SOAPFaultException, Exception
{
log.debug("invokeServiceEndpoint: " + epInv.getJavaMethod().getName());
try
Modified: trunk/src/test/build.xml
===================================================================
--- trunk/src/test/build.xml 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/build.xml 2006-11-17 07:56:40 UTC (rev 1455)
@@ -189,10 +189,10 @@
<pathelement location="${thirdparty.dir}/stax-api-1.0.jar"/>
</path>
- <!-- Check that jBPM BPEL has been deployed -->
+ <!-- Deploy jBPM BPEL (no action if deployed already) -->
<property name="jboss.server.deploy.jbpmbpel" value="${jboss.server.deploy}/jbpm-bpel.sar" />
- <available property="jbpmbpel.available" file="${jboss.server.deploy.jbpmbpel}" />
- <antcall target="deploy-jbpmbpel" />
+ <mkdir dir="${jboss.server.deploy.jbpmbpel}" />
+ <unjar dest="${jboss.server.deploy.jbpmbpel}" src="${thirdparty.dir}/jbpm-bpel.sar" overwrite="no"/>
<!-- The jBPM BPEL classpath -->
<path id="jbpmbpel.classpath">
@@ -210,11 +210,6 @@
<path location="${test.etc.dir}" />
</path>
</target>
-
- <target name="deploy-jbpmbpel" unless="jbpmbpel.available">
- <mkdir dir="${jboss.server.deploy.jbpmbpel}" />
- <unjar dest="${jboss.server.deploy.jbpmbpel}" src="${thirdparty.dir}/jbpm-bpel.sar" />
- </target>
<!-- ================================================================== -->
<!-- Compiling -->
Modified: trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPFaultTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPFaultTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPFaultTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -37,7 +37,7 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.Constants;
-import org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper;
+import org.jboss.ws.jaxrpc.SOAPFaultHelperJAXRPC;
import org.jboss.ws.utils.DOMUtils;
/**
@@ -57,7 +57,7 @@
{
Detail detail = createDetailElement();
SOAPFaultException faultEx = new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, "Some fault message", "Some fault actor", detail);
- SOAPEnvelope soapEnv = SOAPFaultExceptionHelper.exceptionToFaultMessage(faultEx).getSOAPPart().getEnvelope();
+ SOAPEnvelope soapEnv = SOAPFaultHelperJAXRPC.exceptionToFaultMessage(faultEx).getSOAPPart().getEnvelope();
assertEquals(DOMUtils.parse(envStr), soapEnv);
}
@@ -72,7 +72,7 @@
assertEquals("Some fault actor", soapFault.getFaultActor());
assertEquals(createDetailElement(), soapFault.getDetail());
- SOAPFaultException faultEx = SOAPFaultExceptionHelper.getSOAPFaultException((SOAPFault)soapFault);
+ SOAPFaultException faultEx = SOAPFaultHelperJAXRPC.getSOAPFaultException((SOAPFault)soapFault);
assertEquals(Constants.SOAP11_FAULT_CODE_CLIENT, faultEx.getFaultCode());
assertEquals("Some fault message", faultEx.getFaultString());
Modified: trunk/src/test/java/org/jboss/test/ws/jaxrpc/encoded/marshalltest/MarshallTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxrpc/encoded/marshalltest/MarshallTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxrpc/encoded/marshalltest/MarshallTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -279,7 +279,7 @@
public void testJavaBeanTest() throws Exception
{
JavaBean inObj = new JavaBean();
-
+
inObj.setMyBigDecimal(new BigDecimal("100"));
inObj.setMyBigDecimalArray(new BigDecimal[] { new BigDecimal("100"), new BigDecimal("200"), new BigDecimal("300") });
inObj.setMyBigInteger(new BigInteger("100"));
@@ -321,8 +321,9 @@
inObj.setMyStringArray(new String[] { "String1", "String2" });
System.out.println("FIXME: [JBWS-485] SOAP encoded arrays as bean properties");
- if (true) return;
-
+ if (true)
+ return;
+
JavaBean retObj = port.javaBeanTest(inObj);
assertEquals(inObj, retObj);
}
@@ -352,9 +353,6 @@
public void testMyServiceExceptionTest() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
try
{
port.myServiceExceptionTest();
@@ -431,7 +429,7 @@
public void testValueTypeTest() throws Exception
{
ValueType inObj = new ValueType();
-
+
inObj.setMyBigDecimal(new BigDecimal("100"));
inObj.setMyBigDecimalArray(new BigDecimal[] { new BigDecimal("100"), new BigDecimal("200"), new BigDecimal("300") });
inObj.setMyBigInteger(new BigInteger("100"));
@@ -473,8 +471,9 @@
inObj.setMyStringArray(new String[] { "String1", "String2" });
System.out.println("FIXME: [JBWS-485] SOAP encoded arrays as bean properties");
- if (true) return;
-
+ if (true)
+ return;
+
ValueType retObj = port.valueTypeTest(inObj);
assertEquals(inObj, retObj);
}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxrpc/jbws807/JBWS807TestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxrpc/jbws807/JBWS807TestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxrpc/jbws807/JBWS807TestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -63,14 +63,10 @@
public void testPingMsg() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
try
{
port.ping(new PingMsg("Hello World"));
fail("JBWS807 endpoint is supposed to fault");
-
}
catch (RemoteException e)
{
Modified: trunk/src/test/java/org/jboss/test/ws/jaxrpc/samples/exception/ExceptionTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxrpc/samples/exception/ExceptionTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxrpc/samples/exception/ExceptionTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -110,9 +110,6 @@
/** Test simple exception propagation */
public void testException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
ExceptionServiceInterface port = getPort();
try
{
@@ -132,9 +129,6 @@
/** Test exception with message */
public void testExceptionWithMessage() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
ExceptionServiceInterface port = getPort();
String message = "Don't worry it's just a test";
@@ -156,9 +150,6 @@
/** Test a complex user exception */
public void testComplexUserException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
ExceptionServiceInterface port = getPort();
String message = "Don't worry it's just a test";
@@ -181,9 +172,6 @@
/** Test a complex user exception that contains an array */
public void testComplexUserArrayException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
ExceptionServiceInterface port = getPort();
String message = "Don't worry it's just a test";
@@ -207,9 +195,6 @@
/** Test a fault message for a non existant operation */
public void testNonExistantOperation() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
String reqEnv = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + " <env:Header/>" + " <env:Body>"
+ " <ns1:nonExistantOperation xmlns:ns1='http://org.jboss.webservice/exception'/>" + " </env:Body>" + "</env:Envelope>";
@@ -230,9 +215,6 @@
/** Test a fault message for a non existant operation */
public void testNonExistantOperationDII() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(TARGET_NAMESPACE, "ExceptionService"));
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/exception/ExceptionTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/exception/ExceptionTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/exception/ExceptionTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -80,66 +80,48 @@
*/
public void testRuntimeException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true) return;
-
try
{
proxy.throwRuntimeException();
+ fail("Expected SOAPFaultException");
}
catch (SOAPFaultException e)
{
assertEquals("oh no, a runtime exception occured.", e.getMessage());
assertEquals("oh no, a runtime exception occured.", e.getFault().getFaultString());
- return;
}
-
- assertTrue("Expected SOAPFaultException", false);
}
public void testSoapFaultException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true)
- return;
-
try
{
proxy.throwSoapFaultException();
+ fail("Expected SOAPFaultException");
}
catch (SOAPFaultException e)
{
- assertEquals("this is a fault string", e.getMessage());
- assertEquals("this is a fault string", e.getFault().getFaultString());
+ assertEquals("this is a fault string!", e.getMessage());
+ assertEquals("this is a fault string!", e.getFault().getFaultString());
assertEquals("mr.actor", e.getFault().getFaultActor());
assertEquals("FooCode", e.getFault().getFaultCodeAsName().getLocalName());
assertEquals("http://foo", e.getFault().getFaultCodeAsName().getURI());
assertEquals("test", ((Element)e.getFault().getDetail().getChildElements().next()).getLocalName());
-
- return;
}
-
- assertTrue("Expected SOAPFaultException", false);
}
public void testApplicationException() throws Exception
{
- System.out.println("FIXME: [JBWS-1297] Implement JAXB Fault Marshalling");
- if (true)
- return;
-
try
{
proxy.throwApplicationException();
+ fail("Expected UserException");
}
catch (UserException e)
{
assertEquals("Some validation error", e.getMessage());
assertEquals("validation", e.getErrorCategory());
assertEquals(123, e.getErrorCode());
- return;
}
-
- assertTrue("Expected UserException", false);
}
}
\ No newline at end of file
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webmethod/JSR181WebMethodTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webmethod/JSR181WebMethodTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/webmethod/JSR181WebMethodTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -41,7 +41,6 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.soap.NameImpl;
import org.jboss.ws.utils.DOMUtils;
import org.w3c.dom.Element;
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ObjectFactory.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ObjectFactory.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ObjectFactory.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -8,7 +8,9 @@
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
+import org.jboss.test.ws.jaxws.samples.retail.Customer;
+
/**
* This object contains factory methods for each
* Java content interface and Java element interface
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/replyto/AddressingReplyToTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/replyto/AddressingReplyToTestCase.java 2006-11-17 02:06:33 UTC (rev 1454)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/replyto/AddressingReplyToTestCase.java 2006-11-17 07:56:40 UTC (rev 1455)
@@ -35,7 +35,6 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.test.ws.jaxws.logicalhandler.SOAPEndpointJAXB;
/**
* Test endpoint using ws-addressing
@@ -142,6 +141,16 @@
public void testFaultTo() throws Exception
{
String lastFault = faultto.getLastFault();
- assertEquals("java.lang.IllegalArgumentException: Invalid Value", lastFault);
+
+ /* JAX-WS 10.2.2.3: the fields of the fault message are populated according to
+ * the following rules of precedence:
+ *
+ * faultstring
+ * 1. SOAPFaultException.getFault().getFaultString()
+ * 2. Exception.getMessage()
+ * 3. Exception.toString()
+ *
+ * this test used to expect the value returned by toString() */
+ assertEquals("Invalid Value", lastFault);
}
}
18 years, 1 month
JBossWS SVN: r1454 - trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/handlerchain
by jbossws-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2006-11-16 21:06:33 -0500 (Thu, 16 Nov 2006)
New Revision: 1454
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/handlerchain/EndpointImpl.java
Log:
Fix test case
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/handlerchain/EndpointImpl.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/handlerchain/EndpointImpl.java 2006-11-16 22:51:43 UTC (rev 1453)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/jsr181/handlerchain/EndpointImpl.java 2006-11-17 02:06:33 UTC (rev 1454)
@@ -37,7 +37,7 @@
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "jaxws-handlers.xml") // relative path from the class file
-public class EndpointImpl implements Endpoint
+public class EndpointImpl
{
// Provide logging
private static Logger log = Logger.getLogger(EndpointImpl.class);
18 years, 1 month
JBossWS SVN: r1453 - branches/dlofthouse
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2006-11-16 17:51:43 -0500 (Thu, 16 Nov 2006)
New Revision: 1453
Removed:
branches/dlofthouse/JBWS-1079/
Log:
Branch no longer required.
18 years, 1 month
JBossWS SVN: r1452 - in branches/jbossws-1.0/src: main/java/org/jboss/ws/tools main/java/org/jboss/ws/tools/helpers main/java/org/jboss/ws/tools/mapping test/java/org/jboss/test/ws/tools test/java/org/jboss/test/ws/tools/jbws1079 test/resources/tools test/resources/tools/jbws1079
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2006-11-16 17:50:57 -0500 (Thu, 16 Nov 2006)
New Revision: 1452
Added:
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/
branches/jbossws-1.0/src/test/resources/tools/jbws1079/Anonymous.wsdl
branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumber.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/anonymous-mapping.xml
branches/jbossws-1.0/src/test/resources/tools/jbws1079/wstools-config.xml
Removed:
branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/Anonymous.wsdl
branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumber.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java
branches/jbossws-1.0/src/test/resources/tools/jbws1079/anonymous-mapping.xml
branches/jbossws-1.0/src/test/resources/tools/jbws1079/wstools-config.xml
Modified:
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/mapping/MappingFileGenerator.java
Log:
JBWS-1079 - Bring name of class in jax-rpc mapping in synch with the name of the generated class.
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2006-11-16 13:13:31 UTC (rev 1451)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -53,7 +53,6 @@
import org.jboss.ws.metadata.wsdl.WSDLUtils;
import org.jboss.ws.metadata.wsdl.xsd.SchemaUtils;
import org.jboss.ws.utils.JavaUtils;
-import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
/** Class that converts a XSD Type into Java class
* @author <mailto:Anil.Saldhana@jboss.org>Anil Saldhana
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2006-11-16 13:13:31 UTC (rev 1451)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -22,9 +22,7 @@
package org.jboss.ws.tools.helpers;
import java.beans.Introspector;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -91,9 +89,7 @@
private WSDLDefinitions wsdlDefinitions = null;
private String serviceName = null;
private String packageName = null;
- private Class serviceEndpointInterface = null;
- private String typeNamespace = null;
-
+
private Set<String> registeredTypes = new HashSet<String>();
private LiteralTypeMapping typeMapping = null;
@@ -103,18 +99,11 @@
private String parameterStyle;
- /**
- * A list of types that need java-xml type generation
- */
- private List<XSTypeDefinition> queueTypes = new ArrayList<XSTypeDefinition>();
-
public MappingFileGeneratorHelper(WSDLDefinitions wsdl, String sname, String pname, Class seiClass, String tns, LiteralTypeMapping ltm, String paramStyle)
{
this.wsdlDefinitions = wsdl;
this.serviceName = sname;
- this.packageName = pname;
- this.serviceEndpointInterface = seiClass;
- this.typeNamespace = tns;
+ this.packageName = pname;
this.typeMapping = ltm;
this.wsdlStyle = utils.getWSDLStyle(wsdl);
@@ -333,7 +322,7 @@
{
WSDLInterfaceOperationInput input = inputs[k];
XSTypeDefinition xt = getXSType(input);
- addJavaXMLTypeMap(xt, input.getElement().getLocalPart(), jwm, !isDocStyle());
+ addJavaXMLTypeMap(xt, input.getElement().getLocalPart(), "", jwm, !isDocStyle());
}
WSDLInterfaceOperationOutput[] outputs = op.getOutputs();
@@ -342,7 +331,7 @@
{
WSDLInterfaceOperationOutput output = outputs[k];
XSTypeDefinition xt = getXSType(output);
- addJavaXMLTypeMap(xt, output.getElement().getLocalPart(), jwm, !isDocStyle());
+ addJavaXMLTypeMap(xt, output.getElement().getLocalPart(), "", jwm, !isDocStyle());
}
for (WSDLInterfaceFault fault : wi.getFaults())
@@ -353,7 +342,7 @@
WSDLTypes types = wsdlDefinitions.getWsdlTypes();
JBossXSModel xsmodel = WSDLUtils.getSchemaModel(types);
XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
- addJavaXMLTypeMap(xt, xmlName.getLocalPart(), jwm, true);
+ addJavaXMLTypeMap(xt, xmlName.getLocalPart(), "", jwm, true);
ExceptionMapping exceptionMapping = new ExceptionMapping(jwm);
exceptionMapping.setExceptionType(getJavaTypeAsString(null, xmlType, false, true));
@@ -484,7 +473,7 @@
return xsmodel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
}
- private void addJavaXMLTypeMap(XSTypeDefinition xt, String containingElement, JavaWsdlMapping jwm, boolean skipWrapperArray)
+ private void addJavaXMLTypeMap(XSTypeDefinition xt,String name, String containingElement, JavaWsdlMapping jwm, boolean skipWrapperArray)
{
JavaXmlTypeMapping jxtm = null;
@@ -513,8 +502,8 @@
// Anonymous
if (localName == null)
{
- javaType = getJavaTypeAsString(null, new QName(containingElement), false, true);
- localName = ">" + containingElement;
+ javaType = getJavaTypeAsString(null, new QName(containingElement + name), false, true);
+ localName = ">" + name;
jxtm.setAnonymousTypeQName(new QName(xt.getNamespace(), localName, "typeNS"));
}
else
@@ -542,7 +531,7 @@
XSSimpleTypeDefinition simple = xc.getSimpleType();
if (simple != null)
{
- addJavaXMLTypeMap(simple, xc.getName(), jwm, skipWrapperArray);
+ addJavaXMLTypeMap(simple, xc.getName(), "", jwm, skipWrapperArray);
}
// Add attributes
@@ -587,7 +576,7 @@
XSAttributeUse obj = (XSAttributeUse)attributes.item(i);
XSAttributeDeclaration att = obj.getAttrDeclaration();
XSSimpleTypeDefinition simple = att.getTypeDefinition();
- addJavaXMLTypeMap(simple, "none", jxtm.getJavaWsdlMapping(), true);
+ addJavaXMLTypeMap(simple, "none", "", jxtm.getJavaWsdlMapping(), true);
VariableMapping vm = new VariableMapping(jxtm);
String name = att.getName();
vm.setXmlAttributeName(name);
@@ -612,7 +601,7 @@
{
XSElementDeclaration xe = (XSElementDeclaration)xsterm;
XSTypeDefinition typeDefinition = xe.getTypeDefinition();
- addJavaXMLTypeMap(typeDefinition, xe.getName(), jwm, true);
+ addJavaXMLTypeMap(typeDefinition, xe.getName(), xe.getEnclosingCTDefinition().getName(), jwm, true);
}
}
}
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2006-11-16 13:13:31 UTC (rev 1451)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -311,8 +311,7 @@
MappingFileGenerator mgf = new MappingFileGenerator(wsdl, new LiteralTypeMapping());
mgf.setPackageName(getPackageName(wsdl, glc));
mgf.setServiceName(wsdl.getServices()[0].getName().toString());
- mgf.setParameterStyle(w2jc.parameterStyle);
- //mgf.generate();
+ mgf.setParameterStyle(w2jc.parameterStyle);
JavaWsdlMapping jwm = mgf.generate();
Writer writer = IOUtils.getCharsetFileWriter(new File(outDir + "/" + w2jc.mappingFileName), Constants.DEFAULT_XML_CHARSET);
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/mapping/MappingFileGenerator.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/mapping/MappingFileGenerator.java 2006-11-16 13:13:31 UTC (rev 1451)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/mapping/MappingFileGenerator.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -219,9 +219,7 @@
MethodParamPartsMapping[] mppmarr = mm.getMethodParamPartsMappings();
int lenmppmarr = mppmarr != null ? mppmarr.length : 0;
for (int j = 0; j < lenmppmarr; j++)
- {
- MethodParamPartsMapping mppm = mppmarr[j];
- String paramType = mppm.getParamType();
+ {
listInputs.addAll(xst.getVARList((XSComplexTypeDefinition)xsmodel.getTypeDefinition(opname, typeNamespace), xsmodel, false));
}
JavaWriter jw = new JavaWriter();
Copied: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079 (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/java/org/jboss/test/ws/tools/jbws1079)
Deleted: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.ws.tools.jbws1079;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import org.jboss.test.ws.JBossWSTest;
-import org.jboss.test.ws.tools.fixture.JBossSourceComparator;
-import org.jboss.ws.tools.WSTools;
-import org.jboss.ws.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-/**
- *
- * @author darran.lofthouse(a)jboss.com
- * @since Nov 5, 2006
- */
-public class JBWS1079TestCase extends JBossWSTest
-{
-
- public void testAnonymousType() throws Exception
- {
- String resourceDir = "resources/tools/jbws1079";
- String toolsDir = "tools/jbws1079";
- String[] args = new String[] { "-dest", toolsDir, "-config", resourceDir + "/wstools-config.xml" };
- new WSTools().generate(args);
-
- Element exp = DOMUtils.parse(new FileInputStream(resourceDir + "/anonymous-mapping.xml"));
- Element was = DOMUtils.parse(new FileInputStream(toolsDir + "/anonymous-mapping.xml"));
- assertEquals(exp, was);
-
- compareSource(resourceDir + "/TelephoneNumber.java", toolsDir + "/org/jboss/test/ws/jbws1079/TelephoneNumber.java");
- compareSource(resourceDir + "/TelephoneNumberNumber.java", toolsDir + "/org/jboss/test/ws/jbws1079/TelephoneNumberNumber.java");
- }
-
- private static void compareSource(final String expectedName, final String generatedName) throws Exception
- {
- File expected = new File(expectedName);
- File generated = new File(generatedName);
-
- JBossSourceComparator sc = new JBossSourceComparator(expected, generated);
- sc.validate();
- sc.validateImports();
- }
-}
Copied: branches/jbossws-1.0/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/java/org/jboss/test/ws/tools/jbws1079/JBWS1079TestCase.java)
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079 (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079)
Deleted: branches/jbossws-1.0/src/test/resources/tools/jbws1079/Anonymous.wsdl
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/Anonymous.wsdl 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/resources/tools/jbws1079/Anonymous.wsdl 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<definitions name='PhoneBook' targetNamespace='http://test.jboss.org/ws/jbws1079' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:ns1='http://test.jboss.org/ws/jbws1079/types' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://test.jboss.org/ws/jbws1079' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
- <types>
- <schema targetNamespace='http://test.jboss.org/ws/jbws1079/types' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://test.jboss.org/ws/jbws1079/types' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
- <complexType name='Person'>
- <sequence>
- <element name='firstName' nillable='true' type='string'/>
- <element name='surname' nillable='true' type='string'/>
- </sequence>
- </complexType>
- <complexType name='TelephoneNumber'>
- <sequence>
- <element name='Number'>
- <complexType>
- <sequence>
- <element name='areaCode' nillable='true' type='string'/>
- <element name='number' nillable='true' type='string'/>
- </sequence>
- </complexType>
- </element>
- </sequence>
- </complexType>
- <element name='lookup' type='tns:Person'/>
- <element name='lookupResponse' type='tns:TelephoneNumber'/>
- </schema>
- </types>
- <message name='PhoneBook_lookup'>
- <part element='ns1:lookup' name='parameters'/>
- </message>
- <message name='PhoneBook_lookupResponse'>
- <part element='ns1:lookupResponse' name='result'/>
- </message>
- <portType name='PhoneBook'>
- <operation name='lookup'>
- <input message='tns:PhoneBook_lookup'/>
- <output message='tns:PhoneBook_lookupResponse'/>
- </operation>
- </portType>
- <binding name='PhoneBookBinding' type='tns:PhoneBook'>
- <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
- <operation name='lookup'>
- <soap:operation soapAction=''/>
- <input>
- <soap:body use='literal'/>
- </input>
- <output>
- <soap:body use='literal'/>
- </output>
- </operation>
- </binding>
- <service name='PhoneBook'>
- <port binding='tns:PhoneBookBinding' name='PhoneBookPort'>
- <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
- </port>
- </service>
-</definitions>
\ No newline at end of file
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079/Anonymous.wsdl (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/Anonymous.wsdl)
Deleted: branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumber.java
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/TelephoneNumber.java 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumber.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,27 +0,0 @@
-/*
- * JBossWS WS-Tools Generated Source
- *
- * Generation Date: Sun Nov 05 12:21:27 CET 2006
- *
- * This generated source code represents a derivative work of the input to
- * the generator that produced it. Consult the input for the copyright and
- * terms of use that apply to this source code.
- */
-
-package org.jboss.test.ws.jbws1079;
-
-
-public class TelephoneNumber
-{
-
-protected org.jboss.test.ws.jbws1079.TelephoneNumberNumber number;
-public TelephoneNumber(){}
-
-public TelephoneNumber(org.jboss.test.ws.jbws1079.TelephoneNumberNumber number){
-this.number=number;
-}
-public org.jboss.test.ws.jbws1079.TelephoneNumberNumber getNumber() { return number ;}
-
-public void setNumber(org.jboss.test.ws.jbws1079.TelephoneNumberNumber number){ this.number=number; }
-
-}
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumber.java (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/TelephoneNumber.java)
Deleted: branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,34 +0,0 @@
-/*
- * JBossWS WS-Tools Generated Source
- *
- * Generation Date: Sun Nov 05 12:21:27 CET 2006
- *
- * This generated source code represents a derivative work of the input to
- * the generator that produced it. Consult the input for the copyright and
- * terms of use that apply to this source code.
- */
-
-package org.jboss.test.ws.jbws1079;
-
-
-public class TelephoneNumberNumber
-{
-
-protected java.lang.String areaCode;
-
-protected java.lang.String number;
-public TelephoneNumberNumber(){}
-
-public TelephoneNumberNumber(java.lang.String areaCode, java.lang.String number){
-this.areaCode=areaCode;
-this.number=number;
-}
-public java.lang.String getAreaCode() { return areaCode ;}
-
-public void setAreaCode(java.lang.String areaCode){ this.areaCode=areaCode; }
-
-public java.lang.String getNumber() { return number ;}
-
-public void setNumber(java.lang.String number){ this.number=number; }
-
-}
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/TelephoneNumberNumber.java)
Deleted: branches/jbossws-1.0/src/test/resources/tools/jbws1079/anonymous-mapping.xml
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/anonymous-mapping.xml 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/resources/tools/jbws1079/anonymous-mapping.xml 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,72 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping version='1.1' xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
- <package-mapping>
- <package-type>org.jboss.test.ws.jbws1079</package-type>
- <namespaceURI>http://test.jboss.org/ws/jbws1079</namespaceURI>
- </package-mapping>
- <java-xml-type-mapping>
- <java-type>org.jboss.test.ws.jbws1079.Person</java-type>
- <root-type-qname xmlns:typeNS='http://test.jboss.org/ws/jbws1079/types'>typeNS:Person</root-type-qname>
- <qname-scope>complexType</qname-scope>
- <variable-mapping>
- <java-variable-name>firstName</java-variable-name>
- <xml-element-name>firstName</xml-element-name>
- </variable-mapping>
- <variable-mapping>
- <java-variable-name>surname</java-variable-name>
- <xml-element-name>surname</xml-element-name>
- </variable-mapping>
- </java-xml-type-mapping>
- <java-xml-type-mapping>
- <java-type>org.jboss.test.ws.jbws1079.TelephoneNumber</java-type>
- <root-type-qname xmlns:typeNS='http://test.jboss.org/ws/jbws1079/types'>typeNS:TelephoneNumber</root-type-qname>
- <qname-scope>complexType</qname-scope>
- <variable-mapping>
- <java-variable-name>number</java-variable-name>
- <xml-element-name>Number</xml-element-name>
- </variable-mapping>
- </java-xml-type-mapping>
- <java-xml-type-mapping>
- <java-type>org.jboss.test.ws.jbws1079.TelephoneNumberNumber</java-type>
- <anonymous-type-qname xmlns:typeNS='http://test.jboss.org/ws/jbws1079/types'>typeNS:>Number</anonymous-type-qname>
- <qname-scope>complexType</qname-scope>
- <variable-mapping>
- <java-variable-name>areaCode</java-variable-name>
- <xml-element-name>areaCode</xml-element-name>
- </variable-mapping>
- <variable-mapping>
- <java-variable-name>number</java-variable-name>
- <xml-element-name>number</xml-element-name>
- </variable-mapping>
- </java-xml-type-mapping>
- <service-interface-mapping>
- <service-interface>org.jboss.test.ws.jbws1079.PhoneBook_Service</service-interface>
- <wsdl-service-name xmlns:serviceNS='http://test.jboss.org/ws/jbws1079'>serviceNS:PhoneBook</wsdl-service-name>
- <port-mapping>
- <port-name>PhoneBookPort</port-name>
- <java-port-name>PhoneBookPort</java-port-name>
- </port-mapping>
- </service-interface-mapping>
- <service-endpoint-interface-mapping>
- <service-endpoint-interface>org.jboss.test.ws.jbws1079.PhoneBook_PortType</service-endpoint-interface>
- <wsdl-port-type xmlns:portTypeNS='http://test.jboss.org/ws/jbws1079'>portTypeNS:PhoneBook</wsdl-port-type>
- <wsdl-binding xmlns:bindingNS='http://test.jboss.org/ws/jbws1079'>bindingNS:PhoneBookBinding</wsdl-binding>
- <service-endpoint-method-mapping>
- <java-method-name>lookup</java-method-name>
- <wsdl-operation>lookup</wsdl-operation>
- <method-param-parts-mapping>
- <param-position>0</param-position>
- <param-type>org.jboss.test.ws.jbws1079.Person</param-type>
- <wsdl-message-mapping>
- <wsdl-message xmlns:wsdlMsgNS='http://test.jboss.org/ws/jbws1079'>wsdlMsgNS:PhoneBook_lookup</wsdl-message>
- <wsdl-message-part-name>parameters</wsdl-message-part-name>
- <parameter-mode>IN</parameter-mode>
- </wsdl-message-mapping>
- </method-param-parts-mapping>
- <wsdl-return-value-mapping>
- <method-return-value>org.jboss.test.ws.jbws1079.TelephoneNumber</method-return-value>
- <wsdl-message xmlns:wsdlMsgNS='http://test.jboss.org/ws/jbws1079'>wsdlMsgNS:PhoneBook_lookupResponse</wsdl-message>
- <wsdl-message-part-name>result</wsdl-message-part-name>
- </wsdl-return-value-mapping>
- </service-endpoint-method-mapping>
- </service-endpoint-interface-mapping>
-</java-wsdl-mapping>
\ No newline at end of file
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079/anonymous-mapping.xml (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/anonymous-mapping.xml)
Deleted: branches/jbossws-1.0/src/test/resources/tools/jbws1079/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/wstools-config.xml 2006-11-05 13:34:01 UTC (rev 1387)
+++ branches/jbossws-1.0/src/test/resources/tools/jbws1079/wstools-config.xml 2006-11-16 22:50:57 UTC (rev 1452)
@@ -1,5 +0,0 @@
-<configuration>
- <wsdl-java location="resources/tools/jbws1079/Anonymous.wsdl" parameter-style="bare">
- <mapping file="anonymous-mapping.xml"/>
- </wsdl-java>
-</configuration>
Copied: branches/jbossws-1.0/src/test/resources/tools/jbws1079/wstools-config.xml (from rev 1387, branches/dlofthouse/JBWS-1079/src/test/resources/tools/jbws1079/wstools-config.xml)
18 years, 1 month
JBossWS SVN: r1451 - branches/jbossws-1.0
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2006-11-16 08:13:31 -0500 (Thu, 16 Nov 2006)
New Revision: 1451
Modified:
branches/jbossws-1.0/version.properties
Log:
1.0.5.DEV
Modified: branches/jbossws-1.0/version.properties
===================================================================
--- branches/jbossws-1.0/version.properties 2006-11-16 13:10:56 UTC (rev 1450)
+++ branches/jbossws-1.0/version.properties 2006-11-16 13:13:31 UTC (rev 1451)
@@ -5,8 +5,8 @@
specification.vendor=JBoss (http://www.jboss.com)
specification.version=jbossws-1.0
-version.id=1.0.4.GA
-repository.id=1.0.4.GA
+version.id=1.0.5.DEV
+repository.id=1.0.5.DEV
implementation.title=JBoss Web Services (JBossWS)
implementation.url=http://labs.jboss.com/portal/jbossws
18 years, 1 month
JBossWS SVN: r1450 - /
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2006-11-16 08:10:56 -0500 (Thu, 16 Nov 2006)
New Revision: 1450
Removed:
jbossws-1.0/
Log:
remove erroneous import
18 years, 1 month
JBossWS SVN: r1449 - /
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2006-11-16 08:06:16 -0500 (Thu, 16 Nov 2006)
New Revision: 1449
Added:
jbossws-1.0/
Log:
Initial import.
18 years, 1 month
JBossWS SVN: r1448 - tags/jbossws-1.0.4.GA
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2006-11-16 06:00:57 -0500 (Thu, 16 Nov 2006)
New Revision: 1448
Modified:
tags/jbossws-1.0.4.GA/README-COMMITTERS
Log:
test lock
Modified: tags/jbossws-1.0.4.GA/README-COMMITTERS
===================================================================
--- tags/jbossws-1.0.4.GA/README-COMMITTERS 2006-11-16 10:18:34 UTC (rev 1447)
+++ tags/jbossws-1.0.4.GA/README-COMMITTERS 2006-11-16 11:00:57 UTC (rev 1448)
@@ -17,3 +17,5 @@
c:\cygwin\home\<your user name>\.subversion
3. If you are using Eclipse, set your code style to JBossWSCodeStyle.xml
+
+test
18 years, 1 month
JBossWS SVN: r1447 - branches/jbossws-1.0.4.GA-JBWS-1379/src/main/java/org/jboss/ws/soap/attachment
by jbossws-commits@lists.jboss.org
Author: mageshbk
Date: 2006-11-16 05:18:34 -0500 (Thu, 16 Nov 2006)
New Revision: 1447
Modified:
branches/jbossws-1.0.4.GA-JBWS-1379/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandler.java
Log:
JBWS-1379 Support Patch for JBWS-1284 - Gracefully handle invalid ImageIO mime types
Modified: branches/jbossws-1.0.4.GA-JBWS-1379/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandler.java
===================================================================
--- branches/jbossws-1.0.4.GA-JBWS-1379/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandler.java 2006-11-16 09:19:19 UTC (rev 1446)
+++ branches/jbossws-1.0.4.GA-JBWS-1379/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandler.java 2006-11-16 10:18:34 UTC (rev 1447)
@@ -30,6 +30,7 @@
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.Iterator;
import javax.activation.ActivationDataFlavor;
@@ -39,6 +40,8 @@
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
+import org.jboss.logging.Logger;
+
/**
* <code>ImageDataContentHandler</code> is a JAF content handler that handles
* marshalling/unmarshalling between <code>Image</code> objects and a stream.
@@ -53,9 +56,13 @@
* an exception will be thrown indicating the lack of encoding support.
*
* @author <a href="mailto:jason@stacksmash.com">Jason T. Greene</a>
+ * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar B</a>
*/
public class ImageDataContentHandler extends Component implements DataContentHandler
{
+ // provide logging
+ private static Logger log = Logger.getLogger(ImageDataContentHandler.class);
+
private static DataFlavor[] flavors;
static
@@ -71,11 +78,28 @@
String[] mimeTypes = ImageIO.getReaderMIMETypes();
if (mimeTypes == null)
return;
- flavors = new DataFlavor[mimeTypes.length];
+ ArrayList flavs = new ArrayList ();
+ DataFlavor flavor;
+ //flavors = new DataFlavor[mimeTypes.length];
for (int i = 0; i < mimeTypes.length; i++)
{
- flavors[i] = new ActivationDataFlavor(Image.class, mimeTypes[i], "Image");
+ try
+ {
+ flavor = new ActivationDataFlavor(Image.class, mimeTypes[i], "Image");
+ flavs.add(flavor);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ //This mime type is not supported
+ log.warn("Unsupported MIME Type '" + mimeTypes[i] +"'");
+ }
}
+ int size = flavs.size();
+ flavors = new DataFlavor[size];
+ for (int i = 0; i < size; i++)
+ {
+ flavors[i] = (ActivationDataFlavor)flavs.get(i);
+ }
}
private static ImageWriter getImageWriter(String mimeType) {
18 years, 1 month