--- org/jboss/webservice/metadata/WebserviceDescriptionMetaData.java.orig 2004-11-16 17:12:22.000000000 +0530 +++ org/jboss/webservice/metadata/WebserviceDescriptionMetaData.java 2005-01-25 17:24:30.000000000 +0530 @@ -236,67 +236,65 @@ */ private void replaceAddressLocations(Definition wsdlDefinition, ServiceDeployer.ServiceLocationResolver locationResolver) { - if (wsdlDefinition.getServices().size() != 1) - throw new IllegalArgumentException("Unsupported number of service elements in wsdl document"); - - // process all webservice-description(s) that use the same wsdl-file - WebserviceDescriptionMetaData[] wsdArr = webservices.getWebserviceDescriptions(); - for (int i = 0; i < wsdArr.length; i++) - { - WebserviceDescriptionMetaData wsdMetaData = wsdArr[i]; - if (wsdlFile.equals(wsdMetaData.wsdlFile)) - { - Service wsdlService = (Service)wsdlDefinition.getServices().values().iterator().next(); - - PortComponentMetaData[] pcarr = wsdMetaData.getPortComponents(); - for (int pcIndex = 0; pcIndex < pcarr.length; pcIndex++) - { - PortComponentMetaData portComponent = pcarr[pcIndex]; - String pcWsdlPortName = portComponent.getWsdlPort().getLocalPart(); - Port wsdlPort = null; - - Map wsdlPorts = wsdlService.getPorts(); - Iterator it = wsdlPorts.keySet().iterator(); - while (wsdlPort == null && it.hasNext()) + // process all webservice-description(s) that use the same wsdl-file + WebserviceDescriptionMetaData[] wsdArr = webservices.getWebserviceDescriptions(); + for (int i = 0; i < wsdArr.length; i++) + { + WebserviceDescriptionMetaData wsdMetaData = wsdArr[i]; + if (wsdlFile.equals(wsdMetaData.wsdlFile)) + { + Iterator serviceIt = wsdlDefinition.getServices().values().iterator(); + while (serviceIt.hasNext()) { - String wsdlPortName = (String)it.next(); - if (wsdlPortName.equals(pcWsdlPortName)) - { - wsdlPort = (Port)wsdlPorts.get(wsdlPortName); - Iterator itElements = wsdlPort.getExtensibilityElements().iterator(); - while (itElements.hasNext()) - { - Object obj = itElements.next(); - if (obj instanceof SOAPAddress) - { - SOAPAddress address = (SOAPAddress)obj; - String wsdlURI = address.getLocationURI(); - - String schema = null; - if (wsdlURI.startsWith("http://") || wsdlURI.startsWith("https://")) - schema = wsdlURI.substring(0, wsdlURI.indexOf("://") + 3); + Service wsdlService = (Service)serviceIt.next(); - String urlString = locationResolver.getServiceLocation(schema, portComponent); - try - { - portComponent.setServiceEndpointURL(new URL(urlString)); - log.debug("Replace port location '" + wsdlURI + "' with '" + urlString + "'"); - address.setLocationURI(urlString); - } - catch (MalformedURLException e) + PortComponentMetaData[] pcarr = wsdMetaData.getPortComponents(); + for (int pcIndex = 0; pcIndex < pcarr.length; pcIndex++) + { + PortComponentMetaData portComponent = pcarr[pcIndex]; + String pcWsdlPortName = portComponent.getWsdlPort().getLocalPart(); + Port wsdlPort = null; + + Map wsdlPorts = wsdlService.getPorts(); + Iterator it = wsdlPorts.keySet().iterator(); + while (wsdlPort == null && it.hasNext()) + { + String wsdlPortName = (String)it.next(); + if (wsdlPortName.equals(pcWsdlPortName)) { - log.error("Invalid service URL: " + urlString); + wsdlPort = (Port)wsdlPorts.get(wsdlPortName); + Iterator itElements = wsdlPort.getExtensibilityElements().iterator(); + while (itElements.hasNext()) + { + Object obj = itElements.next(); + if (obj instanceof SOAPAddress) + { + SOAPAddress address = (SOAPAddress)obj; + String wsdlURI = address.getLocationURI(); + + String schema = null; + if (wsdlURI.startsWith("http://") || wsdlURI.startsWith("https://")) + schema = wsdlURI.substring(0, wsdlURI.indexOf("://") + 3); + + String urlString = locationResolver.getServiceLocation(schema, portComponent); + try + { + portComponent.setServiceEndpointURL(new URL(urlString)); + log.debug("Replace port location '" + wsdlURI + "' with '" + urlString + "'"); + address.setLocationURI(urlString); + } + catch (MalformedURLException e) + { + log.error("Invalid service URL: " + urlString); + } + } + } } - } - } - } + } + } } - - if (wsdlPort == null) - throw new IllegalArgumentException("Cannot find port with name '" + pcWsdlPortName + "' in wsdl document"); - } - } - } + } + } } /** --- org/jboss/webservice/AxisService.java.orig 2004-11-27 12:58:46.000000000 +0530 +++ org/jboss/webservice/AxisService.java 2005-01-25 16:59:58.000000000 +0530 @@ -32,6 +32,7 @@ import javax.management.ObjectName; import javax.wsdl.Definition; +import javax.wsdl.Service; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -47,6 +48,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Collection; /** * A service that keeps track of the Axis server and client engine @@ -493,14 +495,38 @@ // build the ServiceDescr from wsdl + jaxrpc-mapping Definition wsdlDefinition = wsdMetaData.getWsdlDefinition(); + String serviceName = getService(wsdlDefinition, portName); + // Find the optional optional ws4ee-deployment.xml URL ws4eeMetaData = findTypeMappingMetaData(di); - ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, portName); + ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, serviceName, portName); return serviceDesc; } - /** + /** + * Method to return the Service Name given the port and wsdl + * @param wsdlDefinition + * @param portName + * @return + */ + private String getService(Definition wsdlDefinition, String portName) + { + String serviceName = null; + Map services = wsdlDefinition.getServices(); + Collection service = services.values(); + for (Iterator iterator = service.iterator(); iterator.hasNext();) + { + Service thisService = (Service) iterator.next(); + if (thisService.getPort(portName) != null) + { + serviceName = thisService.getQName().getLocalPart(); + } + } + return serviceName; + } + + /** * Write the generated axis wsdd to the given print writer */ private String generateDeploymentWSDD(PortComponentInfo pcInfo) throws Exception --- org/jboss/webservice/deployment/ServiceDescription.java.orig 2004-11-27 12:58:47.000000000 +0530 +++ org/jboss/webservice/deployment/ServiceDescription.java 2005-01-25 16:59:45.000000000 +0530 @@ -96,10 +96,10 @@ /** * Construct the service description from a given wsdl and jaxrpc-mapping.xml */ - public ServiceDescription(Definition wsdlDefinition, JavaWsdlMapping javaMapping, URL ws4eeMetaData, String portName) throws ServiceException + public ServiceDescription(Definition wsdlDefinition, JavaWsdlMapping javaMapping, URL ws4eeMetaData, String serviceName, String portName) throws ServiceException { this.wsdlDefinition = wsdlDefinition; - this.wsdlService = getWsdlService(wsdlDefinition, portName); + this.wsdlService = getWsdlService(wsdlDefinition, serviceName); this.wsdlBinding = getWsdlBinding(wsdlService, portName); this.javaWsdlMapping = javaMapping; @@ -118,7 +118,7 @@ wsdlFactory.setFeature(WSDLDefinitionFactory.FEATURE_VERBOSE, true); this.wsdlDefinition = wsdlFactory.parse(wsdlLocation); - this.wsdlService = getWsdlService(wsdlDefinition, portName); + this.wsdlService = getWsdlService(wsdlDefinition, null, portName); this.wsdlBinding = getWsdlBinding(wsdlService, portName); if (jaxrpcLocation != null) @@ -932,38 +932,64 @@ return packageName; } + /** + * Get the wsdl service that corresponds to the portName + * If portName is null, it assumes there is only one service. + * The second argument is for Service Name + */ + private Service getWsdlService(Definition wsdlDefinition, String tmp, String portName) + { + Service wsdlService = null; + + if (portName == null) + { + if (wsdlDefinition.getServices().values().size() != 1) + throw new IllegalArgumentException("Unsupported number of service elements"); + + wsdlService = (Service)wsdlDefinition.getServices().values().iterator().next(); + } + else + { + Iterator it = wsdlDefinition.getServices().values().iterator(); + while (wsdlService == null && it.hasNext()) + { + Service service = (Service)it.next(); + if (service.getPort(portName) != null) + wsdlService = service; + } + } + + if (wsdlService == null) + throw new IllegalArgumentException("Cannot find wsdl service for port: " + portName); + + return wsdlService; + } + + /** + * Get the wsdl service that corresponds to the serviceName + */ + private Service getWsdlService(Definition wsdlDefinition, String serviceName) + { + Service wsdlService = null; + + if (serviceName == null) + throw new IllegalArgumentException("WSDL Service Name cannot be blank"); + + Iterator it = wsdlDefinition.getServices().values().iterator(); + while (it.hasNext()) + { + Service service = (Service) it.next(); + if (service.getQName().getLocalPart().equals(serviceName)) + { + wsdlService = service; + } + } - /** - * Get the wsdl service that corresponds to the portName - * If portName is null, it assumes there is only one service. - */ - private Service getWsdlService(Definition wsdlDefinition, String portName) - { - Service wsdlService = null; - - if (portName == null) - { - if (wsdlDefinition.getServices().values().size() != 1) - throw new IllegalArgumentException("Unsupported number of service elements"); - - wsdlService = (Service)wsdlDefinition.getServices().values().iterator().next(); - } - else - { - Iterator it = wsdlDefinition.getServices().values().iterator(); - while (wsdlService == null && it.hasNext()) - { - Service service = (Service)it.next(); - if (service.getPort(portName) != null) - wsdlService = service; - } - } - - if (wsdlService == null) - throw new IllegalArgumentException("Cannot find wsdl service for port: " + portName); + if (wsdlService == null) + throw new IllegalArgumentException("Cannot find wsdl service for name: " + serviceName); - return wsdlService; - } + return wsdlService; + } /** --- org/jboss/webservice/client/ServiceFactoryImpl.java.orig 2004-07-20 19:18:52.000000000 +0530 +++ org/jboss/webservice/client/ServiceFactoryImpl.java 2005-01-25 17:00:29.000000000 +0530 @@ -117,7 +117,7 @@ Definition wsdlDefinition = factory.parse(wsdlDocumentLocation); // In this case we have no jaxrpc-mapping.xml - ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, null, null, null); + ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, null, null,serviceName.getLocalPart(), null); service.initService(serviceDesc, null); } catch (Exception e) @@ -158,7 +158,7 @@ javaWsdlMapping = mappingFactory.parse(mappingLocation); } - ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, portName); + ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, null, portName); service.initService(serviceDesc, portName); } catch (Exception e) --- org/jboss/webservice/client/ServiceObjectFactory.java.orig 2004-11-16 17:12:21.000000000 +0530 +++ org/jboss/webservice/client/ServiceObjectFactory.java 2005-01-25 17:00:43.000000000 +0530 @@ -185,7 +185,7 @@ for (Iterator j = portNames.iterator(); j.hasNext();) { String portName = (String)j.next(); - ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, portName); + ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, wsdlService.getQName().getLocalPart(),portName); serviceDesc.setCallProperties(pcRef.getCallProperties()); jaxrpcService.initService(serviceDesc, portName); } @@ -194,7 +194,7 @@ else { // There are zero port-component-ref elements, use the single possible port binding - ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, null); + ServiceDescription serviceDesc = new ServiceDescription(wsdlDefinition, javaWsdlMapping, ws4eeMetaData, wsdlService.getQName().getLocalPart(), null); jaxrpcService.initService(serviceDesc, null); }