1 57 58 package org.apache.wsif.providers.soap.apachesoap; 59 60 import java.math.BigDecimal ; 61 62 import org.apache.soap.Constants; 63 import org.apache.soap.encoding.SOAPMappingRegistry; 64 import org.apache.soap.util.xml.Deserializer; 65 import org.apache.soap.util.xml.QName; 66 import org.apache.soap.util.xml.Serializer; 67 import org.apache.wsif.WSIFConstants; 68 import org.apache.wsif.logging.Trc; 69 70 74 public class WSIFSOAPMappingRegistry extends SOAPMappingRegistry { 75 76 79 public WSIFSOAPMappingRegistry() { 80 super(); 81 Trc.entry(this); 82 Trc.exit(); 83 } 84 85 89 public WSIFSOAPMappingRegistry(SOAPMappingRegistry registry) { 90 super(registry); 91 Trc.entry(this, registry); 92 Trc.exit(); 93 } 94 95 100 public WSIFSOAPMappingRegistry( 101 SOAPMappingRegistry registry, 102 String schemaURI) { 103 super(registry, schemaURI); 104 Trc.entry(this, registry, schemaURI); 105 Trc.exit(); 106 } 107 108 114 protected Serializer querySerializer_( 115 Class javaType, 116 String encodingStyleURI) { 117 Trc.entry(this, javaType, encodingStyleURI); 118 Serializer ser = super.querySerializer_(javaType, encodingStyleURI); 119 Trc.exit(ser); 120 return ser; 121 } 122 123 129 protected Deserializer queryDeserializer_( 130 QName elementType, 131 String encodingStyleURI) { 132 Trc.entry(this, elementType, encodingStyleURI); 133 Deserializer deser = null; 134 if (elementType != null 135 && elementType.getNamespaceURI().equals( 136 WSIFConstants.NS_URI_SOAP_ENC)) { 137 QName qn = getEquivalentXSDSimpleType(elementType); 138 if (qn != null) { 139 deser = super.queryDeserializer_(qn, encodingStyleURI); 140 } 141 } 142 if (deser == null) { 143 deser = super.queryDeserializer_(elementType, encodingStyleURI); 144 } 145 Trc.exit(deser); 146 return deser; 147 } 148 149 155 protected QName queryElementType_( 156 Class javaType, 157 String encodingStyleURI) { 158 return super.queryElementType_(javaType, encodingStyleURI); 159 } 160 161 167 protected Class queryJavaType_( 168 QName elementType, 169 String encodingStyleURI) { 170 Class cls = null; 171 if (elementType != null 172 && elementType.getNamespaceURI().equals( 173 WSIFConstants.NS_URI_SOAP_ENC)) { 174 cls = resolveSOAPENCSimpleType(elementType); 175 } 176 if (cls == null) { 177 return super.queryJavaType_(elementType, encodingStyleURI); 178 } 179 return cls; 180 } 181 182 private QName getEquivalentXSDSimpleType(QName elementType) { 183 if (elementType == null 184 || !elementType.getNamespaceURI().equals( 185 WSIFConstants.NS_URI_SOAP_ENC)) { 186 return null; 187 } 188 189 String lp = elementType.getLocalPart(); 190 if (lp == null) { 191 return null; 192 } 193 194 if (lp.equals("string")) { 195 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "string"); 196 } else if (lp.equals("boolean")) { 197 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "boolean"); 198 } else if (lp.equals("float")) { 199 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "float"); 200 } else if (lp.equals("double")) { 201 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "double"); 202 } else if (lp.equals("decimal")) { 203 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "decimal"); 204 } else if (lp.equals("int")) { 205 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "int"); 206 } else if (lp.equals("short")) { 207 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "short"); 208 } else if (lp.equals("byte")) { 209 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "byte"); 210 } else if (lp.equals("base64")) { 211 return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "base64Binary"); 212 } else { 213 return null; 214 } 215 } 216 217 private Class resolveSOAPENCSimpleType(QName elementType) { 218 if (elementType == null 219 || !elementType.getNamespaceURI().equals( 220 WSIFConstants.NS_URI_SOAP_ENC)) { 221 return null; 222 } 223 224 String lp = elementType.getLocalPart(); 225 if (lp == null) { 226 return null; 227 } 228 229 if (lp.equals("string")) { 230 return String .class; 231 } else if (lp.equals("boolean")) { 232 return Boolean .class; 233 } else if (lp.equals("float")) { 234 return Float .class; 235 } else if (lp.equals("double")) { 236 return Double .class; 237 } else if (lp.equals("decimal")) { 238 return BigDecimal .class; 239 } else if (lp.equals("int")) { 240 return Integer .class; 241 } else if (lp.equals("short")) { 242 return Short .class; 243 } else if (lp.equals("byte")) { 244 return Byte .class; 245 } else if (lp.equals("base64")) { 246 return byte[].class; 247 } else { 248 return null; 249 } 250 } 251 } | Popular Tags |