[jboss-svn-commits] JBL Code SVN: r20412 - in labs/jbossesb/workspace/jimma/product: rosetta/src/org/jboss/internal/soa/esb/publish and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 11 04:18:42 EDT 2008
Author: jim.ma
Date: 2008-06-11 04:18:42 -0400 (Wed, 11 Jun 2008)
New Revision: 20412
Added:
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGenerator.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublishException.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGeneratorUnitTest.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/webservice_test.esb
labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SOAPTest.java
Modified:
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployment.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/ServicePublisherUnitTest.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_06.xml
labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml
Log:
* Add artifacts to generate jaxws disptch provider class for ESB service and publish it in JBOSSWS native
* Add helloworld_pub_service sample to demonstrate this prototype of publishing esb service as web service
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -57,18 +57,21 @@
String wsdl;
Definition def = null;
int nsSuffixCounter = 1;
+ Service serviceCfg;
public void setServiceConfig(Service serviceConfig)
throws ConfigurationException {
+ serviceCfg = serviceConfig;
- String targetNamespace = "http://" + serviceConfig.getCategory() + "/"
- + serviceConfig.getName();
- String serviceName = serviceConfig.getCategory();
-
+ }
+ //TODO:Handle the exception
+ public void generateWSDL() {
+ String targetNamespace = "http://soa.jboss.org/" + serviceCfg.getCategory().toLowerCase();
+ String serviceName = serviceCfg.getName();
try {
def = WSDLFactory.newInstance().newDefinition();
} catch (WSDLException e1) {
- throw new ConfigurationException(e1);
+ e1.printStackTrace();
}
def.setTargetNamespace(targetNamespace);
def.addNamespace("tns", targetNamespace);
@@ -81,9 +84,9 @@
Message resMessage = null;
Message faultMessage = null;
- String inXsd = serviceConfig.getActions().getInXsd();
- String outXsd = serviceConfig.getActions().getOutXsd();
- String faultXsd = serviceConfig.getActions().getFaultXsd();
+ String inXsd = serviceCfg.getActions().getInXsd();
+ String outXsd = serviceCfg.getActions().getOutXsd();
+ String faultXsd = serviceCfg.getActions().getFaultXsd();
if (inXsd != null) {
try {
@@ -94,7 +97,7 @@
serviceName + "Req", "in");
}
} catch (Exception e) {
- throw new ConfigurationException(e);
+ e.printStackTrace();
}
}
@@ -108,7 +111,7 @@
serviceName + "Res", "out");
}
} catch (Exception e) {
- throw new ConfigurationException(e);
+ //
}
}
@@ -116,13 +119,14 @@
if (faultXsd != null) {
try {
Document doc = YADOMUtil.parseStream(ClassUtil
- .getResourceAsStream(faultXsd, getClass()), false, false);
+ .getResourceAsStream(faultXsd, getClass()), false,
+ false);
if (doc != null) {
faultMessage = addMessage(doc.getDocumentElement(),
serviceName + "fault", "fault");
}
} catch (Exception e) {
- throw new ConfigurationException(e);
+ //
}
}
@@ -130,14 +134,13 @@
PortType portType = addPortType(serviceName, reqMessage, resMessage,
faultMessage);
Binding binding = addBinding(serviceName, portType);
- addService(serviceName, binding);
+ addService(serviceName, binding);
StringWriter sw = new java.io.StringWriter();
try {
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sw);
} catch (WSDLException e) {
}
wsdl = sw.toString();
-
}
public ContractInfo getContractInfo(EPR epr) {
@@ -226,16 +229,16 @@
Operation op = (Operation) portType.getOperations().get(0);
bop.setOperation(op);
if (op.getInput() != null) {
- BindingInput binput = def.createBindingInput();
- bop.setBindingInput(binput);
- }
+ BindingInput binput = def.createBindingInput();
+ bop.setBindingInput(binput);
+ }
if (op.getOutput() != null) {
BindingOutput boutput = def.createBindingOutput();
bop.setBindingOutput(boutput);
}
- if (op.getFaults().size() != 0 ) {
+ if (op.getFaults().size() != 0) {
BindingFault bfault = def.createBindingFault();
- Fault fault = (Fault)op.getFaults().values().iterator().next();
+ Fault fault = (Fault) op.getFaults().values().iterator().next();
bfault.setName(fault.getName());
bop.addBindingFault(bfault);
}
@@ -259,4 +262,9 @@
service.addPort(port);
def.addService(service);
}
+
+ public String getWSDL() {
+ return wsdl;
+ }
+
}
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ESBServiceEndpointInfo {
+ private ConcurrentHashMap<String, Object> properties = new ConcurrentHashMap<String, Object>();
+ private Class<?> epClass;
+ private String svcCat;
+ private String svcName;
+ private String wsdl;
+ private String targetNS;
+ public ESBServiceEndpointInfo(String serviceCategory, String serviceName) {
+ svcCat = serviceCategory;
+ svcName = serviceName;
+ }
+
+
+ public void setWSDL(String value) {
+ wsdl = value;
+ }
+
+ public String getWSDL() {
+ return wsdl;
+ }
+
+ public void setEndpointClass(Class<?> clz) {
+ epClass = clz;
+ }
+
+ public Class<?> getEndpointClass() {
+ return epClass;
+ }
+
+ public Object getProperty(String key) {
+ return properties.get(key);
+ }
+
+ public void setProperty(String key, Object obj) {
+ properties.put(key, obj);
+ }
+
+ public String getServiceDirectory() {
+ return svcCat;
+ }
+
+ public void setServiceDirectory(String value) {
+ svcCat = value;
+ }
+
+ public String getServiceName() {
+ return svcName;
+ }
+
+ public void setServiceName(String value) {
+ svcName = value;
+ }
+
+ public String getEndpointName() {
+ return this.getServiceDirectory() + "." + this.getServiceName();
+ }
+
+ public String getWSEndpointClassName() {
+ return "org.jboss.soa." + this.svcCat.toLowerCase() + "." + this.svcName;
+ }
+
+ public void setTargetNamespace(String value) {
+ targetNS = value;
+ }
+
+ public String getTargetNamesapce() {
+ return targetNS;
+ }
+
+ public String getWSDLFileName() {
+ return svcCat.toLowerCase() + "_" + svcName.toLowerCase() + ".wsdl";
+ }
+
+ public String getWSDLServiceName() {
+ return svcName + "Service";
+ }
+
+ public String getWSDLPortName() {
+ return svcName + "Port";
+ }
+
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.SignatureAttribute;
+import javassist.bytecode.annotation.Annotation;
+import javassist.bytecode.annotation.EnumMemberValue;
+import javassist.bytecode.annotation.StringMemberValue;
+
+public class JAXWSProviderClassGenerator {
+ public CtClass generate(ESBServiceEndpointInfo epInfo) throws WebServicePublishException {
+ ClassPool pool = ClassPool.getDefault();
+ CtClass seiClass = pool.makeClass(epInfo.getWSEndpointClassName());
+ try {
+ CtClass providerClass = pool
+ .get("javax.xml.ws.Provider");
+ seiClass.setInterfaces(new CtClass[] { providerClass });
+
+
+ ConstPool constantPool = seiClass.getClassFile().getConstPool();
+ AnnotationsAttribute attribute = new AnnotationsAttribute(
+ constantPool, AnnotationsAttribute.visibleTag);
+ Annotation annotation = new Annotation(
+ "javax.xml.ws.WebServiceProvider", constantPool);
+ StringMemberValue strValue1 = new StringMemberValue(constantPool);
+ strValue1.setValue("/WEB-INF/wsdl/" + epInfo.getWSDLFileName());
+ annotation.addMemberValue("wsdlLocation", strValue1);
+ StringMemberValue strValue2 = new StringMemberValue(constantPool);
+ strValue2.setValue(epInfo.getWSDLServiceName());
+ annotation.addMemberValue("serviceName", strValue2);
+ StringMemberValue strValue3 = new StringMemberValue(constantPool);
+ strValue3.setValue(epInfo.getWSDLPortName());
+ annotation.addMemberValue("portName", strValue3);
+
+ StringMemberValue strValue4 = new StringMemberValue(constantPool);
+ strValue4.setValue(epInfo.getTargetNamesapce());
+ annotation.addMemberValue("targetNamespace", strValue4);
+
+ attribute.addAnnotation(annotation);
+
+ Annotation annotation2= new Annotation(
+ "javax.xml.ws.ServiceMode", constantPool);
+ EnumMemberValue enumValue = new EnumMemberValue(constantPool);
+ //CtClass serviceMode = pool.get("javax.xml.ws.Service$Mode");
+ enumValue.setType("javax.xml.ws.Service$Mode");
+ enumValue.setValue("MESSAGE");
+ annotation2.addMemberValue("value", enumValue);
+ attribute.addAnnotation(annotation2);
+ seiClass.getClassFile().addAttribute(attribute);
+ CtMethod m = CtNewMethod.make("public Object invoke(Object obj) "
+ + getMethodBody(epInfo), seiClass);
+ seiClass.addMethod(m);
+ //add generics for class
+ SignatureAttribute signatureAttribute = new SignatureAttribute(seiClass.getClassFile().getConstPool(),
+ "Ljava/lang/Object;Ljavax/xml/ws/Provider<Ljavax/xml/soap/SOAPMessage;>;");
+ seiClass.getClassFile().addAttribute(signatureAttribute);
+
+ } catch (Exception e) {
+
+ throw new WebServicePublishException("Failed to generate jaxws dispatch class for ESB service", e);
+ }
+
+ return seiClass;
+ }
+
+
+ public String getMethodBody(ESBServiceEndpointInfo epInfo) {
+ String body = "{ "
+ + "javax.xml.soap.SOAPMessage request = (javax.xml.soap.SOAPMessage)obj;"
+ + "try {"
+ + "org.jboss.soa.esb.client.ServiceInvoker serviceInvoker = new org.jboss.soa.esb.client.ServiceInvoker("
+ + "\"" + epInfo.getServiceDirectory() + "\"," + "\"" + epInfo.getServiceName()+ "\");";
+ body = body + "org.jboss.soa.esb.message.Message msg = org.jboss.soa.esb.message.format.MessageFactory.getInstance().getMessage();";
+ body = body + "msg.getBody().add(request.getSOAPBody().toString());";
+ body = body + "org.jboss.soa.esb.message.Message resMsg = serviceInvoker.deliverSync(msg, (long)2000);";
+ body = body + "System.out.println(\"---res msg --- \"+ resMsg.getBody().get().toString());";
+ body = body + "} catch (Exception e) { e.printStackTrace();} ";
+ body = body + "return request;}";
+ return body;
+ }
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGenerator.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGenerator.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javassist.CtClass;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jboss.util.file.JarUtils;
+
+public class JBossWSWarGenerator {
+ private Logger logger = Logger.getLogger(getClass());
+ public String warName;
+ public CopyOnWriteArrayList<File> fileList = new CopyOnWriteArrayList<File>();
+ public String tmpDir = System.getProperty("java.io.tmpdir");
+ public ESBServiceEndpointInfo endpointInfo;
+
+ public JBossWSWarGenerator(ESBServiceEndpointInfo endpoint) {
+ endpointInfo = endpoint;
+ warName = (endpoint.getServiceDirectory() + "-" + endpoint
+ .getServiceName()).toLowerCase();
+
+ }
+
+ private File generateWar() throws Exception {
+ try {
+ addFile(generateWebXml());
+ addFile(generateWSDLFile());
+ File warTmp = File.createTempFile(endpointInfo.getEndpointName()
+ + "war", "dir");
+ warTmp.delete();
+ warTmp.mkdirs();
+ File warDir = new File(warTmp.getPath() + File.separator + "sub");
+ warDir.mkdir();
+
+ for (File file : fileList) {
+ File dir = new File(warDir.getCanonicalPath() + File.separator
+ + file.getParentFile().getName());
+
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+
+ FileUtils.copyFileToDirectory(file, dir);
+ }
+
+ JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
+ CtClass providerClass = generator.generate(endpointInfo);
+ providerClass.writeFile(warDir.getCanonicalPath());
+
+ File warFile = new File(warTmp + File.separator + warName + ".war");
+ warFile.createNewFile();
+ FileOutputStream fout = new FileOutputStream(warFile);
+ JarUtils.jar(fout, warDir.listFiles());
+ fout.close();
+ logger.log(Level.DEBUG,
+ "Generated webserivce war file for Endpoint "
+ + endpointInfo.getEndpointName());
+ return warFile;
+ } catch (Exception e) {
+ throw e;
+ }
+
+ }
+
+ public void deployWar(File esbFile) throws WebServicePublishException {
+ File wsWar;
+ try {
+ wsWar = generateWar();
+ } catch (Exception e1) {
+ throw new WebServicePublishException(
+ "Failed to Generate war file for Endpoint "
+ + endpointInfo.getEndpointName(), e1);
+ }
+ File deployDir = esbFile.getParentFile();
+
+ try {
+ FileUtils.copyFileToDirectory(wsWar, deployDir);
+ } catch (Exception e) {
+ throw new WebServicePublishException(
+ "Failed to add war file to esb service "
+ + esbFile.getName(), e);
+ }
+
+ logger.log(Level.DEBUG,
+ "Deployed webservice war for esb service "
+ + esbFile.getName());
+
+ }
+
+ public void injectWarToESBArchive(File esbFile) throws WebServicePublishException {
+ File wsWar;
+ try {
+ wsWar = generateWar();
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ throw new WebServicePublishException(
+ "Failed to Generate war file for Endpoint "
+ + endpointInfo.getEndpointName(), e1);
+ }
+
+ if (esbFile.exists() && esbFile.isFile()) {
+ try {
+ FileInputStream fin = new FileInputStream(esbFile);
+ File tmpDir = File.createTempFile(esbFile.getName(), ".tmp");
+ tmpDir.delete();
+ tmpDir.mkdirs();
+ JarUtils.unjar(fin, tmpDir);
+ FileUtils.copyFileToDirectory(wsWar, tmpDir);
+ fin.close();
+
+ esbFile.delete();
+ esbFile.createNewFile();
+ FileOutputStream fout = new FileOutputStream(esbFile);
+ JarUtils.jar(fout, tmpDir.listFiles());
+ fout.close();
+ } catch (Exception e) {
+ throw new WebServicePublishException(
+ "Failed to inject war file in esb service "
+ + esbFile.getName(), e);
+ }
+ } else if (esbFile.exists() && esbFile.isDirectory()) {
+ try {
+ FileUtils.copyFileToDirectory(wsWar, esbFile);
+ } catch (Exception e) {
+ throw new WebServicePublishException(
+ "Failed to add war file to esb service "
+ + esbFile.getName(), e);
+ }
+
+ }
+ logger.log(Level.DEBUG,
+ "Injected webservice deployment war to esb service "
+ + esbFile.getName());
+
+ }
+
+ public void addFile(File file) {
+ fileList.add(file);
+ }
+
+ // TODO:Use a template file to do this?
+ private File generateWebXml() throws IOException {
+ String webXmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<web-app xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\""
+ + " version=\"2.4\">" + "<servlet>" + "<servlet-name>"
+ + endpointInfo.getServiceName() + "</servlet-name>"
+ + "<servlet-class>" + endpointInfo.getWSEndpointClassName()
+ + "</servlet-class>" + "</servlet>" + "<servlet-mapping>"
+ + "<servlet-name>" + endpointInfo.getServiceName()
+ + "</servlet-name>" + "<url-pattern>/"
+ + endpointInfo.getServiceDirectory() + "/"
+ + endpointInfo.getServiceName() + "</url-pattern>"
+ + "</servlet-mapping>" + "</web-app>";
+ File webXml = new File("WEB-INF/web.xml");
+ FileUtils.writeStringToFile(webXml, webXmlContent);
+ return webXml;
+ }
+
+ private File generateWSDLFile() throws IOException {
+ File wsdlFile = new File("WEB-INF/wsdl/"
+ + endpointInfo.getWSDLFileName());
+ FileUtils.writeStringToFile(wsdlFile, endpointInfo.getWSDL());
+ return wsdlFile;
+ }
+
+}
\ No newline at end of file
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.File;
+
+public class JBossWSWebServicePublisher implements WebServicePublisher {
+ public void publish(ESBServiceEndpointInfo endpoint, File esbService) throws WebServicePublishException {
+ JBossWSWarGenerator warGenerator = new JBossWSWarGenerator(endpoint);
+ try {
+ warGenerator.deployWar(esbService);
+ } catch (WebServicePublishException e) {
+ throw new WebServicePublishException(
+ "Failed to publish webservice "
+ + endpoint.getServiceDirectory()+ "/" + endpoint.getServiceName() + " for service "
+ + esbService.getName(), e);
+ }
+ }
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublishException.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublishException.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublishException.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+public class WebServicePublishException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Public constructor.
+ * @param message Exception message.
+ */
+ public WebServicePublishException(String message) {
+ super(message);
+ }
+
+ /**
+ * Public constructor.
+ * @param message Exception message.
+ * @param cause Exception cause.
+ */
+ public WebServicePublishException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Public constructor.
+ * @param cause Exception cause.
+ */
+ public WebServicePublishException(Throwable cause) {
+ super(cause);
+ }
+
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.File;
+
+public interface WebServicePublisher {
+ void publish(ESBServiceEndpointInfo endpoint, File esbService) throws WebServicePublishException;
+}
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -23,6 +23,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URL;
@@ -31,7 +32,12 @@
import javax.management.ObjectName;
import javax.xml.transform.stream.StreamSource;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.internal.soa.esb.publish.ServiceContractPublisher;
import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
+import org.jboss.internal.soa.esb.webservice.JBossWSWebServicePublisher;
+import org.jboss.internal.soa.esb.webservice.WebServicePublisher;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.LifecycleUtil;
import org.jboss.soa.esb.listeners.ListenerTagNames;
@@ -73,10 +79,10 @@
}
public static ManagedLifecycleController create(String configXml) {
- return create (configXml, null);
+ return create (configXml, null, null);
}
- public static ManagedLifecycleController create(String configXml, ObjectName serviceName)
+ public static ManagedLifecycleController create(String configXml, DeploymentInfo di, ObjectName serviceName)
{
InputStream validationInputStream = ClassUtil.getResourceAsStream(JBOSSESB_XSD, Configuration.class);
//if this fails try using the
@@ -96,20 +102,26 @@
ByteArrayOutputStream gatewayXml = new ByteArrayOutputStream();
Generator generator = new Generator(new ByteArrayInputStream(configXml.getBytes()), listenerXml, gatewayXml);
generator.generate();
+
byte[] listenerBytes = listenerXml.toByteArray();
//System.out.println("*************** listenerBytes: " + new String(listenerBytes));
ByteArrayInputStream listenerIs = new ByteArrayInputStream(listenerBytes);
ConfigTree listenerConfig = ConfigTree.fromInputStream(listenerIs);
+
if (serviceName != null) {
listenerConfig.setAttribute(ListenerTagNames.DEPLOYMENT_NAME_TAG,
- serviceName.getKeyProperty(ListenerTagNames.DEPLOYMENT_NAME_TAG));
+ serviceName.getKeyProperty(ListenerTagNames.DEPLOYMENT_NAME_TAG));
}
+
+ File esbFile = new File(di.url.getFile());
+
List<ManagedLifecycle> instances = LifecycleUtil.getListeners(listenerConfig);
byte[] gatewayBytes = gatewayXml.toByteArray();
//System.out.println("*************** gatewayBytes: " + new String(gatewayBytes));
ByteArrayInputStream gatewayIs = new ByteArrayInputStream(gatewayBytes);
ConfigTree gatewayConfig = ConfigTree.fromInputStream(gatewayIs);
+
instances.addAll(LifecycleUtil.getGateways(gatewayConfig));
ManagedLifecycleController controller = new ManagedLifecycleController(instances);
@@ -118,7 +130,30 @@
// In parallel, create a map of the contract publication info...
ServicePublisher.addServicePublishers(controller, generator.getModel());
-
+
+ List<ServicePublisher> servicePublihsers = ServicePublisher.getServicePublisher(controller);
+
+ //need to publish esb service as a webService?
+ File deployDir = esbFile.getParentFile();
+ for(ServicePublisher publisher : servicePublihsers) {
+
+ if (publisher.getContractPublisher() instanceof ServiceContractPublisher) {
+ //
+ ServiceContractPublisher serviceContractpublisher = (ServiceContractPublisher)publisher.getContractPublisher();
+ String wsdl = serviceContractpublisher.getWSDL();
+ ESBServiceEndpointInfo endpoint = new ESBServiceEndpointInfo(publisher.getCategory(), publisher.getServiceName());
+ File publishedWar = new File(deployDir.getCanonicalPath(), publisher.getCategory().toLowerCase() + "_" + publisher.getServiceName() + ".war");
+ if (publishedWar.exists()) {
+ continue;
+ }
+ endpoint.setWSDL(wsdl);
+ endpoint.setTargetNamespace("http://soa.jboss.org/" + publisher.getCategory().toLowerCase());
+ //publish this esb service to web service
+ WebServicePublisher esbServicePublisher = new JBossWSWebServicePublisher();
+ esbServicePublisher.publish(endpoint, esbFile);
+
+ }
+ }
return controller;
}
else
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -333,7 +333,7 @@
addActionDependencies(di.shortName, jbossEsbXml, deps) ;
- JBoss4ESBDeployment deployment = new JBoss4ESBDeployment(jbossEsbXml, di.shortName);
+ JBoss4ESBDeployment deployment = new JBoss4ESBDeployment(jbossEsbXml, di);
deployment.setClassloader(di.ucl);
String name = PREFIX_CANONICAL_NAME + di.shortName;
ObjectName on = ObjectNameConverter.convert(name);
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployment.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployment.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployment.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -21,6 +21,7 @@
*/
package org.jboss.soa.esb.listeners.config;
+import org.jboss.deployment.DeploymentInfo;
import org.jboss.soa.esb.lifecycle.LifecycleResourceManager;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleController;
import org.jboss.system.ServiceMBeanSupport;
@@ -37,12 +38,14 @@
private final String deploymentName ;
private ManagedLifecycleController controller;
private ClassLoader classloader;
+ private DeploymentInfo deploymentInfo;
- public JBoss4ESBDeployment(String jbossEsbXml, final String deploymentName)
+ public JBoss4ESBDeployment(String jbossEsbXml, final DeploymentInfo di)
{
this.jbossEsbXml = jbossEsbXml;
- this.deploymentName = deploymentName ;
+ this.deploymentName = di.shortName ;
+ deploymentInfo = di;
}
public String getJbossEsbXml()
@@ -78,8 +81,8 @@
try
{
Thread.currentThread().setContextClassLoader(classloader);
- LifecycleResourceManager.getSingleton().associateDeployment(deploymentName) ;
- controller = Configuration.create(jbossEsbXml, serviceName);
+ LifecycleResourceManager.getSingleton().associateDeployment(deploymentName);
+ controller = Configuration.create(jbossEsbXml, deploymentInfo, serviceName);
controller.start();
}
finally
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -112,9 +112,14 @@
servicePublisher.setDescription(service.getDescription());
publishers.add(servicePublisher);
}
-
+
servicePublishers.put(controller, publishers);
}
+
+
+ public static List<ServicePublisher> getServicePublisher(ManagedLifecycleController controller) {
+ return servicePublishers.get(controller);
+ }
/**
* Get the full list of publishers registered against all active {@link ManagedLifecycleController}
@@ -175,8 +180,10 @@
if (service.getActions().getInXsd() != null)
{
ServiceContractPublisher publisher = new ServiceContractPublisher();
+
try {
publisher.setServiceConfig(service);
+ publisher.generateWSDL();
} catch (ConfigurationException e) {
throw new RuntimeException("Failed to instantiate Service Contract Publisher '" + publisher.getClass().getName() + "'. Class must implement a public default constructor.", e);
}
Added: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,26 @@
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.File;
+
+import javassist.CtClass;
+import junit.framework.TestCase;
+
+public class JAXWSProviderClassGeneratorUnitTest extends TestCase {
+ public void testGenerator() {
+ JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
+ ESBServiceEndpointInfo epInfo = new ESBServiceEndpointInfo("test", "MyTest");
+ epInfo.setTargetNamespace("http://soa.jboss.org/");
+ String currentDir = getClass().getResource(".").getFile();
+
+ try {
+ CtClass ctClass = generator.generate(epInfo);
+ ctClass.writeFile(currentDir);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ File generatedClass = new File(currentDir + "/org/jboss/soa/test/MyTest.class");
+ assertTrue("the jaxws disptach provider class is not generated", generatedClass.exists());
+
+ }
+
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGeneratorUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSWarGeneratorUnitTest.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.File;
+import java.net.URL;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import junit.framework.TestCase;
+
+public class JBossWSWarGeneratorUnitTest extends TestCase {
+
+ public void testInjetWar() {
+ URL url = getClass().getResource("webservice_test.esb");
+ File file = new File(url.getFile());
+ ESBServiceEndpointInfo endpointInfo = new ESBServiceEndpointInfo("MyTest", "test");
+ endpointInfo.setTargetNamespace("http://soa.jboss.org");
+ JBossWSWarGenerator generator = new JBossWSWarGenerator(endpointInfo);
+ boolean warGenerated = false;
+ try {
+ generator.injectWarToESBArchive(file);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ try {
+ JarInputStream jarInput = new JarInputStream(new java.io.FileInputStream(file));
+ JarEntry jarEntry = null;
+
+ while ((jarEntry = jarInput.getNextJarEntry()) != null) {
+ if(jarEntry.getName().equalsIgnoreCase("mytest.war")) {
+ warGenerated = true;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertTrue("the war does not injected into esb file", warGenerated);
+ }
+
+}
Added: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/webservice_test.esb
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/webservice_test.esb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/ServicePublisherUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/ServicePublisherUnitTest.java 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/ServicePublisherUnitTest.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -1,10 +1,12 @@
package org.jboss.soa.esb.listeners.config;
+import java.io.File;
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
import org.jboss.internal.soa.esb.publish.ServiceContractPublisher;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.EPR;
@@ -104,7 +106,9 @@
EPR epr = registry.findEPR(publishers.get(2).getCategory(),
publishers.get(2).getServiceName());
assertNotNull(publishers.get(2).getContractPublisher().getContractInfo(epr).getData());
-
+ //File file = new File("/home/jimma/project/jbossesb/workspace/jimma/product/tmp.wsdl");
+ //file.createNewFile();
+ //FileUtils.writeStringToFile(file, publishers.get(2).getContractPublisher().getContractInfo(epr).getData());
configUtil.stopController();
} catch (Exception e) {
Modified: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_06.xml
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_06.xml 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/jbossesb_config_06.xml 2008-06-11 08:18:42 UTC (rev 20412)
@@ -1,10 +1,16 @@
<?xml version = "1.0" encoding = "UTF-8"?>
-<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+<jbossesb
+ xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
<services>
- <service category="C" name="3" description="A1" invmScope="GLOBAL">
- <actions inXsd="/org/jboss/soa/esb/listeners/config/request.xsd" outXsd="/org/jboss/soa/esb/listeners/config/response.xsd">
- <action name="a1" class="org.jboss.soa.esb.actions.converters.ByteArrayToString" />
+ <service category="FirstServiceESB" name="SimpleListener"
+ description="Hello World" invmScope="GLOBAL">>
+ <actions mep="OneWay"
+ inXsd="/org/jboss/soa/esb/listeners/config/request.xsd">
+ <action name="action2"
+ class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull" value="true" />
+ </action>
</actions>
</service>
- </services>
+ </services>
</jbossesb>
Modified: labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml
===================================================================
--- labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml 2008-06-11 00:18:54 UTC (rev 20411)
+++ labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml 2008-06-11 08:18:42 UTC (rev 20412)
@@ -7,15 +7,22 @@
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
+ <target name="runtest" depends="compile"
+ description="sends a soap message to published web service">
+ <echo>Send soap message to published web service</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.helloworld.test.SOAPTest" failonerror="true">
+ <classpath refid="exec-classpath"/>
+ </java>
+ </target>
- <target name="runtest" depends="compile"
+ <!--target name="runtest" depends="compile"
description="sends a JMS message to queue/quickstart_helloworld_Request_gw">
<echo>Runs Test JMS Sender</echo>
<java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.helloworld.test.SendJMSMessage" failonerror="true">
<arg value="Hello World"/>
<classpath refid="exec-classpath"/>
</java>
- </target>
+ </target-->
<target name="sendesb" depends="compile"
description="Will send an esb Message">
Added: labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SOAPTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SOAPTest.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/src/org/jboss/soa/esb/samples/quickstart/helloworld/test/SOAPTest.java 2008-06-11 08:18:42 UTC (rev 20412)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.helloworld.test;
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+public class SOAPTest {
+ public static void main(String args[]) {
+ String request = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cus=\"http://schemas.active-endpoints.com/\">"
+ + "<soapenv:Header/><soapenv:Body><cus:customerName>JBOSS</cus:customerName></soapenv:Body></soapenv:Envelope>";
+ HttpClient client = new HttpClient();
+ PostMethod postMethod = new PostMethod(
+ "http://127.0.0.1:8080/firstserviceesb-simplelistener/FirstServiceESB/SimpleListener");
+
+ StringRequestEntity requestEntity = new StringRequestEntity(request);
+ postMethod.setRequestEntity(requestEntity);
+ try {
+ client.executeMethod(postMethod);
+ System.out.println("Response from web service");
+ System.out.println(postMethod.getResponseBodyAsString());
+ } catch (HttpException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+}
More information about the jboss-svn-commits
mailing list