Author: kurtstam
Date: 2011-06-07 10:34:12 -0400 (Tue, 07 Jun 2011)
New Revision: 1373
Added:
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/JBossURLLocalizer.java
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java
Log:
RIFTSAW-358 - registration of BPEL processes according to OASIS technote
'uddi-spec-tc-tn-bpel-20040725'
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java 2011-06-07
14:32:54 UTC (rev 1372)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java 2011-06-07
14:34:12 UTC (rev 1373)
@@ -23,6 +23,7 @@
import java.net.URL;
+import javax.wsdl.Definition;
import javax.xml.namespace.QName;
import org.jboss.soa.dsp.ws.WSDLReference;
@@ -32,7 +33,7 @@
* @author Kurt T Stam <kurt.stam(a)jboss.com>
*
*/
-public interface UDDIRegistration {
+public interface UDDIRegistration {
/**
* Registers a BPEL ServiceEndpointReference (EPR) into a UDDI registry using the jUDDI
client code.
* If the serviceKey does not already exist we register the service along with the EPR.
@@ -41,17 +42,28 @@
* @param metaData
* @param wsdlRef
*/
- public void registerEPR(String serviceName, String portName, URL accessUrl);
+ public void registerBPELProcess(QName serviceName, String version, String portName,
+ URL accessUrl, URL wsdlUrl, Definition definition);
/**
* UnRegisters the binding from the UDDI Registry.
* @param QName of the service
* @param port name
*/
- public void unRegisterEPR(QName service, String port);
+ public void unRegisterBPELEPR(QName service, String port, URL accessUrl);
/**
*
* @param service
* @param port
*/
public WSDLReference lookupWSDL(QName serviceQName, String portName);
+ /**
+ *
+ * @param service
+ * @param port
+ */
+ public String lookupEndpoint(QName serviceQName, String portName);
+ /**
+ * Call shutdown to release all resources held by the UDDI client.
+ */
+ public void shutdown() throws Exception;
}
Added: trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/JBossURLLocalizer.java
===================================================================
--- trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/JBossURLLocalizer.java
(rev 0)
+++
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/JBossURLLocalizer.java 2011-06-07
14:34:12 UTC (rev 1373)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.bpel.uddi;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.mapping.URLLocalizer;
+import org.jboss.soa.bpel.runtime.JBossDSPFactory;
+import org.jboss.soa.bpel.runtime.engine.ode.BPELEngineImpl;
+import org.jboss.soa.dsp.server.ServerConfig;
+
+/**
+ *
+ * * @author Kurt T Stam <kurt.stam(a)jboss.com>
+ *
+ */
+public class JBossURLLocalizer implements URLLocalizer {
+
+ protected static final Log log = LogFactory.getLog(JBossURLLocalizer.class);
+ private Properties properties = new Properties();
+
+ public JBossURLLocalizer(Properties properties) {
+ super();
+ this.properties = properties;
+ }
+
+ /**
+ *
+ * @param urlIn
+ * @return
+ */
+ public String rewriteToWSDLURL(URL url) {
+ return getWebserviceBaseUrl() + "/" + url.getPath() + "?wsdl";
+ }
+ /**
+ *
+ * @param urlIn
+ * @return
+ */
+ public String rewrite(URL url) {
+ return getWebserviceBaseUrl() + "/" + url.getPath();
+ }
+ /**
+ *
+ * @return
+ */
+ private String getWebserviceBaseUrl() {
+ String url = properties.getProperty(BPELEngineImpl.BPEL_WEBSERVICE_BASEURL);
+ if (url != null) {
+ return url;
+ }
+ return getDefaultWebServiceBaseUrl();
+ }
+
+ private String getDefaultWebServiceBaseUrl() {
+ try {
+ ServerConfig serverConfig=JBossDSPFactory.getServerConfig();
+ String webServiceHost = serverConfig.getWebServiceHost();
+ int webServicePort = serverConfig.getWebServicePort();
+ URL theURL = new URL("http://" + webServiceHost + ":" +
webServicePort);
+ if (Boolean.valueOf(properties.getProperty(BPELEngineImpl.BPEL_WEBSERVICE_SECURE,
"false"))) {
+ int secureWebServicePort = serverConfig.getWebServicePort();
+ theURL = new URL("https://" + webServiceHost + ":" +
secureWebServicePort);
+ }
+ return theURL.toExternalForm();
+ } catch (MalformedURLException e) {
+ log.error("Error in constructing the webservice base url.", e);
+ return null;
+ }
+ }
+}
Modified:
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java
===================================================================
---
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java 2011-06-07
14:32:54 UTC (rev 1372)
+++
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java 2011-06-07
14:34:12 UTC (rev 1373)
@@ -21,49 +21,28 @@
*/
package org.jboss.soa.bpel.uddi;
-import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.juddi.api_v3.AccessPointType;
import org.apache.juddi.v3.annotations.AnnotationProcessor;
-import org.apache.juddi.v3.client.config.TokenResolver;
import org.apache.juddi.v3.client.config.UDDIClerk;
import org.apache.juddi.v3.client.config.UDDIClerkManager;
-import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3.client.mapping.BPEL2UDDI;
+import org.apache.juddi.v3.client.mapping.ServiceLocator;
+import org.apache.juddi.v3.client.mapping.URLLocalizer;
import org.apache.juddi.v3.client.transport.TransportException;
-import org.jboss.soa.bpel.runtime.engine.ode.UDDIRegistration;
-import org.jboss.soa.bpel.runtime.ws.WebServiceClient;
-import org.jboss.soa.dsp.server.ServerConfig;
import org.jboss.soa.bpel.runtime.JBossDSPFactory;
+import org.jboss.soa.bpel.runtime.engine.ode.UDDIRegistration;
import org.jboss.soa.dsp.ws.WSDLReference;
-import org.uddi.api_v3.AccessPoint;
import org.uddi.api_v3.BindingTemplate;
-import org.uddi.api_v3.BindingTemplates;
-import org.uddi.api_v3.BusinessService;
-import org.uddi.api_v3.CategoryBag;
-import org.uddi.api_v3.Description;
-import org.uddi.api_v3.FindQualifiers;
-import org.uddi.api_v3.FindService;
-import org.uddi.api_v3.GetAuthToken;
-import org.uddi.api_v3.Name;
-import org.uddi.api_v3.ServiceInfo;
-import org.uddi.api_v3.ServiceList;
-import org.uddi.api_v3.TModelInstanceDetails;
-import org.uddi.api_v3.TModelInstanceInfo;
-import org.uddi.v3_service.DispositionReportFaultMessage;
/**
*
@@ -73,77 +52,55 @@
public class UDDIRegistrationImpl extends AnnotationProcessor implements UDDIRegistration
{
protected static final Log log = LogFactory.getLog(UDDIRegistrationImpl.class);
- private final static String BPEL_UDDI_CLERK_MANAGER =
"bpel.uddi.clerk.manager";
private final static String BPEL_UDDI_CLERK = "bpel.uddi.clerk";
private final static String BPEL_UDDI_CONFIG = "bpel.uddi.config";
- private final static String DEFAULT_BPEL_UDDI_CLERK_MANAGER = "esb.manager";
private final static String DEFAULT_BPEL_UDDI_CLERK = "BPELClerk";
- private Properties properties = new Properties();
+
UDDIClerk bpelClerk = null;
+ boolean selfRegister = false;
+ BPEL2UDDI bpel2UDDI = null;
+ ServiceLocator serviceLocator = null;
+ Properties properties = null;
- public static final String DEFAULT_SERVICE_KEY_FORMAT =
"uddi:${keyDomain}:bpel-services-";
- public static final String DEFAULT_BINDING_KEY_FORMAT =
"uddi:${keyDomain}:bindings-${nodeName}-";
- //Can be set in the uddi.xml property section
- public static final String LANG = "lang";
- public static final String SERVICE_DESCRIPTION =
"serviceDescription";
- public static final String SERVICE_CATEGORY_BAG =
"serviceCategoryBag";
- public static final String BINDING_DESCRIPTION =
"bindingDescription";
- public static final String BINDING_CATEGORY_BAG =
"bindingCategoryBag";
- public static final String BINDING_TMODEL_KEYS =
"bindingTModelKeys";
- public static final String SERVICE_KEY_FORMAT = "serviceKeyFormat";
- public static final String BINDING_KEY_FORMAT = "bindingKeyFormat";
-
- private String clerkManagerName = null;
-
-
public UDDIRegistrationImpl(Properties properties) {
super();
- this.properties = properties;
- String bpelUDDIConfig = getBPELUDDIConfig();
+
+ properties.put("nodeName",
JBossDSPFactory.getServerConfig().getUddiNodeName());
+ String bpelUDDIConfig = properties.getProperty(BPEL_UDDI_CONFIG);
if (bpelUDDIConfig!=null) {
try {
UDDIClerkManager clerkManager = new UDDIClerkManager(bpelUDDIConfig);
clerkManager.start();
- clerkManagerName = clerkManager.getName();
+ selfRegister = clerkManager.getClientConfig().isRegisterOnStartup();
+ Map<String,UDDIClerk> clerks =
clerkManager.getClientConfig().getUDDIClerks();
+ String clerkName = properties.getProperty(BPEL_UDDI_CLERK,
DEFAULT_BPEL_UDDI_CLERK);
+ bpelClerk = clerks.get(clerkName);
+ //Add the properties from the uddi.xml
+ properties.putAll(bpelClerk.getUDDINode().getProperties());
+ if (bpelClerk==null) {
+ throw new ConfigurationException("Could not find UDDI Clerk named "+
bpelClerk.getName());
+ }
+ this.properties = properties;
+ URLLocalizer urlLocalizer = new JBossURLLocalizer(properties);
+ bpel2UDDI = new BPEL2UDDI(bpelClerk, urlLocalizer, properties);
+ serviceLocator = new ServiceLocator(bpelClerk, urlLocalizer, properties);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
} else {
- log.debug("Using jbossesb.sar/esb.uddi.client.xml");
+ log.error("The 'bpel.uddi.config' property must be defined in the
bpel.properties file");
}
}
-
- private String getBPELUDDIConfig() {
- return (properties.getProperty(BPEL_UDDI_CONFIG));
- }
- private String getClerkManagerName() {
- if (clerkManagerName!=null) {
- log.debug("ClerkManagerName is " + clerkManagerName);
- return clerkManagerName;
- } else {
- String clerkManager = (properties.getProperty(BPEL_UDDI_CLERK_MANAGER,
DEFAULT_BPEL_UDDI_CLERK_MANAGER));
- log.debug("ClerkManagerName is " + clerkManager);
- return clerkManager;
- }
+ /**
+ * Releasing the resources we are holding (such as the subscriptionListener in the
UDDIServiceCache).
+ * @throws TransportException
+ * @throws ConfigurationException
+ * @throws RemoteException
+ */
+ public void shutdown() throws Exception {
+ serviceLocator.shutdown();
}
-
- private String getClerkName() {
- return (properties.getProperty(BPEL_UDDI_CLERK, DEFAULT_BPEL_UDDI_CLERK));
- }
-
- private synchronized UDDIClerk getBPELClerk() throws ConfigurationException {
- if (bpelClerk==null) {
- UDDIClerkManager clerkManager =
UDDIClientContainer.getUDDIClerkManager(getClerkManagerName());
- Map<String,UDDIClerk> clerks = clerkManager.getClientConfig().getUDDIClerks();
- bpelClerk = clerks.get(getClerkName());
- if (bpelClerk==null) {
- throw new ConfigurationException("Could not find UDDI Clerk named "+
getClerkName());
- }
- }
- return bpelClerk;
- }
-
/**
* Registers a BPEL ServiceEndpointReference (EPR) into a UDDI registry using the jUDDI
client code.
* If the serviceKey does not already exist we register the service along with the EPR.
@@ -152,36 +109,23 @@
* @param metaData
* @param wsdlRef
*/
- public void registerEPR(String serviceName, String portName, URL accessUrl) {
- boolean selfRegister = false;
- try {
- UDDIClerkManager clerkManager =
UDDIClientContainer.getUDDIClerkManager(getClerkManagerName());
- selfRegister = clerkManager.getClientConfig().isRegisterOnStartup();
- if (selfRegister) {
- Map<String,UDDIClerk> clerks = clerkManager.getClientConfig().getUDDIClerks();
- UDDIClerk bpelClerk = clerks.get(getClerkName());
- if (bpelClerk!=null) {
- try {
- BusinessService service = createBusinessService(bpelClerk, serviceName, portName,
accessUrl);
- bpelClerk.register(service, bpelClerk.getUDDINode().getApiNode());
- } catch (Exception e) {
- log.error("Unable to register service " + serviceName
- + " ." + e.getMessage(),e);
- } catch (Throwable t) {
- log.error("Unable to register service " + serviceName
- + " ." + t.getMessage(),t);
- }
- } else {
- throw new ConfigurationException("Could not find UDDI Clerk named "+
getClerkName());
- }
+ public void registerBPELProcess(QName serviceName, String version, String portName, URL
serviceUrl,
+ URL wsdlURL, Definition wsdlDefinition) {
+ if (selfRegister) {
+
+ try {
+ BindingTemplate binding = bpel2UDDI.register(serviceName, portName, serviceUrl,
wsdlDefinition);
+ serviceLocator.addService(binding.getServiceKey());
+ } catch (Exception e) {
+ log.error("Unable to register service " + serviceName
+ + " ." + e.getMessage(),e);
+ } catch (Throwable t) {
+ log.error("Unable to register service " + serviceName
+ + " ." + t.getMessage(),t);
}
- } catch (ConfigurationException ce) {
- if (selfRegister) {
- log.error(ce.getMessage(),ce);
- } else {
- log.info(ce.getMessage());
- }
+
}
+
}
/**
* UnRegisters the binding from the UDDI Registry.
@@ -189,351 +133,33 @@
* @param metaData
* @param wsdlRef
*/
- public void unRegisterEPR(QName service, String port) {
- boolean selfRegister = false;
- try {
- UDDIClerkManager clerkManager =
UDDIClientContainer.getUDDIClerkManager(getClerkManagerName());
- selfRegister = clerkManager.getClientConfig().isRegisterOnStartup();
- if (selfRegister) {
- Map<String,UDDIClerk> clerks = clerkManager.getClientConfig().getUDDIClerks();
- UDDIClerk bpelClerk = clerks.get(getClerkName());
- String bindingName = service.getLocalPart() + "-" + port;
- if (bpelClerk!=null) {
- try {
- Properties properties = bpelClerk.getUDDINode().getProperties();
- properties.put("nodeName",
JBossDSPFactory.getServerConfig().getUddiNodeName());
- //Constructing the bindingKey
- String bindingKey = TokenResolver.replaceTokens(DEFAULT_BINDING_KEY_FORMAT +
bindingName, properties);
- if (properties.containsKey(BINDING_KEY_FORMAT)) {
- bindingKey =
TokenResolver.replaceTokens((String)properties.get(BINDING_KEY_FORMAT) + bindingName,
properties);
- }
- bindingKey = bindingKey.toLowerCase();
- try {
- boolean isRemoveServiceIfNoTemplates = true; //we can make this configurable if
needed.
- if (isRemoveServiceIfNoTemplates) {
- BindingTemplate bindingTemplate = bpelClerk.findServiceBinding(bindingKey,
bpelClerk.getUDDINode().getApiNode());
- BusinessService businessService =
bpelClerk.findService(bindingTemplate.getServiceKey(),
bpelClerk.getUDDINode().getApiNode());
- if (businessService.getBindingTemplates().getBindingTemplate().size()==1
&&
- businessService.getBindingTemplates().getBindingTemplate().get(0).getBindingKey().equals(bindingKey))
{
- log.info("info removing service " + businessService.getServiceKey() +
"from UDDI.");
- bpelClerk.unRegisterService(businessService.getServiceKey(),bpelClerk.getUDDINode().getApiNode());
- } else {
- log.info("info removing binding " + bindingKey + "from
UDDI.");
- bpelClerk.unRegisterBinding(bindingKey, bpelClerk.getUDDINode().getApiNode());
- }
- } else {
- log.info("info removing binding " + bindingKey + "from
UDDI.");
- bpelClerk.unRegisterBinding(bindingKey, bpelClerk.getUDDINode().getApiNode());
- }
- } catch (Exception e) {
- log.warn("Could not unRegister BindingTemplate with key " +
bindingKey);
- }
- } catch (Exception e) {
- log.error("Unable to unRegister EPR " + bindingName
- + " ." + e.getMessage(),e);
- } catch (Throwable t) {
- log.error("Unable to unRegister EPR " + bindingName
- + " ." + t.getMessage(),t);
- }
- } else {
- throw new ConfigurationException("Could not find UDDI Clerk named "+
getClerkName());
- }
+ public void unRegisterBPELEPR(QName serviceName, String portName, URL serviceURL) {
+ if (selfRegister) {
+ try {
+ String serviceKey = bpel2UDDI.unRegister(serviceName, portName, serviceURL);
+ serviceLocator.removeService(serviceKey);
+ } catch (Exception e) {
+ log.error("Unable to unRegister EPR for " + serviceName
+ + " ." + e.getMessage(),e);
+ } catch (Throwable t) {
+ log.error("Unable to unRegister EPR for " + serviceName
+ + " ." + t.getMessage(),t);
}
- } catch (ConfigurationException ce) {
- if (selfRegister) {
- log.error(ce.getMessage(),ce);
- } else {
- log.info(ce.getMessage());
- }
}
}
- private BusinessService createBusinessService(UDDIClerk clerk,
- String serviceName, String portName, URL accessUrl)
- throws DispositionReportFaultMessage, RemoteException, ConfigurationException,
TransportException {
- Properties properties = clerk.getUDDINode().getProperties();
- properties.put("nodeName",
JBossDSPFactory.getServerConfig().getUddiNodeName());
-
- //Constructing the serviceKey
- String serviceKey = TokenResolver.replaceTokens(DEFAULT_SERVICE_KEY_FORMAT +
serviceName, properties);
- if (properties.containsKey(SERVICE_KEY_FORMAT)) {
- serviceKey = TokenResolver.replaceTokens((String)properties.get(SERVICE_KEY_FORMAT) +
serviceName, properties);
- }
- BusinessService service = null;
- try {
- //Checking if this serviceKey already exist
- service = clerk.findService(serviceKey, clerk.getUDDINode().getApiNode());
- if (service==null) {
- service = createBusinessService(serviceName, serviceKey, properties);
- } else {
- log.debug("Service " + serviceName + " already present in the UDDI
Registry");
- }
- } catch (Exception e) {
-
- //This is here to support the jUDDI-client code prior to 3.0.3 where an
- //exception was thrown when a service was not found.
- //DEPRECATED, please remove when older jUDDI-client versions are no longer supported.
- service = createBusinessService(serviceName, serviceKey, properties);
- }
- //Construct bindingTemplate
- BindingTemplate binding = createBindingTemplate(clerk, serviceName, portName,
accessUrl);
- //Add the bindingTemplate on the service
- if (service.getBindingTemplates()==null) {
- BindingTemplates bindingTemplates = new BindingTemplates();
- service.setBindingTemplates(bindingTemplates);
- }
- service.getBindingTemplates().getBindingTemplate().add(binding);
- return service;
+ public String lookupEndpoint(QName serviceQName, String portName) {
+ return serviceLocator.lookupEndpoint(serviceQName, portName);
}
- private BusinessService createBusinessService(String serviceName, String serviceKey,
Properties properties) {
- //If it does not exist construct service information
- log.debug("Constructing Service UDDI Information for " + serviceName);
- BusinessService service = new BusinessService();
- service.setBusinessKey(TokenResolver.replaceTokens("uddi:${keyDomain}:${businessKey}",
properties));
- service.setServiceKey(serviceKey);
- String lang = "en";
- if (properties.containsKey(SERVICE_DESCRIPTION)) {
- Description description = new Description();
- if (properties.containsKey(LANG)) lang = properties.getProperty(LANG);
- description.setLang(lang);
- description.setValue(properties.getProperty(SERVICE_DESCRIPTION));
- service.getDescription().add(description);
- }
- Name sName = new Name();
- sName.setLang(lang);
- sName.setValue(serviceName);
- service.getName().add(sName);
- //default categoryBag on the binding
- if (properties.containsKey(SERVICE_CATEGORY_BAG)) {
- String defaultCategoryBag = properties.getProperty(SERVICE_CATEGORY_BAG);
- log.info("Adding categoryBag: " + defaultCategoryBag);
- CategoryBag categoryBag = parseCategoryBag(defaultCategoryBag);
- service.setCategoryBag(categoryBag);
- }
- return service;
- }
-
- private BindingTemplate createBindingTemplate(UDDIClerk clerk,
- String serviceName, String portName, URL accessURL) {
-
- Properties properties = clerk.getUDDINode().getProperties();
- BindingTemplate bindingTemplate = new BindingTemplate();
-
- //Constructing the bindingKey
- String bindingKey = TokenResolver.replaceTokens(DEFAULT_BINDING_KEY_FORMAT +
serviceName + "-"
- + portName, properties);
- if (properties.containsKey(BINDING_KEY_FORMAT)) {
- bindingKey = TokenResolver.replaceTokens((String)properties.get(BINDING_KEY_FORMAT) +
serviceName + "-"
- + portName, properties);
- }
-
- bindingTemplate.setBindingKey(bindingKey);
-
- String lang = "en";
- if (properties.containsKey(LANG)) lang = properties.getProperty(LANG);
- if (properties.containsKey(BINDING_DESCRIPTION)) {
- Description bindingDescription = new Description();
- bindingDescription.setLang(lang);
- bindingDescription.setValue(properties.getProperty(BINDING_DESCRIPTION));
- bindingTemplate.getDescription().add(bindingDescription);
- }
-
- AccessPoint accessPoint = new AccessPoint();
- accessPoint.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString());
- accessURL = rewriteWSDLURL(accessURL);
- accessPoint.setValue(accessURL.toExternalForm());
- bindingTemplate.setAccessPoint(accessPoint);
-
- //default tModelKeys on the binding
- String defaultTModelKeys = properties.getProperty("tModelKeys");
- if (defaultTModelKeys!=null && !"".equals(defaultTModelKeys)) {
- String[] tModelKeys= defaultTModelKeys.split(",");
- for (String tModelKey : tModelKeys) {
- TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
- instanceInfo.setTModelKey(tModelKey);
- if (bindingTemplate.getTModelInstanceDetails()==null) {
- bindingTemplate.setTModelInstanceDetails(new TModelInstanceDetails());
- }
- bindingTemplate.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);
- }
- }
- //default categoryBag on the binding
- String defaultCategoryBag = properties.getProperty("bindingCategoryBag");
- if (defaultCategoryBag!=null && !"".equals(defaultCategoryBag)) {
- log.info("Adding categoryBag: " + defaultCategoryBag);
- CategoryBag categoryBag = parseCategoryBag(defaultCategoryBag);
- bindingTemplate.setCategoryBag(categoryBag);
- }
-
- return bindingTemplate;
- }
-
/**
- * Looks up the WSDL for the requested service and portName. The BPELClerk
- * is used to lookup the service in the UDDI Registry by ServiceName. For
- * each Service, it will loop over the BindingTemplates. If a BindingTemplate
- * is found containing an AccessPointType of "wsdlDeployment" then this
- * URL is used to obtain the WSDL. If successful the WSDLReference is returned,
- * if not successful the next bindingTemplate is tried. A null result will be
- * returned if none of the attempts are successful.
+ * Looks up the WSDL for the requested service and portName.
*/
public WSDLReference lookupWSDL(QName serviceQName, String portName) {
-
- try {
- UDDIClerk bpelClerk = getBPELClerk();
- FindService findService = new FindService();
- findService.setAuthInfo(getAuthToken(bpelClerk));
- Name serviceName = new Name();
-
- String lang = "en";
- if (properties.containsKey(LANG)) lang = properties.getProperty(LANG);
- serviceName.setLang(lang);
- serviceName.setValue(serviceQName.getLocalPart());
- findService.getName().add(serviceName);
-
- FindQualifiers findQualifiers = new FindQualifiers();
- findQualifiers.getFindQualifier().add("exactMatch");
- findService.setFindQualifiers(findQualifiers);
-
- ServiceList serviceList =
bpelClerk.getUDDINode().getTransport().getUDDIInquiryService().findService(findService);
- //Loop over all services found.
- if (serviceList.getServiceInfos()!=null) {
- List<ServiceInfo> serviceInfos =
serviceList.getServiceInfos().getServiceInfo();
- for (ServiceInfo serviceInfo : serviceInfos) {
- String serviceKey = serviceInfo.getServiceKey();
-
- BusinessService service = bpelClerk.findService(serviceKey,
bpelClerk.getUDDINode().getApiNode());
- BindingTemplates bindingTemplates = service.getBindingTemplates();
- if (bindingTemplates==null) {
- log.warn("Found service " + serviceQName.getLocalPart()
- + " with serviceKey '" + serviceInfo.getServiceKey() +
"'"
- + " but no EPRs");
- } else {
- log.info("Found service " + serviceQName.getLocalPart()
- + " with serviceKey '" + serviceInfo.getServiceKey() +
"'"
- + " and " + bindingTemplates.getBindingTemplate().size() + "
EPRs");
- //Loop over all bindingTemplates found
- for (BindingTemplate bindingTemplate : bindingTemplates.getBindingTemplate()) {
- AccessPoint accessPoint = bindingTemplate.getAccessPoint();
- if (AccessPointType.WSDL_DEPLOYMENT.toString().equals(accessPoint.getUseType()))
{
- URL url = null;
- try {
- url = new URL(accessPoint.getValue());
- log.info("wsdlUrl for service " + serviceQName.getLocalPart() +
" is " + url);
- WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- Definition def = wsdlReader.readWSDL(url.toExternalForm());
-// if (log.isDebugEnabled()) {
-// log.debug(getWSDL(url));
-// }
- //Checking if this WSDL contains the right port name.
- Port port = def.getService(serviceQName).getPort(portName);
- if (port!=null) {
- //Current policy: "FirstSuccess" :)
- return new WSDLReference(def, url.toURI());
- } else {
- log.info("PortName " + portName + " could not be found in
WSDL");
- }
- } catch (Exception e) {
- log.warn("Unable to obtain WSDL from " + url + ". " +
e.getMessage(),e);
- }
- } else {
- log.debug("This accessPoint is of type " + accessPoint.getUseType()
+ " only "
- + AccessPointType.WSDL_DEPLOYMENT + " is supported at the
moment.");
- }
- }
- }
- }
- } else {
- log.info("No Service by the name " + serviceQName.getLocalPart() + "
was found in the registry.");
- }
-
- } catch (Exception e) {
- log.error(e.getMessage(),e);
- }
- log.info("No WSDL could be obtained using the UDDI Registry Lookup.");
+
+ log.info("No yet supported.");
return null;
}
- /**
- * Obtains an authToken for this clerk.
- *
- * @param clerk
- * @return
- * @throws TransportException
- * @throws DispositionReportFaultMessage
- * @throws RemoteException
- */
- private String getAuthToken(UDDIClerk clerk) throws TransportException,
DispositionReportFaultMessage, RemoteException {
-
- String endpointURL = clerk.getUDDINode().getApiNode().getSecurityUrl();
- GetAuthToken getAuthToken = new GetAuthToken();
- getAuthToken.setUserID(clerk.getPublisher());
- getAuthToken.setCred(clerk.getPassword());
- String authToken =
clerk.getUDDINode().getTransport().getUDDISecurityService(endpointURL).getAuthToken(getAuthToken).getAuthInfo();
-
- return authToken;
- }
-// /**
-// * Reads the WSDL from an endpoint URL and returns it in a formatted String.
-// *
-// * @param url - url of a WSDL Endpoint.
-// * @return - Formatted WSDL
-// * @throws IOException when there are IO issues reading the WSDL content from the
url.
-// */
-// private String getWSDL(URL url) throws IOException {
-//
-// BufferedInputStream inputStream = (BufferedInputStream) url.getContent();
-// BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
-// StringBuffer buffer = new StringBuffer();
-// String inputLine;
-// while ((inputLine = in.readLine()) != null) {
-// buffer.append(inputLine).append("\r\n");
-// }
-// in.close();
-// return buffer.toString();
-// }
- /**
- *
- * @param urlIn
- * @return
- */
- public URL rewriteWSDLURL(URL urlIn) {
- URL outUrl = urlIn;
- try {
- String urlString = getWebserviceBaseUrl() + urlIn.getFile() + "?wsdl";
- outUrl = new URL(urlString);
- } catch (Exception e) {
- log.error(e.getMessage(),e);
- }
- return outUrl;
- }
- /**
- *
- * @return
- */
- private String getWebserviceBaseUrl() {
- String url = properties.getProperty(WebServiceClient.BPEL_WEBSERVICE_BASEURL);
- if (url != null) {
- return url;
- }
-
- return getDefaultWebServiceBaseUrl();
- }
-
- private String getDefaultWebServiceBaseUrl() {
- try {
- ServerConfig serverConfig=JBossDSPFactory.getServerConfig();
- String webServiceHost = serverConfig.getWebServiceHost();
- int webServicePort = serverConfig.getWebServicePort();
- URL theURL = new URL("http://" + webServiceHost + ":" +
webServicePort);
- if (Boolean.valueOf(properties.getProperty(WebServiceClient.BPEL_WEBSERVICE_SECURE,
"false"))) {
- int secureWebServicePort = serverConfig.getWebServicePort();
- theURL = new URL("https://" + webServiceHost + ":" +
secureWebServicePort);
- }
- return theURL.toExternalForm();
- } catch (MalformedURLException e) {
- log.error("Error in constructing the webservice base url.", e);
- return null;
- }
- }
+
+
}