antelder 2002/12/31 06:25:28 Modified: java/src/org/apache/wsif/providers/soap/apacheaxis WSIFPort_ApacheAxis.java WSIFOperation_ApacheAxis.java Log: Clean up the AXIS provider type mappings for sync/async and remove duplicated code Revision Changes Path 1.22 +28 -24 xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java Index: WSIFPort_ApacheAxis.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WSIFPort_ApacheAxis.java 7 Dec 2002 12:33:52 -0000 1.21 +++ WSIFPort_ApacheAxis.java 31 Dec 2002 14:25:27 -0000 1.22 @@ -60,18 +60,13 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.wsdl.Definition; -import javax.wsdl.Input; -import javax.wsdl.Operation; -import javax.wsdl.Output; import javax.wsdl.Port; -import javax.wsdl.PortType; import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap.SOAPOperation; @@ -351,29 +346,38 @@ public Call getCall() throws WSIFException { Trc.entry(this); if (call == null) { - java.net.URL url = getEndPoint(); - try { - if (url != null) { - call = new Call(url); - Transport axistransport = getTransport(); - if (axistransport != null) { - axistransport.setUrl(url.toString()); - } - } else { - call = new Call(new org.apache.axis.client.Service()); - } - } catch (JAXRPCException e) { - Trc.exception(e); - throw new WSIFException( - "exception creating call object: " - + e.getLocalizedMessage(), - e); - } + call = makeNewAXISCall(); } - call.setMaintainSession(true); Trc.exit(call); return call; } + + /** + * Creates a new AXIS Call object + */ + private Call makeNewAXISCall() throws WSIFException { + Call c = null; + java.net.URL url = getEndPoint(); + try { + if (url != null) { + c = new Call(url); + Transport axistransport = getTransport(); + if (axistransport != null) { + axistransport.setUrl(url.toString()); + } + } else { + c = new Call(new org.apache.axis.client.Service()); + } + c.setMaintainSession(true); + } catch (JAXRPCException e) { + Trc.exception(e); + throw new WSIFException( + "exception creating call object: " + + e.getLocalizedMessage(), + e); + } + return c; + } /** * Returns the Definition object for the WSDL file 1.51 +35 -57 xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java Index: WSIFOperation_ApacheAxis.java =================================================================== RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- WSIFOperation_ApacheAxis.java 18 Dec 2002 13:54:04 -0000 1.50 +++ WSIFOperation_ApacheAxis.java 31 Dec 2002 14:25:27 -0000 1.51 @@ -171,7 +171,7 @@ protected String outputEncodingStyle; protected WSIFDynamicTypeMap typeMap; protected String operationStyle; - + /** * Construct a new WSIFOperation */ @@ -1114,41 +1114,12 @@ MessageContext msgContext = new MessageContext(service.getEngine()); msgContext.setResponseMessage(responseMessage); - // This registerTypeMapping code is duplicated in prepare - //registerTypeMappings(call); - //TODO: need to sort out this duplicated code TypeMappingRegistry tmr = msgContext.getTypeMappingRegistry(); org.apache.axis.encoding.TypeMapping tm = (org.apache.axis.encoding.TypeMapping) tmr.getTypeMapping( outputEncodingStyle); - Class objClass; - String namespaceURI, localPart; - WSIFDynamicTypeMapping wsifdynamictypemapping; - for (Iterator iterator = typeMap.iterator(); iterator.hasNext();) { - wsifdynamictypemapping = - (WSIFDynamicTypeMapping) iterator.next(); - objClass = wsifdynamictypemapping.getJavaType(); - namespaceURI = - wsifdynamictypemapping.getXmlType().getNamespaceURI(); - - // Filter out XSD and SOAP-ENC types from those we explicitly map. - // Axis already knows how to deal with these; using the BeanSerializer - // would be wrong anyway as they represent simple types and not beans. - if (namespaceURI != null - && !namespaceURI.equals(WSIFConstants.NS_URI_1999_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_2000_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_SOAP_ENC)) { - localPart = - wsifdynamictypemapping.getXmlType().getLocalPart(); - QName qn = new QName(namespaceURI, localPart); - BeanSerializerFactory bsf = - new BeanSerializerFactory(objClass, qn); - BeanDeserializerFactory bdf = - new BeanDeserializerFactory(objClass, qn); - tm.register(objClass, qn, bsf, bdf); - } - } + + registerTypeMappings(tm, typeMap); Message resMsg = msgContext.getResponseMessage(); SOAPEnvelope resEnv = resMsg.getSOAPEnvelope(); @@ -1323,7 +1294,7 @@ throws WSIFException { Trc.entry(this, inMsg, outMsg, faultMsg); - Call call = wsifPort.getCall(); + Call call = wsifPort.getCall(); // Make sure we're making a fresh start. call.removeAllParameters(); @@ -1510,7 +1481,7 @@ Trc.entry(this, inMsg, outMsg, faultMsg); boolean workedOK = false; - Call call = wsifPort.getCall(); + Call call = wsifPort.getCall(); // Make sure we're making a fresh start. call.removeAllParameters(); @@ -1758,7 +1729,7 @@ } // register any WSIFDynamicTypeMappings - registerTypeMappings(call); + registerTypeMappings(call.getTypeMapping(), typeMap); registerMIMETypes( inputMIMEParts, @@ -1775,11 +1746,10 @@ * Register all the type mappings with the AXIS Call object * TODO: why is this here and not in the port and done when Cal is created? */ - private void registerTypeMappings(Call call) throws WSIFException { + private static void registerTypeMappings(TypeMapping tm, WSIFDynamicTypeMap typeMap) throws WSIFException { Class objClass; String namespaceURI, localPart; WSIFDynamicTypeMapping wsifdynamictypemapping; - TypeMapping tm = call.getTypeMapping(); for (Iterator iterator = typeMap.iterator(); iterator.hasNext();) { wsifdynamictypemapping = (WSIFDynamicTypeMapping) iterator.next(); objClass = wsifdynamictypemapping.getJavaType(); @@ -1787,20 +1757,21 @@ SerializerFactory sf = null; DeserializerFactory df = null; - if (tm.getSerializer(objClass, xmlType) == null) { - if (objClass.isArray()) { - sf = new ArraySerializerFactory(); - } else { - sf = new BeanSerializerFactory(objClass, xmlType); - } - } - if (tm.getDeserializer(objClass, xmlType) == null) { - if (objClass.isArray()) { - df = new ArrayDeserializerFactory(); - } else { - df = new BeanDeserializerFactory(objClass, xmlType); - } - } + + if (tm.getSerializer(objClass, xmlType) == null) { + if (objClass.isArray()) { + sf = new ArraySerializerFactory(); + } else { + sf = new BeanSerializerFactory(objClass, xmlType); + } + } + if (tm.getDeserializer(objClass, xmlType) == null) { + if (objClass.isArray()) { + df = new ArrayDeserializerFactory(); + } else { + df = new BeanDeserializerFactory(objClass, xmlType); + } + } namespaceURI = wsifdynamictypemapping.getXmlType().getNamespaceURI(); @@ -1808,20 +1779,27 @@ // Filter out XSD and SOAP-ENC types from those we explicitly map. // Axis already knows how to deal with these; using the BeanSerializer // would be wrong anyway as they represent simple types and not beans. - if (namespaceURI != null - && !namespaceURI.equals(WSIFConstants.NS_URI_1999_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_2000_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD) - && !namespaceURI.equals(WSIFConstants.NS_URI_SOAP_ENC)) { + if (!isDefaultSOAPNamespace(namespaceURI) ) { localPart = wsifdynamictypemapping.getXmlType().getLocalPart(); QName qn = new QName(namespaceURI, localPart); if (sf != null || df != null) { - call.registerTypeMapping(objClass, qn, sf, df); + tm.register(objClass, qn, sf, df); } } } + } + + private static boolean isDefaultSOAPNamespace(String ns) { + boolean soapNamespace = false; + if (WSIFConstants.NS_URI_1999_SCHEMA_XSD.equals(ns) + || WSIFConstants.NS_URI_2000_SCHEMA_XSD.equals(ns) + || WSIFConstants.NS_URI_2001_SCHEMA_XSD.equals(ns) + || WSIFConstants.NS_URI_SOAP_ENC.equals(ns) ){ + soapNamespace = true; + } + return soapNamespace; } /**