[jboss-svn-commits] JBL Code SVN: r20853 - in labs/jbossesb/workspace/jimma/product: rosetta/src/org/jboss/soa/esb/listeners/config and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 1 05:10:44 EDT 2008
Author: jim.ma
Date: 2008-07-01 05:10:44 -0400 (Tue, 01 Jul 2008)
New Revision: 20853
Added:
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/fault.xsd
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_06.xml
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/request.xsd
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/response.xsd
labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/fault.xsd
Modified:
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java
labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java
labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml
labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/jboss-esb.xml
Log:
* Add ESBContractorGeneratorUnitTest to test generating wsdl contains wsdl:fault
* Modify the helloworld_pub_service to generate wsdl contains fault
Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java 2008-07-01 04:44:47 UTC (rev 20852)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java 2008-07-01 09:10:44 UTC (rev 20853)
@@ -19,7 +19,6 @@
*/
package org.jboss.internal.soa.esb.webservice;
-import java.io.IOException;
import java.io.StringWriter;
import javax.wsdl.Binding;
@@ -49,11 +48,12 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
import com.ibm.wsdl.extensions.schema.SchemaImpl;
import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
+import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
+import com.ibm.wsdl.extensions.soap.SOAPFaultImpl;
public class ESBContractGenerator {
private final QName XSD_QN = new QName("http://www.w3.org/2001/XMLSchema", "schema");
@@ -66,9 +66,9 @@
svcConfig = serviceConfig;
}
- public void generateWSDL(Service serviceConfig) throws ConfigurationException {
- String targetNamespace = "http://soa.jboss.org/" + serviceConfig.getCategory().toLowerCase();
- String serviceName = serviceConfig.getName();
+ public void generateWSDL() throws ConfigurationException {
+ String targetNamespace = "http://soa.jboss.org/" + svcConfig.getCategory().toLowerCase();
+ String serviceName = svcConfig.getName();
try {
def = WSDLFactory.newInstance().newDefinition();
} catch (WSDLException e1) {
@@ -85,9 +85,9 @@
Message resMessage = null;
Message faultMessage = null;
- String inXsd = serviceConfig.getActions().getInXsd();
- String outXsd = serviceConfig.getActions().getOutXsd();
- String faultXsd = serviceConfig.getActions().getFaultXsd();
+ String inXsd = svcConfig.getActions().getInXsd();
+ String outXsd = svcConfig.getActions().getOutXsd();
+ String faultXsd = svcConfig.getActions().getFaultXsd();
if (inXsd != null) {
try {
@@ -97,13 +97,9 @@
reqMessage = addMessage(doc.getDocumentElement(),
serviceName + "Req", "in");
}
- } catch (IOException e) {
- throw new ConfigurationException("File defined in inXsd attribute '" + serviceConfig.getActions().getInXsd() + "' not found in classpath.", e);
- } catch (SAXException e) {
- throw new ConfigurationException("invalid inXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+ } catch (Exception e) {
+ throw new ConfigurationException("File defined in inXsd attribute '" + svcConfig.getActions().getInXsd() + "' not found in classpath.", e);
}
-
-
}
if (outXsd != null) {
@@ -114,10 +110,8 @@
resMessage = addMessage(doc.getDocumentElement(),
serviceName + "Res", "out");
}
- } catch (IOException e) {
- throw new ConfigurationException("File defined in outXsd attribute '" + serviceConfig.getActions().getOutXsd() + "' not found in classpath.", e);
- } catch (SAXException e) {
- throw new ConfigurationException("Invalid outXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+ } catch (Exception e) {
+ throw new ConfigurationException("File defined in outXsd attribute '" + svcConfig.getActions().getOutXsd() + "' not found in classpath.", e);
}
}
@@ -131,10 +125,8 @@
faultMessage = addMessage(doc.getDocumentElement(),
serviceName + "fault", "fault");
}
- } catch (IOException e) {
- throw new ConfigurationException("File defined in faultXsd attribute '" + serviceConfig.getActions().getFaultXsd() + "' not found in classpath.", e);
- } catch (SAXException e) {
- throw new ConfigurationException("Invalid faultXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+ } catch (Exception e) {
+ throw new ConfigurationException("File defined in faultXsd attribute '" + svcConfig.getActions().getFaultXsd() + "' not found in classpath.", e);
}
}
@@ -147,7 +139,7 @@
try {
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sw);
} catch (WSDLException e) {
- new ConfigurationException("Failed to generate wsdl for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+ new ConfigurationException("Failed to generate wsdl for service:" + svcConfig.getCategory() + "/" + svcConfig.getName() , e);
}
wsdl = sw.toString();
}
@@ -229,6 +221,7 @@
binding.setQName(new QName(def.getTargetNamespace(), serviceName
+ "Binding"));
SOAPBindingImpl soapBinding = new SOAPBindingImpl();
+
soapBinding.setStyle("document");
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
binding.addExtensibilityElement(soapBinding);
@@ -239,18 +232,28 @@
Operation op = (Operation) portType.getOperations().get(0);
bop.setOperation(op);
if (op.getInput() != null) {
- BindingInput binput = def.createBindingInput();
+ BindingInput binput = def.createBindingInput();
bop.setBindingInput(binput);
+ SOAPBodyImpl soapBody = new SOAPBodyImpl();
+ soapBody.setUse("literal");
+ binput.addExtensibilityElement(soapBody);
}
if (op.getOutput() != null) {
BindingOutput boutput = def.createBindingOutput();
bop.setBindingOutput(boutput);
+ SOAPBodyImpl soapBody = new SOAPBodyImpl();
+ soapBody.setUse("literal");
+ boutput.addExtensibilityElement(soapBody);
}
if (op.getFaults().size() != 0) {
BindingFault bfault = def.createBindingFault();
Fault fault = (Fault) op.getFaults().values().iterator().next();
bfault.setName(fault.getName());
bop.addBindingFault(bfault);
+ SOAPFaultImpl soapFault = new SOAPFaultImpl();
+ soapFault.setName(fault.getName());
+ soapFault.setUse("literal");
+ bfault.addExtensibilityElement(soapFault);
}
binding.addBindingOperation(bop);
def.addBinding(binding);
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-07-01 04:44:47 UTC (rev 20852)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java 2008-07-01 09:10:44 UTC (rev 20853)
@@ -140,12 +140,9 @@
ESBContractGenerator contractGen = new ESBContractGenerator(
service);
try {
- contractGen.generateWSDL(service);
+ contractGen.generateWSDL();
} catch (ConfigurationException e) {
- throw new RuntimeException(
- "Failed to generate contract for service '"
- + service.getCategory() + "/"
- + service.getName() + "'", e);
+ throw new RuntimeException(e.getMessage(), e);
}
ESBServiceEndpointInfo endpoint = new ESBServiceEndpointInfo(
Added: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,57 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.jboss.soa.esb.listeners.config.Generator;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
+import org.jboss.soa.esb.util.FileUtil;
+import org.xml.sax.InputSource;
+
+import junit.framework.TestCase;
+
+public class ESBContractGeneratorUnitTest extends TestCase {
+ public void testGenerateWSDL() throws Exception {
+ URL url = getClass().getResource("./jbossesb_config_06.xml");
+ byte[] configBytes = FileUtil.readFile(new File(url.getFile()));
+ ByteArrayOutputStream listenerXml = new ByteArrayOutputStream();
+ ByteArrayOutputStream gatewayXml = new ByteArrayOutputStream();
+ Generator generator = new Generator(new ByteArrayInputStream(configBytes), listenerXml, gatewayXml);
+ generator.generate();
+ List<Service> serivces = generator.getModel().getServices();
+ ESBContractGenerator contractGen = new ESBContractGenerator(serivces.get(0));
+ contractGen.generateWSDL();
+ String wsdl = contractGen.getWSDL();
+ java.io.StringReader strReader = new java.io.StringReader(wsdl);
+ InputSource inputSource = new InputSource(strReader);
+ Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL("file://tmp.wsdl", inputSource);
+ assertNotNull("Failed to generate wsdl file" , def);
+ }
+
+}
Modified: 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 2008-07-01 04:44:47 UTC (rev 20852)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGeneratorUnitTest.java 2008-07-01 09:10:44 UTC (rev 20853)
@@ -1,3 +1,22 @@
+/*
+ * 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;
Added: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/fault.xsd
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/fault.xsd (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/fault.xsd 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,9 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="sayFault" type="x1:fault"/>
+ <xs:complexType name="fault">
+ <xs:sequence>
+ <xs:element name="code" type="xs:string"/>
+ <xs:element name="faultString" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
Copied: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_06.xml (from rev 20828, 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/internal/soa/esb/webservice/jbossesb_config_06.xml (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_06.xml 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,18 @@
+<?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">
+ <services>
+ <service category="FirstServiceESB" name="SimpleListener"
+ description="Hello World" invmScope="GLOBAL">>
+ <actions
+ inXsd="/org/jboss/internal/soa/esb/webservice/request.xsd"
+ outXsd="/org/jboss/internal/soa/esb/webservice/request.xsd"
+ faultXsd="/org/jboss/internal/soa/esb/webservice/fault.xsd">
+ <action name="action2"
+ class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull" value="true" />
+ </action>
+ </actions>
+ </service>
+ </services>
+</jbossesb>
Copied: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/request.xsd (from rev 20828, labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/request.xsd)
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/request.xsd (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/request.xsd 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="sayHi" type="x1:sayHi"/>
+ <xs:complexType name="sayHi">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
Copied: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/response.xsd (from rev 20828, labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/response.xsd)
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/response.xsd (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/response.xsd 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,8 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="sayHiReponse" type="x1:sayHiReponse"/>
+ <xs:complexType name="sayHiReponse">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
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-07-01 04:44:47 UTC (rev 20852)
+++ labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/build.xml 2008-07-01 09:10:44 UTC (rev 20853)
@@ -42,7 +42,7 @@
<fileset dir="${basedir}" includes="deployment.xml" />
</copy>
<copy todir="${build.dir}">
- <fileset dir="${basedir}" includes="request.xsd" />
+ <fileset dir="${basedir}" includes="*.xsd" />
</copy>
</target>
Added: labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/fault.xsd
===================================================================
--- labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/fault.xsd (rev 0)
+++ labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/fault.xsd 2008-07-01 09:10:44 UTC (rev 20853)
@@ -0,0 +1,9 @@
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/sayHi" xmlns:x1="http://www.jboss.org/sayHi" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="sayFault" type="x1:fault"/>
+ <xs:complexType name="fault">
+ <xs:sequence>
+ <xs:element name="code" type="xs:string"/>
+ <xs:element name="faultString" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
Modified: labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/jboss-esb.xml 2008-07-01 04:44:47 UTC (rev 20852)
+++ labs/jbossesb/workspace/jimma/product/samples/quickstarts/helloworld_pub_service/jboss-esb.xml 2008-07-01 09:10:44 UTC (rev 20853)
@@ -24,7 +24,7 @@
maxThreads="1"
/>
</listeners>
- <actions mep="OneWay" inXsd="/request.xsd">
+ <actions inXsd="/request.xsd" outXsd="/response.xsd" faultXsd="/fault.xsd">
<action name="action1"
class="org.jboss.soa.esb.samples.quickstart.helloworld.MyJMSListenerAction"
process="displayMessage"
More information about the jboss-svn-commits
mailing list