Author: heiko.braun(a)jboss.com
Date: 2007-03-06 08:45:43 -0500 (Tue, 06 Mar 2007)
New Revision: 2535
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
trunk/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/XmlDataContentHandler.java
trunk/jbossws-core/src/java/org/jboss/ws/core/utils/IOUtils.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
Log:
Fix SWA for JAX-WS
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-06
11:56:20 UTC (rev 2534)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/CommonSOAPBinding.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -387,7 +387,7 @@
if (paramMetaData.isSwA())
{
CIDGenerator cidGenerator = resMessage.getCidGenerator();
- AttachmentPart part = createAttachmentPart(retMetaData, value,
cidGenerator);
+ AttachmentPart part = createAttachmentPart(paramMetaData, value,
cidGenerator);
resMessage.addAttachmentPart(part);
}
else
@@ -530,7 +530,7 @@
handleException(e);
}
}
-
+
public Object bindFaultMessage(Exception ex)
{
SOAPMessage faultMessage = createFaultMessageFromException(ex);
@@ -570,8 +570,11 @@
DataHandler handler = (DataHandler)value;
String mimeType = MimeUtils.getBaseMimeType(handler.getContentType());
+ // JAX-WS 2.0, 2.6.3.1 MIME Content
+ // Conformance (MIME type mismatch): On receipt of a message where the MIME type
of a part does not
+ // match that described in the WSDL an implementation SHOULD throw a
WebServiceException.
if (mimeTypes != null && !MimeUtils.isMemberOf(mimeType, mimeTypes))
- throw new BindingException("Mime type " + mimeType + " not
allowed for parameter " + partName + " allowed types are " + mimeTypes);
+ log.warn("Mime type " + mimeType + " not allowed for parameter
" + partName + " allowed types are " + mimeTypes);
part.setDataHandler((DataHandler)value);
}
@@ -777,7 +780,7 @@
if (paramMetaData.isXOP() && XOPContext.isXOPEncodedRequest())
{
SOAPMessageImpl soapMessage =
(SOAPMessageImpl)MessageContextAssociation.peekMessageContext().getSOAPMessage();
- soapMessage.setXOPMessage(true);
+ soapMessage.setXOPMessage(true);
}
return soapContentElement;
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java 2007-03-06
11:56:20 UTC (rev 2534)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/EndpointInvocation.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -207,8 +207,11 @@
DataHandler handler = part.getDataHandler();
String mimeType = MimeUtils.getBaseMimeType(handler.getContentType());
+ // JAX-WS 2.0, 2.6.3.1 MIME Content
+ // Conformance (MIME type mismatch): On receipt of a message where the MIME
type of a part does not
+ // match that described in the WSDL an implementation SHOULD throw a
WebServiceException.
if (mimeTypes != null && !MimeUtils.isMemberOf(mimeType, mimeTypes))
- throw new SOAPException("Mime type " + mimeType + " not
allowed for parameter " + xmlName + " allowed types are " + mimeTypes);
+ log.warn("Mime type " + mimeType + " not allowed for
parameter " + xmlName + " allowed types are " + mimeTypes);
retValue = part.getDataHandler();
}
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/XmlDataContentHandler.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/XmlDataContentHandler.java 2007-03-06
11:56:20 UTC (rev 2534)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/attachment/XmlDataContentHandler.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Reader;
import javax.activation.ActivationDataFlavor;
import javax.activation.DataContentHandler;
@@ -102,9 +103,14 @@
// TODO - add support for reader source
InputStream stream = ((StreamSource) obj).getInputStream();
- if (stream == null)
- throw new IOException("XML Content handler requires an input stream based
StreamSource");
+ if (stream != null)
+ {
+ IOUtils.copyStream(os, stream);
+ }
+ else
+ {
+ IOUtils.copyReader(os, ((StreamSource) obj).getReader());
- IOUtils.copyStream(os, stream);
+ }
}
}
\ No newline at end of file
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/utils/IOUtils.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/utils/IOUtils.java 2007-03-06 11:56:20
UTC (rev 2534)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/utils/IOUtils.java 2007-03-06 13:45:43
UTC (rev 2535)
@@ -72,6 +72,18 @@
r = ins.read(bytes);
}
}
+
+ public static void copyReader(OutputStream outs, Reader reader) throws IOException
+ {
+ OutputStreamWriter writer = new OutputStreamWriter(outs);
+ char[] bytes = new char[1024];
+ int r = reader.read(bytes);
+ while (r > 0)
+ {
+ writer.write(bytes, 0, r);
+ r = reader.read(bytes);
+ }
+ }
public static byte[] convertToBytes(DataHandler dh)
{
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-03-06
11:56:20 UTC (rev 2534)
+++
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilder.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -23,38 +23,8 @@
// $Id$
-import java.io.File;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.jws.HandlerChain;
-import javax.jws.Oneway;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebResult;
-import javax.jws.soap.SOAPBinding;
-import javax.jws.soap.SOAPMessageHandlers;
-import javax.jws.soap.SOAPBinding.ParameterStyle;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.ParameterMode;
-import javax.xml.ws.BindingType;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.ResponseWrapper;
-import javax.xml.ws.WebFault;
-import javax.xml.ws.addressing.Action;
-import javax.xml.ws.addressing.AddressingProperties;
-
+import com.sun.xml.bind.api.JAXBRIContext;
+import com.sun.xml.bind.api.TypeReference;
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
@@ -73,20 +43,39 @@
import org.jboss.ws.metadata.jsr181.HandlerChainFactory;
import org.jboss.ws.metadata.jsr181.HandlerChainMetaData;
import org.jboss.ws.metadata.jsr181.HandlerChainsMetaData;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.metadata.umdm.FaultMetaData;
-import org.jboss.ws.metadata.umdm.OperationMetaData;
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
-import org.jboss.ws.metadata.umdm.TypeMappingMetaData;
-import org.jboss.ws.metadata.umdm.TypesMetaData;
-import org.jboss.ws.metadata.umdm.WrappedParameter;
+import org.jboss.ws.metadata.umdm.*;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
+import org.jboss.ws.metadata.wsdl.*;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
-import com.sun.xml.bind.api.JAXBRIContext;
-import com.sun.xml.bind.api.TypeReference;
+import javax.jws.*;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPMessageHandlers;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.ParameterMode;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.WebFault;
+import javax.xml.ws.addressing.Action;
+import javax.xml.ws.addressing.AddressingProperties;
+import java.io.File;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
/**
* Abstract class that represents a JAX-WS metadata builder.
@@ -624,7 +613,7 @@
if (mode != ParameterMode.OUT)
wrappedParameters.add(wrappedParameter);
-
+
if (mode != ParameterMode.IN)
{
wrappedParameter.setHolder(true);
@@ -662,6 +651,8 @@
opMetaData.addParameter(paramMetaData);
javaTypes.add(javaType);
typeRefs.add(new TypeReference(xmlName, genericType,
parameterAnnotations[i]));
+
+ processMIMEBinding(epMetaData, opMetaData, paramMetaData);
}
}
@@ -717,6 +708,8 @@
javaTypes.add(returnType);
typeRefs.add(new TypeReference(xmlName, genericReturnType,
method.getAnnotations()));
+
+ processMIMEBinding(epMetaData, opMetaData, retMetaData);
}
}
@@ -753,6 +746,44 @@
processMetaExtensions(method, epMetaData, opMetaData);
}
+ private void processMIMEBinding(EndpointMetaData epMetaData, OperationMetaData
opMetaData, ParameterMetaData paramMetaData)
+ {
+ // process SWA metadata
+ WSDLDefinitions wsdlDef = epMetaData.getServiceMetaData().getWsdlDefinitions();
+ if(wsdlDef!=null)
+ {
+ for(WSDLBinding binding : wsdlDef.getBindings())
+ {
+ for(WSDLBindingOperation bindingOp : binding.getOperations())
+ {
+ // it might an input or output parameter
+ WSDLBindingMessageReference[] inOrOutPut =
+ (paramMetaData.getMode().equals(ParameterMode.IN) ||
paramMetaData.getMode().equals(ParameterMode.INOUT)) ?
+ ( WSDLBindingMessageReference[])bindingOp.getInputs() : (
WSDLBindingMessageReference[])bindingOp.getOutputs();
+
+ if(inOrOutPut.length > 0)
+ {
+ // find matching operation
+ if(bindingOp.getRef().equals( opMetaData.getQName()))
+ {
+ WSDLBindingMessageReference bindingInput = inOrOutPut[0];
+ for (WSDLMIMEPart mimePart : bindingInput.getMimeParts())
+ {
+ String partName = mimePart.getPartName();
+ if(paramMetaData.getPartName().equals(partName))
+ {
+ log.debug("Identified SWA parameter: " + partName +
", mimeTypes=" +mimePart.getMimeTypes());
+ paramMetaData.setSwA(true);
+ paramMetaData.setMimeTypes(mimePart.getMimeTypes());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
protected void processWebMethods(EndpointMetaData epMetaData, Class wsClass)
{
epMetaData.clearOperations();
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-03-06
11:56:20 UTC (rev 2534)
+++
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -117,6 +117,7 @@
processBindingType(sepMetaData, seiClass);
// Process web methods
+ if(result.wsdlLocation!=null)
serviceMetaData.setWsdlLocation(result.wsdlLocation);
processWebMethods(sepMetaData, seiClass);
// Init the transport guarantee
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-03-06
11:56:20 UTC (rev 2534)
+++
trunk/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-03-06
13:45:43 UTC (rev 2535)
@@ -529,11 +529,13 @@
{
List<Class> types = typeMapping.getJavaTypes(xmlType);
+ // TODO: Clarification. In which cases is the type already registered?
boolean registered = false;
for (Class current : types)
{
if (current.getName().equals(javaTypeName))
{
+ registeredTypes.add(current);
registered = true;
break;
}