001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.geronimo.axis.builder; 019 020 import java.lang.reflect.Method; 021 import java.net.MalformedURLException; 022 import java.net.URI; 023 import java.net.URISyntaxException; 024 import java.net.URL; 025 import java.util.ArrayList; 026 import java.util.Collection; 027 import java.util.Collections; 028 import java.util.HashMap; 029 import java.util.HashSet; 030 import java.util.Iterator; 031 import java.util.List; 032 import java.util.Map; 033 import java.util.Set; 034 import java.util.jar.JarFile; 035 036 import javax.wsdl.Binding; 037 import javax.wsdl.BindingOperation; 038 import javax.wsdl.Definition; 039 import javax.wsdl.Operation; 040 import javax.wsdl.Port; 041 import javax.wsdl.PortType; 042 import javax.wsdl.extensions.soap.SOAPAddress; 043 import javax.wsdl.extensions.soap.SOAPBinding; 044 import javax.xml.namespace.QName; 045 import javax.xml.rpc.handler.HandlerInfo; 046 047 import org.apache.axis.constants.Style; 048 import org.apache.axis.description.JavaServiceDesc; 049 import org.apache.axis.handlers.HandlerInfoChainFactory; 050 import org.apache.axis.handlers.soap.SOAPService; 051 import org.apache.axis.providers.java.RPCProvider; 052 import org.apache.axis.soap.SOAPConstants; 053 import org.apache.geronimo.axis.client.AxisServiceReference; 054 import org.apache.geronimo.axis.client.OperationInfo; 055 import org.apache.geronimo.axis.client.SEIFactory; 056 import org.apache.geronimo.axis.client.SEIFactoryImpl; 057 import org.apache.geronimo.axis.server.AxisWebServiceContainer; 058 import org.apache.geronimo.axis.server.POJOProvider; 059 import org.apache.geronimo.axis.server.ServiceInfo; 060 import org.apache.geronimo.common.DeploymentException; 061 import org.apache.geronimo.gbean.GBeanData; 062 import org.apache.geronimo.gbean.GBeanInfo; 063 import org.apache.geronimo.gbean.GBeanInfoBuilder; 064 import org.apache.geronimo.gbean.AbstractName; 065 import org.apache.geronimo.j2ee.deployment.Module; 066 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder; 067 import org.apache.geronimo.j2ee.deployment.HandlerInfoInfo; 068 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 069 import org.apache.geronimo.xbeans.geronimo.naming.GerPortCompletionType; 070 import org.apache.geronimo.xbeans.geronimo.naming.GerPortType; 071 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceCompletionType; 072 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType; 073 import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType; 074 import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType; 075 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType; 076 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType; 077 import org.apache.geronimo.deployment.util.DeploymentUtil; 078 import org.apache.geronimo.deployment.DeploymentContext; 079 import org.apache.geronimo.deployment.service.EnvironmentBuilder; 080 import org.apache.geronimo.webservices.SerializableWebServiceContainerFactoryGBean; 081 import org.apache.geronimo.webservices.builder.PortInfo; 082 import org.apache.geronimo.webservices.builder.SchemaInfoBuilder; 083 import org.apache.geronimo.webservices.builder.WSDescriptorParser; 084 import org.apache.geronimo.kernel.GBeanAlreadyExistsException; 085 import org.apache.geronimo.kernel.repository.Environment; 086 087 /** 088 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 089 */ 090 public class AxisBuilder implements WebServiceBuilder { 091 092 private static final SOAPConstants SOAP_VERSION = SOAPConstants.SOAP11_CONSTANTS; 093 094 private final Environment defaultEnvironment; 095 096 public AxisBuilder() { 097 defaultEnvironment = null; 098 } 099 100 public AxisBuilder(Environment defaultEnvironment) { 101 this.defaultEnvironment = defaultEnvironment; 102 } 103 104 105 public Map findWebServices(JarFile moduleFile, boolean isEJB, Map servletLocations, Environment environment) throws DeploymentException { 106 final String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml"; 107 try { 108 URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path); 109 Map result = WSDescriptorParser.parseWebServiceDescriptor(wsDDUrl, moduleFile, isEJB, servletLocations); 110 if (result != null) { 111 if (defaultEnvironment != null) { 112 EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment); 113 } 114 return result; 115 } 116 } catch (MalformedURLException e) { 117 // The webservices.xml file doesn't exist. 118 } 119 return Collections.EMPTY_MAP; 120 } 121 122 public void configurePOJO(GBeanData targetGBean, Module module, Object portInfoObject, String seiClassName, DeploymentContext context) throws DeploymentException { 123 ClassLoader cl = context.getClassLoader(); 124 PortInfo portInfo = (PortInfo) portInfoObject; 125 ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, cl); 126 JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc(); 127 128 targetGBean.setAttribute("pojoClassName", seiClassName); 129 RPCProvider provider = new POJOProvider(); 130 131 SOAPService service = new SOAPService(null, provider, null); 132 service.setServiceDescription(serviceDesc); 133 service.setOption("className", seiClassName); 134 135 HandlerInfoChainFactory handlerInfoChainFactory = new HandlerInfoChainFactory(serviceInfo.getHandlerInfos()); 136 service.setOption(org.apache.axis.Constants.ATTR_HANDLERINFOCHAIN, handlerInfoChainFactory); 137 138 URI location; 139 try { 140 location = new URI(serviceDesc.getEndpointURL()); 141 } catch (URISyntaxException e) { 142 throw new DeploymentException("Invalid webservice endpoint URI", e); 143 } 144 URI wsdlURI; 145 try { 146 wsdlURI = new URI(serviceDesc.getWSDLFile()); 147 } catch (URISyntaxException e) { 148 throw new DeploymentException("Invalid wsdl URI", e); 149 150 } 151 152 AxisWebServiceContainer axisWebServiceContainer = new AxisWebServiceContainer(location, wsdlURI, service, serviceInfo.getWsdlMap(), cl); 153 AbstractName webServiceContainerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(), "webServiceContainer", NameFactory.GERONIMO_SERVICE); 154 GBeanData webServiceContainerFactoryGBean = new GBeanData(webServiceContainerFactoryName, SerializableWebServiceContainerFactoryGBean.GBEAN_INFO); 155 webServiceContainerFactoryGBean.setAttribute("webServiceContainer", axisWebServiceContainer); 156 try { 157 context.addGBean(webServiceContainerFactoryGBean); 158 } catch (GBeanAlreadyExistsException e) { 159 throw new DeploymentException("Could not add webServiceContainerFactoryGBean", e); 160 } 161 targetGBean.setReferencePattern("WebServiceContainerFactory", webServiceContainerFactoryName); 162 } 163 164 public void configureEJB(GBeanData targetGBean, JarFile moduleFile, Object portInfoObject, ClassLoader classLoader) throws DeploymentException { 165 PortInfo portInfo = (PortInfo) portInfoObject; 166 ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, classLoader); 167 targetGBean.setAttribute("serviceInfo", serviceInfo); 168 JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc(); 169 URI location = portInfo.getContextURI(); 170 targetGBean.setAttribute("location", location); 171 URI wsdlURI; 172 try { 173 wsdlURI = new URI(serviceDesc.getWSDLFile()); 174 } catch (URISyntaxException e) { 175 throw new DeploymentException("Invalid wsdl URI", e); 176 } 177 targetGBean.setAttribute("wsdlURI", wsdlURI); 178 } 179 180 181 //ServicereferenceBuilder 182 public Object createService(Class serviceInterface, URI wsdlURI, URI jaxrpcMappingURI, QName serviceQName, Map portComponentRefMap, List handlerInfos, Object serviceRefType, Module module, ClassLoader classLoader) throws DeploymentException { 183 GerServiceRefType gerServiceRefType = (GerServiceRefType) serviceRefType; 184 JarFile moduleFile = module.getModuleFile(); 185 SchemaInfoBuilder schemaInfoBuilder = null; 186 JavaWsdlMappingType mapping = null; 187 if (wsdlURI != null) { 188 schemaInfoBuilder = new SchemaInfoBuilder(moduleFile, wsdlURI); 189 190 mapping = WSDescriptorParser.readJaxrpcMapping(moduleFile, jaxrpcMappingURI); 191 } 192 193 return createService(serviceInterface, schemaInfoBuilder, mapping, serviceQName, SOAP_VERSION, handlerInfos, gerServiceRefType, module, classLoader); 194 } 195 196 public Object createService(Class serviceInterface, SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, List handlerInfos, GerServiceRefType serviceRefType, Module module, ClassLoader classloader) throws DeploymentException { 197 Map seiPortNameToFactoryMap = new HashMap(); 198 Map seiClassNameToFactoryMap = new HashMap(); 199 if (schemaInfoBuilder != null) { 200 buildSEIFactoryMap(schemaInfoBuilder, serviceRefType, mapping, handlerInfos, serviceQName, soapVersion, seiPortNameToFactoryMap, seiClassNameToFactoryMap, classloader); 201 } 202 return new AxisServiceReference(serviceInterface.getName(), seiPortNameToFactoryMap, seiClassNameToFactoryMap); 203 } 204 205 public void buildSEIFactoryMap(SchemaInfoBuilder schemaInfoBuilder, GerServiceRefType serviceRefType, JavaWsdlMappingType mapping, List handlerInfos, QName serviceQName, SOAPConstants soapVersion, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, ClassLoader classLoader) throws DeploymentException { 206 Map exceptionMap = WSDescriptorParser.getExceptionMap(mapping); 207 208 Definition definition = schemaInfoBuilder.getDefinition(); 209 //check for consistency 210 if (definition.getServices().size() == 0) { 211 //partial wsdl 212 if (serviceRefType == null || !serviceRefType.isSetServiceCompletion()) { 213 throw new DeploymentException("Partial wsdl, but no service completion supplied"); 214 } 215 GerServiceCompletionType serviceCompletion = serviceRefType.getServiceCompletion(); 216 String serviceLocalName = serviceCompletion.getServiceName().trim(); 217 String namespace = definition.getTargetNamespace(); 218 serviceQName = new QName(namespace, serviceLocalName); 219 javax.wsdl.Service service = definition.createService(); 220 service.setQName(serviceQName); 221 GerPortCompletionType[] portCompletions = serviceCompletion.getPortCompletionArray(); 222 for (int i = 0; i < portCompletions.length; i++) { 223 GerPortCompletionType portCompletion = portCompletions[i]; 224 GerPortType port = portCompletion.getPort(); 225 URL location = getLocation(port); 226 String portName = port.getPortName().trim(); 227 String bindingName = portCompletion.getBindingName().trim(); 228 QName bindingQName = new QName(namespace, bindingName); 229 Binding binding = definition.getBinding(bindingQName); 230 if (binding == null) { 231 throw new DeploymentException("No binding found with qname: " + bindingQName); 232 } 233 String credentialsName = port.isSetCredentialsName() ? port.getCredentialsName().trim() : null; 234 mapBinding(binding, mapping, serviceQName, classLoader, soapVersion, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName, exceptionMap); 235 236 } 237 } else { 238 //full wsdl 239 if (serviceRefType != null && serviceRefType.isSetServiceCompletion()) { 240 throw new DeploymentException("Full wsdl, but service completion supplied"); 241 } 242 //organize the extra port info 243 Map portMap = new HashMap(); 244 if (serviceRefType != null) { 245 GerPortType[] ports = serviceRefType.getPortArray(); 246 for (int i = 0; i < ports.length; i++) { 247 GerPortType port = ports[i]; 248 String portName = port.getPortName().trim(); 249 portMap.put(portName, port); 250 } 251 } 252 253 //find the service we are working with 254 javax.wsdl.Service service = getService(serviceQName, schemaInfoBuilder.getDefinition()); 255 if (serviceQName == null) { 256 serviceQName = service.getQName(); 257 } 258 259 Map wsdlPortMap = service.getPorts(); 260 for (Iterator iterator = wsdlPortMap.entrySet().iterator(); iterator.hasNext();) { 261 Map.Entry entry = (Map.Entry) iterator.next(); 262 String portName = (String) entry.getKey(); 263 Port port = (Port) entry.getValue(); 264 265 GerPortType gerPort = (GerPortType) portMap.get(portName); 266 267 URL location = gerPort == null ? getAddressLocation(port) : getLocation(gerPort); 268 //skip non-soap ports 269 if (location == null) { 270 continue; 271 } 272 String credentialsName = gerPort == null || gerPort.getCredentialsName() == null ? null : gerPort.getCredentialsName().trim(); 273 274 Binding binding = port.getBinding(); 275 276 mapBinding(binding, mapping, serviceQName, classLoader, soapVersion, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName, exceptionMap); 277 } 278 } 279 } 280 281 private void mapBinding(Binding binding, JavaWsdlMappingType mapping, QName serviceQName, ClassLoader classLoader, SOAPConstants soapVersion, SchemaInfoBuilder schemaInfoBuilder, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName, Map exceptionMap) throws DeploymentException { 282 Style portStyle = getStyle(binding); 283 284 PortType portType = binding.getPortType(); 285 286 ServiceEndpointInterfaceMappingType[] endpointMappings = mapping.getServiceEndpointInterfaceMappingArray(); 287 288 289 //port type corresponds to SEI 290 List operations = portType.getOperations(); 291 OperationInfo[] operationInfos = new OperationInfo[operations.size()]; 292 if (endpointMappings.length == 0) { 293 doLightweightMapping(serviceQName, portType, mapping, classLoader, operations, binding, portStyle, soapVersion, operationInfos, schemaInfoBuilder, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName); 294 } else { 295 doHeavyweightMapping(serviceQName, portType, endpointMappings, classLoader, operations, binding, portStyle, soapVersion, exceptionMap, schemaInfoBuilder, mapping, operationInfos, portName, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName); 296 } 297 } 298 299 private URL getLocation(GerPortType port) throws DeploymentException { 300 String protocol = port.getProtocol().trim(); 301 String host = port.getHost().trim(); 302 int portNum = port.getPort(); 303 String uri = port.getUri().trim(); 304 String locationURIString = protocol + "://" + host + ":" + portNum + uri; 305 URL location; 306 try { 307 location = new URL(locationURIString); 308 } catch (MalformedURLException e) { 309 throw new DeploymentException("Could not construct web service location URL from " + locationURIString); 310 } 311 return location; 312 } 313 314 private javax.wsdl.Service getService(QName serviceQName, Definition definition) throws DeploymentException { 315 javax.wsdl.Service service; 316 if (serviceQName != null) { 317 service = definition.getService(serviceQName); 318 if (service == null) { 319 throw new DeploymentException("No service wsdl for supplied service qname " + serviceQName); 320 } 321 } else { 322 Map services = definition.getServices(); 323 if (services.size() > 1) { 324 throw new DeploymentException("no serviceQName supplied, and there are " + services.size() + " services"); 325 } 326 if (services.size() == 0) { 327 throw new DeploymentException("No service in wsdl, and no service completion supplied!"); 328 } else { 329 service = (javax.wsdl.Service) services.values().iterator().next(); 330 } 331 } 332 return service; 333 } 334 335 private Style getStyle(Binding binding) throws DeploymentException { 336 SOAPBinding soapBinding = (SOAPBinding) SchemaInfoBuilder.getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements()); 337 // String transportURI = soapBinding.getTransportURI(); 338 String portStyleString = soapBinding.getStyle(); 339 return Style.getStyle(portStyleString); 340 } 341 342 private URL getAddressLocation(Port port) throws DeploymentException { 343 SOAPAddress soapAddress; 344 try { 345 soapAddress = (SOAPAddress) SchemaInfoBuilder.getExtensibilityElement(SOAPAddress.class, port.getExtensibilityElements()); 346 } catch (DeploymentException e) { 347 //a http: protocol REST service. Skip it. 348 return null; 349 } 350 String locationURIString = soapAddress.getLocationURI(); 351 URL location; 352 try { 353 location = new URL(locationURIString); 354 } catch (MalformedURLException e) { 355 throw new DeploymentException("Could not construct web service location URL from " + locationURIString); 356 } 357 return location; 358 } 359 360 private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[] endpointMappings, ClassLoader classLoader, List operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap, SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType mapping, OperationInfo[] operationInfos, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException { 361 Class serviceEndpointInterface; 362 SEIFactory seiFactory; 363 //complete jaxrpc mapping file supplied 364 QName portTypeQName = portType.getQName(); 365 ServiceEndpointInterfaceMappingType endpointMapping = WSDescriptorParser.getServiceEndpointInterfaceMapping(endpointMappings, portTypeQName); 366 String fqcn = endpointMapping.getServiceEndpointInterface().getStringValue(); 367 try { 368 serviceEndpointInterface = classLoader.loadClass(fqcn); 369 } catch (ClassNotFoundException e) { 370 throw new DeploymentException("Could not load service endpoint interface", e); 371 } 372 // Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classLoader); 373 374 Collection operationDescs = new ArrayList(); 375 ServiceEndpointMethodMappingType[] methodMappings = endpointMapping.getServiceEndpointMethodMappingArray(); 376 int i = 0; 377 Set wrapperElementQNames = new HashSet(); 378 JavaXmlTypeMappingType[] javaXmlTypeMappings = mapping.getJavaXmlTypeMappingArray(); 379 boolean hasEncoded = false; 380 for (Iterator ops = operations.iterator(); ops.hasNext();) { 381 Operation operation = (Operation) ops.next(); 382 String operationName = operation.getName(); 383 //the obvious method seems to be buggy 384 // BindingOperation bindingOperation = binding.getBindingOperation(operationName, operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName()); 385 BindingOperation bindingOperation = null; 386 List bops = binding.getBindingOperations(); 387 for (Iterator iterator = bops.iterator(); iterator.hasNext();) { 388 BindingOperation bindingOperation1 = (BindingOperation) iterator.next(); 389 if (bindingOperation1.getOperation().equals(operation)) { 390 bindingOperation = bindingOperation1; 391 break; 392 } 393 } 394 if (bindingOperation == null) { 395 throw new DeploymentException("No BindingOperation for operation: " + operationName + ", input: " + operation.getInput().getName() + ", output: " + (operation.getOutput() == null ? "<none>" : operation.getOutput().getName())); 396 } 397 ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName, methodMappings); 398 HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation, mapping, methodMapping, portStyle, exceptionMap, schemaInfoBuilder, javaXmlTypeMappings, classLoader, serviceEndpointInterface); 399 OperationInfo operationInfo = operationDescBuilder.buildOperationInfo(soapVersion); 400 operationInfos[i++] = operationInfo; 401 operationDescs.add(operationInfo.getOperationDesc()); 402 wrapperElementQNames.addAll(operationDescBuilder.getWrapperElementQNames()); 403 hasEncoded |= operationDescBuilder.isEncoded(); 404 } 405 HeavyweightTypeInfoBuilder builder = new HeavyweightTypeInfoBuilder(classLoader, schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap(), wrapperElementQNames, operationDescs, hasEncoded); 406 List typeInfo = builder.buildTypeInfo(mapping); 407 408 seiFactory = createSEIFactory(serviceName, portName, serviceEndpointInterface.getName(), typeInfo, location, operationInfos, handlerInfos, credentialsName); 409 seiPortNameToFactoryMap.put(portName, seiFactory); 410 seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory); 411 } 412 413 private void doLightweightMapping(QName serviceName, PortType portType, JavaWsdlMappingType mapping, ClassLoader classLoader, List operations, Binding binding, Style portStyle, SOAPConstants soapVersion, OperationInfo[] operationInfos, SchemaInfoBuilder schemaInfoBuilder, String portName, URL location, List handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException { 414 Class serviceEndpointInterface; 415 SEIFactory seiFactory; 416 //lightweight jaxrpc mapping supplied 417 serviceEndpointInterface = getServiceEndpointInterfaceLightweight(portType, mapping, classLoader); 418 // Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classLoader); 419 420 int i = 0; 421 for (Iterator ops = operations.iterator(); ops.hasNext();) { 422 Operation operation = (Operation) ops.next(); 423 Method method = WSDescriptorParser.getMethodForOperation(serviceEndpointInterface, operation); 424 BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput() == null ? null : operation.getOutput().getName()); 425 operationInfos[i++] = buildOperationInfoLightweight(method, bindingOperation, portStyle, soapVersion); 426 } 427 LightweightTypeInfoBuilder builder = new LightweightTypeInfoBuilder(classLoader, schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap(), Collections.EMPTY_SET); 428 List typeInfo = builder.buildTypeInfo(mapping); 429 430 seiFactory = createSEIFactory(serviceName, portName, serviceEndpointInterface.getName(), typeInfo, location, operationInfos, handlerInfos, credentialsName); 431 seiPortNameToFactoryMap.put(portName, seiFactory); 432 seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory); 433 } 434 435 private Class getServiceEndpointInterfaceLightweight(PortType portType, JavaWsdlMappingType mappings, ClassLoader classLoader) throws DeploymentException { 436 QName portTypeQName = portType.getQName(); 437 String portTypeNamespace = portTypeQName.getNamespaceURI(); 438 String portTypePackage = WSDescriptorParser.getPackageFromNamespace(portTypeNamespace, mappings); 439 StringBuffer shortInterfaceName = new StringBuffer(portTypeQName.getLocalPart()); 440 shortInterfaceName.setCharAt(0, Character.toUpperCase(shortInterfaceName.charAt(0))); 441 //TODO just use one buffer! 442 String fqcn = portTypePackage + "." + shortInterfaceName.toString(); 443 try { 444 return classLoader.loadClass(fqcn); 445 } catch (ClassNotFoundException e) { 446 throw new DeploymentException("Could not load service endpoint interface type", e); 447 } 448 } 449 450 451 public SEIFactory createSEIFactory(QName serviceName, String portName, String enhancedServiceEndpointClassName, List typeInfo, URL location, OperationInfo[] operationInfos, List handlerInfoInfos, String credentialsName) throws DeploymentException { 452 List handlerInfos = buildHandlerInfosForPort(portName, handlerInfoInfos); 453 return new SEIFactoryImpl(serviceName, portName, enhancedServiceEndpointClassName, operationInfos, typeInfo, location, handlerInfos, credentialsName); 454 } 455 456 private List buildHandlerInfosForPort(String portName, List handlerInfoInfos) { 457 List handlerInfos = new ArrayList(); 458 for (Iterator iterator = handlerInfoInfos.iterator(); iterator.hasNext();) { 459 HandlerInfoInfo handlerInfoInfo = (HandlerInfoInfo) iterator.next(); 460 Set portNames = handlerInfoInfo.getPortNames(); 461 if (portNames.isEmpty() || portNames.contains(portName)) { 462 HandlerInfo handlerInfo = new HandlerInfo(handlerInfoInfo.getHandlerClass(), handlerInfoInfo.getHandlerConfig(), handlerInfoInfo.getSoapHeaders()); 463 handlerInfos.add(handlerInfo); 464 465 //TODO what about the soap roles?? 466 } 467 } 468 return handlerInfos; 469 } 470 471 public OperationInfo buildOperationInfoLightweight(Method method, BindingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersion) throws DeploymentException { 472 LightweightOperationDescBuilder operationDescBuilder = new LightweightOperationDescBuilder(bindingOperation, method); 473 return operationDescBuilder.buildOperationInfo(soapVersion); 474 } 475 476 477 public static final GBeanInfo GBEAN_INFO; 478 479 static { 480 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AxisBuilder.class, NameFactory.MODULE_BUILDER); 481 infoBuilder.addInterface(WebServiceBuilder.class); 482 infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true); 483 484 infoBuilder.setConstructor(new String[] {"defaultEnvironment"}); 485 486 GBEAN_INFO = infoBuilder.getBeanInfo(); 487 } 488 489 public static GBeanInfo getGBeanInfo() { 490 return GBEAN_INFO; 491 } 492 493 }