savara SVN: r51 - in tools/eclipse/trunk: plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator and 4 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-16 19:21:50 -0400 (Fri, 16 Oct 2009)
New Revision: 51
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java
Modified:
tools/eclipse/trunk/
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/META-INF/MANIFEST.MF
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
Log:
Added WSDL service generation, with a port per binding. Set the port type on the binding. Added initial mechanism for defining specific binding details (default will be SOAP RPC).
Property changes on: tools/eclipse/trunk
___________________________________________________________________
Name: svn:ignore
+ .project
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-16 13:35:32 UTC (rev 50)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-16 23:21:50 UTC (rev 51)
@@ -24,6 +24,7 @@
import org.jboss.savara.tools.bpel.generator.BuildSystem;
import org.jboss.savara.tools.bpel.model.*;
import org.jboss.savara.tools.bpel.util.XMLUtils;
+import org.jboss.savara.tools.wsdl.soap.SOAPRPCWSDLBinding;
import org.scribble.contract.model.Contract;
import org.scribble.conversation.model.*;
import org.scribble.extensions.RegistryFactory;
@@ -216,7 +217,8 @@
new org.jboss.savara.tools.wsdl.WSDLGenerator();
Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
- java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract);
+ java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract,
+ new SOAPRPCWSDLBinding());
for (int i=defns.size()-1; i >= 0; i--) {
javax.wsdl.Definition defn=defns.get(i);
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/META-INF/MANIFEST.MF
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/META-INF/MANIFEST.MF 2009-10-16 13:35:32 UTC (rev 50)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/META-INF/MANIFEST.MF 2009-10-16 23:21:50 UTC (rev 51)
@@ -11,4 +11,5 @@
org.scribble.contract.model;bundle-version="0.1.0",
org.apache.commons.logging;bundle-version="1.0.4",
org.scribble.core;bundle-version="0.1.0"
-Export-Package: org.jboss.savara.tools.wsdl
+Export-Package: org.jboss.savara.tools.wsdl,
+ org.jboss.savara.tools.wsdl.soap
Added: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java 2009-10-16 23:21:50 UTC (rev 51)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.
+ */
+package org.jboss.savara.tools.wsdl;
+
+/**
+ * This interface is used to establish binding information on a
+ * WSDL definition.
+ *
+ */
+public interface WSDLBinding {
+
+ /**
+ * This method returns the name of the WSDL binding implementation.
+ *
+ * @return The WSDL binding
+ */
+ public String getName();
+
+ /**
+ * This method initializes the WSDL definition for the binding.
+ *
+ * @param defn The definition
+ */
+ public void initDefinition(javax.wsdl.Definition defn);
+
+ /**
+ * This method adds WSDL binding information to the port binding.
+ *
+ * @param defn The definition
+ * @param binding The port type
+ */
+ public void updateBinding(javax.wsdl.Definition defn, javax.wsdl.Binding binding);
+
+ /**
+ * This method adds WSDL binding information to the operation.
+ *
+ * @param defn The definition
+ * @param operation The operation
+ */
+ public void updateOperation(javax.wsdl.Definition defn, javax.wsdl.Operation operation);
+
+ /**
+ * This method adds WSDL binding information to the input.
+ *
+ * @param defn The definition
+ * @param input The input
+ */
+ public void updateInput(javax.wsdl.Definition defn, javax.wsdl.Input input);
+
+ /**
+ * This method adds WSDL binding information to the output.
+ *
+ * @param defn The definition
+ * @param output The output
+ */
+ public void updateOutput(javax.wsdl.Definition defn, javax.wsdl.Output output);
+
+ /**
+ * This method adds WSDL binding information to the fault.
+ *
+ * @param defn The definition
+ * @param fault The fault
+ */
+ public void updateFault(javax.wsdl.Definition defn, javax.wsdl.Fault fault);
+
+}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-16 13:35:32 UTC (rev 50)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-16 23:21:50 UTC (rev 51)
@@ -40,24 +40,43 @@
* This method generates a WSDL definition from a Scribble contract model.
*
* @param contract The contract model
+ * @param wsdlBinding The WSDL binding to use, or null if no binding
* @return The WSDL definition
*/
- public java.util.List<javax.wsdl.Definition> generateDefinitions(org.scribble.contract.model.Contract contract) {
+ public java.util.List<javax.wsdl.Definition> generateDefinitions(org.scribble.contract.model.Contract contract,
+ WSDLBinding wsdlBinding) {
java.util.List<javax.wsdl.Definition> ret=new java.util.Vector<javax.wsdl.Definition>();
try {
// Create definition for contract's target namespace
- javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace());
+ javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace(), wsdlBinding);
+ // Create service
+ javax.wsdl.Service service=main.createService();
+ service.setQName(new javax.xml.namespace.QName(contract.getNamespace(),
+ contract.getName()+"Service"));
+
+ main.addService(service);
+
// Define a port type per interface
for (int i=0; i < contract.getInterfaces().size(); i++) {
- createPortType(ret, contract, contract.getInterfaces().get(i));
+ javax.wsdl.PortType portType=
+ createPortType(ret, contract, contract.getInterfaces().get(i),
+ wsdlBinding);
- createBinding(ret, contract, contract.getInterfaces().get(i));
+ javax.wsdl.Binding binding=
+ createBinding(ret, contract, contract.getInterfaces().get(i),
+ portType, wsdlBinding);
+
+ // Create service port for interface
+ javax.wsdl.Port port=main.createPort();
+
+ port.setName(contract.getInterfaces().get(i).getName()+"Port");
+ port.setBinding(binding);
+
+ service.addPort(port);
}
- // TODO: Add service with port type bindings
-
} catch(Exception e) {
logger.error("Failed to generate WSDL", e);
}
@@ -71,10 +90,12 @@
* @param wsdls The list of current WSDL definitions
* @param contract The contract
* @param targetNamespace The target namespace
+ * @param wsdlBinding The WSDL binding to use, or null if no binding
* @return The WSDL definition for the target namespace, or null if unable to find or create
*/
protected javax.wsdl.Definition getDefinition(java.util.List<javax.wsdl.Definition> wsdls,
- org.scribble.contract.model.Contract contract, String targetNamespace) {
+ org.scribble.contract.model.Contract contract, String targetNamespace,
+ WSDLBinding wsdlBinding) {
javax.wsdl.Definition ret=null;
if (targetNamespace != null) {
@@ -91,6 +112,12 @@
ret = createDefinition(contract, targetNamespace);
if (ret != null) {
+
+ // Initialize definition using the WSDL binding
+ if (wsdlBinding != null) {
+ wsdlBinding.initDefinition(ret);
+ }
+
wsdls.add(ret);
}
}
@@ -148,11 +175,12 @@
*/
public javax.wsdl.PortType createPortType(java.util.List<javax.wsdl.Definition> wsdls,
org.scribble.contract.model.Contract contract,
- org.scribble.contract.model.Interface intf) {
+ org.scribble.contract.model.Interface intf,
+ WSDLBinding wsdlBinding) {
javax.wsdl.PortType ret=null;
if (intf != null) {
- javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace());
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
if (defn != null) {
ret = defn.createPortType();
@@ -164,7 +192,7 @@
for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
createOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i));
+ intf.getMessageExchangePatterns().get(i), wsdlBinding);
}
// Only add portType to definition if they have atleast one operation
@@ -184,20 +212,28 @@
* @param wsdls The list of current WSDL definitions
* @param contract The contract
* @param intf The interface model
+ * @param portType The port type
* @return The WSDL port type binding
*/
public javax.wsdl.Binding createBinding(java.util.List<javax.wsdl.Definition> wsdls,
org.scribble.contract.model.Contract contract,
- org.scribble.contract.model.Interface intf) {
+ org.scribble.contract.model.Interface intf,
+ javax.wsdl.PortType portType,
+ WSDLBinding wsdlBinding) {
javax.wsdl.Binding ret=null;
if (intf != null) {
- javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace());
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace(), wsdlBinding);
if (defn != null) {
ret = defn.createBinding();
ret.setUndefined(false);
+ // Check if WSDL binding details
+ if (wsdlBinding != null) {
+ wsdlBinding.updateBinding(defn, ret);
+ }
+
// TODO: Need to make binding configurable
if (intf.getName() != null) {
@@ -205,9 +241,11 @@
intf.getName()+SOAP_BINDING_SUFFIX));
}
+ ret.setPortType(portType);
+
for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
createBindingOperation(wsdls, contract, ret,
- intf.getMessageExchangePatterns().get(i));
+ intf.getMessageExchangePatterns().get(i), wsdlBinding);
}
// Only add portType to definition if they have atleast one operation
@@ -232,13 +270,14 @@
*/
public javax.wsdl.Operation createOperation(java.util.List<javax.wsdl.Definition> wsdls,
org.scribble.contract.model.Contract contract, javax.wsdl.PortType portType,
- org.scribble.contract.model.MessageExchangePattern mep) {
+ org.scribble.contract.model.MessageExchangePattern mep,
+ WSDLBinding wsdlBinding) {
javax.wsdl.Operation ret=null;
javax.wsdl.Definition defn=null;
if (portType != null) {
- defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI());
+ defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI(), wsdlBinding);
}
if (defn != null && mep != null) {
@@ -247,7 +286,7 @@
ret.setName(mep.getOperation());
- javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes());
+ javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes(), wsdlBinding);
if (mesg != null) {
javax.wsdl.Input input=defn.createInput();
@@ -259,7 +298,7 @@
if (mep instanceof RequestResponseMEP) {
RequestResponseMEP rr=(RequestResponseMEP)mep;
- javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes());
+ javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes(), wsdlBinding);
if (om != null) {
javax.wsdl.Output output=defn.createOutput();
output.setMessage(om);
@@ -271,7 +310,7 @@
for (int i=0; i < rr.getFaultDetails().size(); i++) {
FaultDetails fd=rr.getFaultDetails().get(i);
- javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes());
+ javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes(), wsdlBinding);
if (fm != null) {
javax.wsdl.Fault fault=defn.createFault();
fault.setName(fd.getName());
@@ -301,13 +340,14 @@
*/
public javax.wsdl.BindingOperation createBindingOperation(java.util.List<javax.wsdl.Definition> wsdls,
org.scribble.contract.model.Contract contract, javax.wsdl.Binding binding,
- org.scribble.contract.model.MessageExchangePattern mep) {
+ org.scribble.contract.model.MessageExchangePattern mep,
+ WSDLBinding wsdlBinding) {
javax.wsdl.BindingOperation ret=null;
javax.wsdl.Definition defn=null;
if (binding != null) {
- defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI());
+ defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI(), wsdlBinding);
}
if (defn != null && mep != null) {
@@ -316,7 +356,7 @@
ret.setName(mep.getOperation());
- javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes());
+ javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes(), wsdlBinding);
if (mesg != null) {
javax.wsdl.BindingInput input=defn.createBindingInput();
@@ -327,7 +367,7 @@
if (mep instanceof RequestResponseMEP) {
RequestResponseMEP rr=(RequestResponseMEP)mep;
- javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes());
+ javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes(), wsdlBinding);
if (om != null) {
javax.wsdl.BindingOutput output=defn.createBindingOutput();
ret.setBindingOutput(output);
@@ -338,7 +378,7 @@
for (int i=0; i < rr.getFaultDetails().size(); i++) {
FaultDetails fd=rr.getFaultDetails().get(i);
- javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes());
+ javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes(), wsdlBinding);
if (fm != null) {
javax.wsdl.BindingFault fault=defn.createBindingFault();
fault.setName(fd.getName());
@@ -373,7 +413,8 @@
*/
public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
org.scribble.contract.model.Contract contract,
- java.util.List<TypeReference> types) {
+ java.util.List<TypeReference> types,
+ WSDLBinding wsdlBinding) {
javax.wsdl.Message ret=null;
if (types != null && types.size() > 0) {
@@ -384,7 +425,7 @@
TypeReference ref=types.get(0);
qname = new javax.xml.namespace.QName(ref.getNamespace(),ref.getLocalpart());
- defn = getDefinition(wsdls, contract, ref.getNamespace());
+ defn = getDefinition(wsdls, contract, ref.getNamespace(), wsdlBinding);
} else {
throw new UnsupportedOperationException("Currently only supports single type reference");
}
Added: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java 2009-10-16 23:21:50 UTC (rev 51)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.
+ */
+package org.jboss.savara.tools.wsdl.soap;
+
+import org.jboss.savara.tools.wsdl.WSDLBinding;
+
+/**
+ * This interface is used to establish binding information on a
+ * WSDL definition.
+ *
+ */
+public class SOAPRPCWSDLBinding implements WSDLBinding {
+
+ /**
+ * This method returns the name of the WSDL binding implementation.
+ *
+ * @return The WSDL binding
+ */
+ public String getName() {
+ return("SOAP RPC");
+ }
+
+ /**
+ * This method initializes the WSDL definition for the binding.
+ *
+ * @param defn The definition
+ */
+ public void initDefinition(javax.wsdl.Definition defn) {
+ defn.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+ }
+
+ /**
+ * This method adds WSDL binding information to the port binding.
+ *
+ * @param defn The definition
+ * @param binding The port type
+ */
+ public void updateBinding(javax.wsdl.Definition defn, javax.wsdl.Binding binding) {
+ /*
+ org.w3c.dom.Element sb=binding.getDocumentationElement().getOwnerDocument().
+ createElementNS("http://schemas.xmlsoap.org/wsdl/soap/", "binding");
+ sb.setAttribute("style", "rpc");
+ sb.setAttribute("transport", "http://schemas.xmlsoap.org/soap/http");
+ binding.getDocumentationElement().appendChild(sb);
+ */
+ }
+
+ /**
+ * This method adds WSDL binding information to the operation.
+ *
+ * @param defn The definition
+ * @param operation The operation
+ */
+ public void updateOperation(javax.wsdl.Definition defn, javax.wsdl.Operation operation) {
+
+ }
+
+ /**
+ * This method adds WSDL binding information to the input.
+ *
+ * @param defn The definition
+ * @param input The input
+ */
+ public void updateInput(javax.wsdl.Definition defn, javax.wsdl.Input input) {
+
+ }
+
+ /**
+ * This method adds WSDL binding information to the output.
+ *
+ * @param defn The definition
+ * @param output The output
+ */
+ public void updateOutput(javax.wsdl.Definition defn, javax.wsdl.Output output) {
+
+ }
+
+ /**
+ * This method adds WSDL binding information to the fault.
+ *
+ * @param defn The definition
+ * @param fault The fault
+ */
+ public void updateFault(javax.wsdl.Definition defn, javax.wsdl.Fault fault) {
+
+ }
+
+}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-16 13:35:32 UTC (rev 50)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-16 23:21:50 UTC (rev 51)
@@ -41,7 +41,7 @@
WSDLGenerator gen=new WSDLGenerator();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
if (defns.size() != 1) {
fail("Only one Definition found: "+defns.size());
@@ -80,7 +80,7 @@
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
- javax.wsdl.PortType result=gen.createPortType(defns, new Contract(), src);
+ javax.wsdl.PortType result=gen.createPortType(defns, new Contract(), src, null);
if (result == null) {
fail("PortType is null");
@@ -117,7 +117,7 @@
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
- javax.wsdl.Binding result=gen.createBinding(defns, new Contract(), src);
+ javax.wsdl.Binding result=gen.createBinding(defns, new Contract(), src, null, null);
if (result == null) {
fail("PortType is null");
@@ -202,7 +202,7 @@
WSDLGenerator gen=new WSDLGenerator();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
if (defns.size() != 1) {
fail("Only one Definition found: "+defns.size());
@@ -254,7 +254,7 @@
javax.wsdl.PortType ptype=defn.createPortType();
ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
- javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src);
+ javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src, null);
if (result == null) {
fail("Operation is null");
@@ -333,7 +333,7 @@
javax.wsdl.PortType ptype=defn.createPortType();
ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
- javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src);
+ javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src, null);
if (result == null) {
fail("Operation is null");
@@ -380,7 +380,7 @@
java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
- javax.wsdl.Message result=gen.getMessage(defns, new Contract(), refs);
+ javax.wsdl.Message result=gen.getMessage(defns, new Contract(), refs, null);
if (result == null) {
fail("Message is null");
@@ -465,7 +465,7 @@
WSDLGenerator gen=new WSDLGenerator();
- java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
if (defns.size() != 3) {
fail("Four Definitions expected, but got: "+defns.size());
@@ -521,5 +521,24 @@
fail("3: Number of message ("+defn3.getMessages().size()+
") does not match number expected (1)");
}
+
+ // Check service only associated with the first defn
+ if (defn1.getServices().size() != 1) {
+ fail("First definition should only have 1 service: "+defn1.getServices().size());
+ }
+
+ javax.wsdl.Service s=(javax.wsdl.Service)
+ defn1.getServices().values().iterator().next();
+ if (s.getPorts().size() != 3) {
+ fail("Should be 3 ports: "+s.getPorts().size());
+ }
+
+ if (defn2.getServices().size() != 0) {
+ fail("Second definition should not have any services: "+defn2.getServices().size());
+ }
+
+ if (defn3.getServices().size() != 0) {
+ fail("Third definition should not have any services: "+defn3.getServices().size());
+ }
}
}
16 years, 6 months
savara SVN: r50 - tools/eclipse/trunk.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:35:32 -0400 (Fri, 16 Oct 2009)
New Revision: 50
Removed:
tools/eclipse/trunk/eclipse/
Log:
* remove eclipse folder
16 years, 6 months
savara SVN: r49 - in tools/eclipse/trunk: eclipse and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:33:58 -0400 (Fri, 16 Oct 2009)
New Revision: 49
Added:
tools/eclipse/trunk/plugins/
Removed:
tools/eclipse/trunk/eclipse/plugins/
Log:
Copied: tools/eclipse/trunk/plugins (from rev 48, tools/eclipse/trunk/eclipse/plugins)
16 years, 6 months
savara SVN: r48 - in tools/eclipse/trunk: eclipse and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:32:35 -0400 (Fri, 16 Oct 2009)
New Revision: 48
Added:
tools/eclipse/trunk/features/
Removed:
tools/eclipse/trunk/eclipse/features/
Log:
Copied: tools/eclipse/trunk/features (from rev 47, tools/eclipse/trunk/eclipse/features)
16 years, 6 months
savara SVN: r47 - /.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:29:14 -0400 (Fri, 16 Oct 2009)
New Revision: 47
Removed:
tags/
Log:
* remove tags
16 years, 6 months
savara SVN: r46 - /.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:27:32 -0400 (Fri, 16 Oct 2009)
New Revision: 46
Removed:
branches/
Log:
* remove branches
16 years, 6 months
savara SVN: r45 - trunk/tools and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:26:53 -0400 (Fri, 16 Oct 2009)
New Revision: 45
Added:
tools/eclipse/trunk/eclipse/
Removed:
trunk/tools/eclipse/
Log:
* move the eclipse tool into its sub-project.
Copied: tools/eclipse/trunk/eclipse (from rev 44, trunk/tools/eclipse)
16 years, 6 months
savara SVN: r44 - runtime and 4 other directories.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-10-16 09:19:40 -0400 (Fri, 16 Oct 2009)
New Revision: 44
Added:
runtime/
runtime/branches/
runtime/tags/
runtime/trunk/
tools/
tools/eclipse/
tools/eclipse/branches/
tools/eclipse/tags/
tools/eclipse/trunk/
tools/web/
tools/web/branches/
tools/web/tags/
tools/web/trunk/
validator/
validator/branches/
validator/tags/
validator/trunk/
Log:
* svn restructure.
16 years, 6 months
savara SVN: r43 - in trunk/tools/eclipse/plugins: org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl and 1 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-13 16:40:30 -0400 (Tue, 13 Oct 2009)
New Revision: 43
Modified:
trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
Log:
Added import statement for main wsdl, and port type bindings (currently without soap extensions).
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-12 21:27:38 UTC (rev 42)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-13 20:40:30 UTC (rev 43)
@@ -218,11 +218,24 @@
java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract);
- for (int i=0; i < defns.size(); i++) {
+ for (int i=defns.size()-1; i >= 0; i--) {
javax.wsdl.Definition defn=defns.get(i);
// Check if definition has a port type
- if (defn.getPortTypes().size() > 0) {
+ if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0) {
+ String filename=localcm.getModelName().getName()+"_"+
+ role.getName()+i+".wsdl";
+
+ if (i > 0) {
+ javax.wsdl.Import imp=defns.get(0).createImport();
+
+ imp.setDefinition(defn);
+ imp.setNamespaceURI(defn.getTargetNamespace());
+ imp.setLocationURI(filename);
+
+ defns.get(0).addImport(imp);
+ }
+
java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
writer.writeWSDL(defn, baos);
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-12 21:27:38 UTC (rev 42)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-13 20:40:30 UTC (rev 43)
@@ -30,6 +30,7 @@
*/
public class WSDLGenerator {
+ public static final String SOAP_BINDING_SUFFIX = "SOAPBinding";
private static Log logger = LogFactory.getLog(WSDLGenerator.class);
public WSDLGenerator() {
@@ -51,6 +52,8 @@
// Define a port type per interface
for (int i=0; i < contract.getInterfaces().size(); i++) {
createPortType(ret, contract, contract.getInterfaces().get(i));
+
+ createBinding(ret, contract, contract.getInterfaces().get(i));
}
// TODO: Add service with port type bindings
@@ -175,6 +178,49 @@
}
/**
+ * This method generates a port type binding, using the supplied WSDL definition,
+ * based on the information in the supplied interface definition.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param intf The interface model
+ * @return The WSDL port type binding
+ */
+ public javax.wsdl.Binding createBinding(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract,
+ org.scribble.contract.model.Interface intf) {
+ javax.wsdl.Binding ret=null;
+
+ if (intf != null) {
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace());
+
+ if (defn != null) {
+ ret = defn.createBinding();
+ ret.setUndefined(false);
+
+ // TODO: Need to make binding configurable
+
+ if (intf.getName() != null) {
+ ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(),
+ intf.getName()+SOAP_BINDING_SUFFIX));
+ }
+
+ for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+ createBindingOperation(wsdls, contract, ret,
+ intf.getMessageExchangePatterns().get(i));
+ }
+
+ // Only add portType to definition if they have atleast one operation
+ if (ret != null && ret.getBindingOperations().size() > 0) {
+ defn.addBinding(ret);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
* This method generates an operation, using the supplied WSDL definition,
* based on the information in the supplied message exchange pattern.
*
@@ -244,6 +290,72 @@
}
/**
+ * This method generates a binding operation, using the supplied WSDL definition,
+ * based on the information in the supplied message exchange pattern.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param binding The port type binding
+ * @param mep The message exchange pattern
+ * @return The WSDL binding operation
+ */
+ public javax.wsdl.BindingOperation createBindingOperation(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract, javax.wsdl.Binding binding,
+ org.scribble.contract.model.MessageExchangePattern mep) {
+ javax.wsdl.BindingOperation ret=null;
+
+ javax.wsdl.Definition defn=null;
+
+ if (binding != null) {
+ defn = getDefinition(wsdls, contract, binding.getQName().getNamespaceURI());
+ }
+
+ if (defn != null && mep != null) {
+ ret = defn.createBindingOperation();
+ //ret.setUndefined(false);
+
+ ret.setName(mep.getOperation());
+
+ javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes());
+
+ if (mesg != null) {
+ javax.wsdl.BindingInput input=defn.createBindingInput();
+ ret.setBindingInput(input);
+ }
+
+ // Check if a request/response MEP
+ if (mep instanceof RequestResponseMEP) {
+ RequestResponseMEP rr=(RequestResponseMEP)mep;
+
+ javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes());
+ if (om != null) {
+ javax.wsdl.BindingOutput output=defn.createBindingOutput();
+ ret.setBindingOutput(output);
+ }
+
+ // Generate fault details
+ if (rr.getFaultDetails() != null) {
+ for (int i=0; i < rr.getFaultDetails().size(); i++) {
+ FaultDetails fd=rr.getFaultDetails().get(i);
+
+ javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes());
+ if (fm != null) {
+ javax.wsdl.BindingFault fault=defn.createBindingFault();
+ fault.setName(fd.getName());
+
+ ret.addBindingFault(fault);
+ }
+ }
+ }
+ }
+
+ binding.addBindingOperation(ret);
+ }
+
+ return(ret);
+ }
+
+ /**
* This method returns a message, using the supplied WSDL definition,
* based on the information supplied in the list of type references. If
* a single type reference is supplied, this will be the message type,
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-12 21:27:38 UTC (rev 42)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-13 20:40:30 UTC (rev 43)
@@ -107,8 +107,45 @@
}
}
- public void testDefnWithPortTypes() {
+ public void testPortTypeBindingNameAndNamespace() {
+ Interface src=new Interface();
+ src.setName(TEST_NAME);
+ src.setNamespace(TEST_NAME_SPACE);
+
+ WSDLGenerator gen=new WSDLGenerator();
+
+ java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+
+ javax.wsdl.Binding result=gen.createBinding(defns, new Contract(), src);
+
+ if (result == null) {
+ fail("PortType is null");
+ }
+
+ if (result.getQName() == null) {
+ fail("QName not set");
+ }
+
+ if (result.getQName().getNamespaceURI() == null) {
+ fail("QName namespace not set");
+ }
+
+ if (TEST_NAME_SPACE.equals(result.getQName().getNamespaceURI()) == false) {
+ fail("Namespace not correct: "+result.getQName().getNamespaceURI());
+ }
+
+ if (result.getQName().getLocalPart() == null) {
+ fail("QName localpart not set");
+ }
+
+ if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGenerator.SOAP_BINDING_SUFFIX) == false) {
+ fail("QName localpart not correct: "+result.getQName().getLocalPart());
+ }
+ }
+
+ public void testDefnWithPortTypesAndBindings() {
+
Contract c=new Contract();
c.setNamespace(TEST_NAME_SPACE);
@@ -178,6 +215,12 @@
") does not match number of interfaces ("+
c.getInterfaces().size()+")");
}
+
+ if (defn.getBindings().size() != c.getInterfaces().size()) {
+ fail("Number of port type bindings ("+defn.getBindings().size()+
+ ") does not match number of interfaces ("+
+ c.getInterfaces().size()+")");
+ }
}
public void testOperationOneWay() {
@@ -435,6 +478,11 @@
") does not match number expected (1)");
}
+ if (defn1.getBindings().size() != 1) {
+ fail("1: Number of port type bindings ("+defn1.getBindings().size()+
+ ") does not match number expected (1)");
+ }
+
if (defn1.getMessages().size() != 1) {
fail("1: Number of message ("+defn1.getMessages().size()+
") does not match number expected (1)");
@@ -447,6 +495,11 @@
") does not match number expected (2)");
}
+ if (defn2.getBindings().size() != 2) {
+ fail("2: Number of port type bindings ("+defn2.getBindings().size()+
+ ") does not match number expected (2)");
+ }
+
if (defn2.getMessages().size() != 1) {
fail("2: Number of message ("+defn2.getMessages().size()+
") does not match number expected (1)");
@@ -459,6 +512,11 @@
") does not match number expected (0)");
}
+ if (defn3.getBindings().size() != 0) {
+ fail("3: Number of port type bindings ("+defn3.getBindings().size()+
+ ") does not match number expected (0)");
+ }
+
if (defn3.getMessages().size() != 1) {
fail("3: Number of message ("+defn3.getMessages().size()+
") does not match number expected (1)");
16 years, 6 months
savara SVN: r42 - in trunk/tools/eclipse/plugins: org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl and 1 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-12 17:27:38 -0400 (Mon, 12 Oct 2009)
New Revision: 42
Modified:
trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
Log:
Enable multiple WSDL files to be generated from a contract, based on their namespaces.
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-10 21:11:20 UTC (rev 41)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-12 21:27:38 UTC (rev 42)
@@ -216,30 +216,34 @@
new org.jboss.savara.tools.wsdl.WSDLGenerator();
Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
- javax.wsdl.Definition defn=generator.generateDefinition(contract);
+ java.util.List<javax.wsdl.Definition> defns=generator.generateDefinitions(contract);
- // Check if definition has a port type
- if (defn.getPortTypes().size() > 0) {
- java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
-
- writer.writeWSDL(defn, baos);
-
- byte[] b=baos.toByteArray();
-
- baos.close();
-
- IPath wsdlPath=proj.getFullPath().append(
- new Path(getBuildSystem().getBPELFilePath())).
- append(localcm.getModelName().getName()+"_"+
- role.getName()+".wsdl");
-
- IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
- GeneratorUtil.createParentFolder(wsdlFile);
- wsdlFile.create(null, true,
- new org.eclipse.core.runtime.NullProgressMonitor());
-
- wsdlFile.setContents(new java.io.ByteArrayInputStream(b), true, false,
+ for (int i=0; i < defns.size(); i++) {
+ javax.wsdl.Definition defn=defns.get(i);
+
+ // Check if definition has a port type
+ if (defn.getPortTypes().size() > 0) {
+ java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
+
+ writer.writeWSDL(defn, baos);
+
+ byte[] b=baos.toByteArray();
+
+ baos.close();
+
+ IPath wsdlPath=proj.getFullPath().append(
+ new Path(getBuildSystem().getBPELFilePath())).
+ append(localcm.getModelName().getName()+"_"+
+ role.getName()+i+".wsdl");
+
+ IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+ GeneratorUtil.createParentFolder(wsdlFile);
+ wsdlFile.create(null, true,
new org.eclipse.core.runtime.NullProgressMonitor());
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(b), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
}
}
}
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-10 21:11:20 UTC (rev 41)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-12 21:27:38 UTC (rev 42)
@@ -41,20 +41,84 @@
* @param contract The contract model
* @return The WSDL definition
*/
- public javax.wsdl.Definition generateDefinition(org.scribble.contract.model.Contract contract) {
+ public java.util.List<javax.wsdl.Definition> generateDefinitions(org.scribble.contract.model.Contract contract) {
+ java.util.List<javax.wsdl.Definition> ret=new java.util.Vector<javax.wsdl.Definition>();
+
+ try {
+ // Create definition for contract's target namespace
+ javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace());
+
+ // Define a port type per interface
+ for (int i=0; i < contract.getInterfaces().size(); i++) {
+ createPortType(ret, contract, contract.getInterfaces().get(i));
+ }
+
+ // TODO: Add service with port type bindings
+
+ } catch(Exception e) {
+ logger.error("Failed to generate WSDL", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the definition associated with the supplied target namespace.
+ *
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param targetNamespace The target namespace
+ * @return The WSDL definition for the target namespace, or null if unable to find or create
+ */
+ protected javax.wsdl.Definition getDefinition(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract, String targetNamespace) {
javax.wsdl.Definition ret=null;
+ if (targetNamespace != null) {
+ for (int i=0; ret == null && i < wsdls.size(); i++) {
+ ret = wsdls.get(i);
+
+ if (ret.getTargetNamespace() == null ||
+ ret.getTargetNamespace().equals(targetNamespace) == false) {
+ ret = null;
+ }
+ }
+
+ if (ret == null) {
+ ret = createDefinition(contract, targetNamespace);
+
+ if (ret != null) {
+ wsdls.add(ret);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method creates a new WSDL definition associated with the supplied
+ * target namespace.
+ *
+ * @param contract The contract
+ * @param targetNamespace The target namespace
+ * @return The WSDL definition
+ */
+ protected javax.wsdl.Definition createDefinition(org.scribble.contract.model.Contract contract,
+ String targetNamespace) {
+ javax.wsdl.Definition ret=null;
+
try {
javax.wsdl.factory.WSDLFactory fact=
- javax.wsdl.factory.WSDLFactory.newInstance();
-
+ javax.wsdl.factory.WSDLFactory.newInstance();
+
ret = fact.newDefinition();
// Set details on the definition
if (contract.getName() != null) {
ret.setQName(new javax.xml.namespace.QName(contract.getName()));
}
- ret.setTargetNamespace(contract.getNamespace());
+ ret.setTargetNamespace(targetNamespace);
// Set up namespace mappings
for (int i=0; i < contract.getNamespaces().size(); i++) {
@@ -62,51 +126,48 @@
ret.addNamespace(ns.getPrefix(), ns.getURI());
}
-
- // Define a port type per interface
- for (int i=0; i < contract.getInterfaces().size(); i++) {
- javax.wsdl.PortType ptype=generatePortType(ret, contract.getInterfaces().get(i));
-
- // Only add portType to definition if they have atleast one operation
- if (ptype != null && ptype.getOperations().size() > 0) {
- ret.addPortType(ptype);
- }
- }
-
+
} catch(Exception e) {
- logger.error("Failed to generate WSDL", e);
+ logger.error("Failed to create WSDL definition for target namespace '"+targetNamespace+"'", e);
}
-
+
return(ret);
}
/**
* This method generates a port type, using the supplied WSDL definition,
- * based on the information in the supplied interface definition. Note that
- * the port type is not automatically added to the definition.
+ * based on the information in the supplied interface definition.
*
- * @param defn The WSDL definition used to create the port type
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
* @param intf The interface model
* @return The WSDL port type
*/
- public javax.wsdl.PortType generatePortType(javax.wsdl.Definition defn,
+ public javax.wsdl.PortType createPortType(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract,
org.scribble.contract.model.Interface intf) {
javax.wsdl.PortType ret=null;
- if (defn != null && intf != null) {
- ret = defn.createPortType();
- ret.setUndefined(false);
-
- if (intf.getName() != null) {
- ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), intf.getName()));
- }
-
- for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
- javax.wsdl.Operation op=generateOperation(defn,
- intf.getMessageExchangePatterns().get(i));
- if (op != null) {
- ret.addOperation(op);
+ if (intf != null) {
+ javax.wsdl.Definition defn=getDefinition(wsdls, contract, intf.getNamespace());
+
+ if (defn != null) {
+ ret = defn.createPortType();
+ ret.setUndefined(false);
+
+ if (intf.getName() != null) {
+ ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(), intf.getName()));
}
+
+ for (int i=0; i < intf.getMessageExchangePatterns().size(); i++) {
+ createOperation(wsdls, contract, ret,
+ intf.getMessageExchangePatterns().get(i));
+ }
+
+ // Only add portType to definition if they have atleast one operation
+ if (ret != null && ret.getOperations().size() > 0) {
+ defn.addPortType(ret);
+ }
}
}
@@ -117,13 +178,22 @@
* This method generates an operation, using the supplied WSDL definition,
* based on the information in the supplied message exchange pattern.
*
- * @param defn The WSDL definition
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
+ * @param portType The port type
* @param mep The message exchange pattern
* @return The WSDL operation
*/
- public javax.wsdl.Operation generateOperation(javax.wsdl.Definition defn,
+ public javax.wsdl.Operation createOperation(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract, javax.wsdl.PortType portType,
org.scribble.contract.model.MessageExchangePattern mep) {
javax.wsdl.Operation ret=null;
+
+ javax.wsdl.Definition defn=null;
+
+ if (portType != null) {
+ defn = getDefinition(wsdls, contract, portType.getQName().getNamespaceURI());
+ }
if (defn != null && mep != null) {
ret = defn.createOperation();
@@ -131,7 +201,7 @@
ret.setName(mep.getOperation());
- javax.wsdl.Message mesg=getMessage(defn, mep.getTypes());
+ javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes());
if (mesg != null) {
javax.wsdl.Input input=defn.createInput();
@@ -143,7 +213,7 @@
if (mep instanceof RequestResponseMEP) {
RequestResponseMEP rr=(RequestResponseMEP)mep;
- javax.wsdl.Message om=getMessage(defn, rr.getResponseTypes());
+ javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes());
if (om != null) {
javax.wsdl.Output output=defn.createOutput();
output.setMessage(om);
@@ -155,7 +225,7 @@
for (int i=0; i < rr.getFaultDetails().size(); i++) {
FaultDetails fd=rr.getFaultDetails().get(i);
- javax.wsdl.Message fm=getMessage(defn, fd.getTypes());
+ javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes());
if (fm != null) {
javax.wsdl.Fault fault=defn.createFault();
fault.setName(fd.getName());
@@ -166,6 +236,8 @@
}
}
}
+
+ portType.addOperation(ret);
}
return(ret);
@@ -182,20 +254,25 @@
* does not exist prior to the call to this method, then it will be
* created and added to the definition upon returning the message.
*
- * @param defn The WSDL definition
+ * @param wsdls The list of current WSDL definitions
+ * @param contract The contract
* @param types The list of type references
* @return The WSDL message
*/
- public javax.wsdl.Message getMessage(javax.wsdl.Definition defn,
+ public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
+ org.scribble.contract.model.Contract contract,
java.util.List<TypeReference> types) {
javax.wsdl.Message ret=null;
- if (defn != null && types != null && types.size() > 0) {
+ if (types != null && types.size() > 0) {
javax.xml.namespace.QName qname=null;
+ javax.wsdl.Definition defn=null;
if (types.size() == 1) {
TypeReference ref=types.get(0);
qname = new javax.xml.namespace.QName(ref.getNamespace(),ref.getLocalpart());
+
+ defn = getDefinition(wsdls, contract, ref.getNamespace());
} else {
throw new UnsupportedOperationException("Currently only supports single type reference");
}
Modified: trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-10 21:11:20 UTC (rev 41)
+++ trunk/tools/eclipse/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-12 21:27:38 UTC (rev 42)
@@ -28,6 +28,8 @@
private static final String TEST_TYPE_NS = "testTypeNS";
private static final String TEST_TYPE_LP = "testTypeLP";
private static final String TEST_NAME_SPACE = "testNameSpace";
+ private static final String TEST_NAME_SPACE2 = "testNameSpace2";
+ private static final String TEST_NAME_SPACE3 = "testNameSpace3";
private static final String TEST_NAME = "testName";
public void testDefnNameAndNamespace() {
@@ -39,12 +41,14 @@
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.Definition defn=gen.generateDefinition(c);
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
- if (defn == null) {
- fail("Definition is null");
+ if (defns.size() != 1) {
+ fail("Only one Definition found: "+defns.size());
}
+ javax.wsdl.Definition defn=defns.get(0);
+
if (defn.getTargetNamespace() == null) {
fail("Target namespace not set");
}
@@ -67,17 +71,6 @@
}
public void testPortTypeNameAndNamespace() {
- javax.wsdl.Definition defn=null;
- try {
- javax.wsdl.factory.WSDLFactory fact=
- javax.wsdl.factory.WSDLFactory.newInstance();
-
- defn = fact.newDefinition();
-
- } catch(Exception e) {
- fail("Failed to get definition");
- }
-
Interface src=new Interface();
src.setName(TEST_NAME);
@@ -85,8 +78,10 @@
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.PortType result=gen.generatePortType(defn, src);
+ java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+ javax.wsdl.PortType result=gen.createPortType(defns, new Contract(), src);
+
if (result == null) {
fail("PortType is null");
}
@@ -115,27 +110,68 @@
public void testDefnWithPortTypes() {
Contract c=new Contract();
+ c.setNamespace(TEST_NAME_SPACE);
Interface i1=new Interface();
i1.setName("I1");
+ i1.setNamespace(TEST_NAME_SPACE);
+ // Need to associate a message, to ensure port type
+ // is generated
+ OneWayRequestMEP m1=new OneWayRequestMEP();
+
+ m1.setOperation(TEST_NAME);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setLocalpart(TEST_TYPE_LP);
+ ref1.setNamespace(TEST_NAME_SPACE);
+ m1.getTypes().add(ref1);
+
+ i1.getMessageExchangePatterns().add(m1);
+
Interface i2=new Interface();
i2.setName("I2");
+ i2.setNamespace(TEST_NAME_SPACE);
+ OneWayRequestMEP m2=new OneWayRequestMEP();
+
+ m2.setOperation(TEST_NAME);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setLocalpart(TEST_TYPE_LP);
+ ref2.setNamespace(TEST_NAME_SPACE);
+ m2.getTypes().add(ref2);
+
+ i2.getMessageExchangePatterns().add(m2);
+
Interface i3=new Interface();
i3.setName("I3");
+ i3.setNamespace(TEST_NAME_SPACE);
+ OneWayRequestMEP m3=new OneWayRequestMEP();
+
+ m3.setOperation(TEST_NAME);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setLocalpart(TEST_TYPE_LP);
+ ref3.setNamespace(TEST_NAME_SPACE);
+ m3.getTypes().add(ref3);
+
+ i3.getMessageExchangePatterns().add(m3);
+
c.getInterfaces().add(i1);
c.getInterfaces().add(i2);
c.getInterfaces().add(i3);
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.Definition defn=gen.generateDefinition(c);
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
- if (defn == null) {
- fail("Definition is null");
+ if (defns.size() != 1) {
+ fail("Only one Definition found: "+defns.size());
}
+
+ javax.wsdl.Definition defn=defns.get(0);
if (defn.getPortTypes().size() != c.getInterfaces().size()) {
fail("Number of port types ("+defn.getPortTypes().size()+
@@ -167,8 +203,16 @@
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.Operation result=gen.generateOperation(defn, src);
+ java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+ defns.add(defn);
+ defn.setTargetNamespace(TEST_NAME_SPACE);
+
+ javax.wsdl.PortType ptype=defn.createPortType();
+ ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
+
+ javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src);
+
if (result == null) {
fail("Operation is null");
}
@@ -238,8 +282,16 @@
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.Operation result=gen.generateOperation(defn, src);
+ java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+ defns.add(defn);
+ defn.setTargetNamespace(TEST_NAME_SPACE);
+
+ javax.wsdl.PortType ptype=defn.createPortType();
+ ptype.setQName(new javax.xml.namespace.QName(TEST_NAME_SPACE, TEST_NAME));
+
+ javax.wsdl.Operation result=gen.createOperation(defns, new Contract(), ptype, src);
+
if (result == null) {
fail("Operation is null");
}
@@ -283,8 +335,10 @@
WSDLGenerator gen=new WSDLGenerator();
- javax.wsdl.Message result=gen.getMessage(defn, refs);
+ java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
+ javax.wsdl.Message result=gen.getMessage(defns, new Contract(), refs);
+
if (result == null) {
fail("Message is null");
}
@@ -309,4 +363,105 @@
fail("QName namespace not correct: "+result.getQName().getNamespaceURI());
}
}
+
+ public void testDefnWithPortTypesAndMesgsInDiffNamespaces() {
+
+ Contract c=new Contract();
+ c.setNamespace(TEST_NAME_SPACE);
+
+ Interface i1=new Interface();
+ i1.setName("I1");
+ i1.setNamespace(TEST_NAME_SPACE);
+
+ // Need to associate a message, to ensure port type
+ // is generated
+ OneWayRequestMEP m1=new OneWayRequestMEP();
+
+ m1.setOperation(TEST_NAME);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setLocalpart(TEST_TYPE_LP);
+ ref1.setNamespace(TEST_NAME_SPACE);
+ m1.getTypes().add(ref1);
+
+ i1.getMessageExchangePatterns().add(m1);
+
+ Interface i2=new Interface();
+ i2.setName("I2");
+ i2.setNamespace(TEST_NAME_SPACE2);
+
+ OneWayRequestMEP m2=new OneWayRequestMEP();
+
+ m2.setOperation(TEST_NAME);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setLocalpart(TEST_TYPE_LP);
+ ref2.setNamespace(TEST_NAME_SPACE2);
+ m2.getTypes().add(ref2);
+
+ i2.getMessageExchangePatterns().add(m2);
+
+ Interface i3=new Interface();
+ i3.setName("I3");
+ i3.setNamespace(TEST_NAME_SPACE2);
+
+ OneWayRequestMEP m3=new OneWayRequestMEP();
+
+ m3.setOperation(TEST_NAME);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setLocalpart(TEST_TYPE_LP);
+ ref3.setNamespace(TEST_NAME_SPACE3);
+ m3.getTypes().add(ref3);
+
+ i3.getMessageExchangePatterns().add(m3);
+
+ c.getInterfaces().add(i1);
+ c.getInterfaces().add(i2);
+ c.getInterfaces().add(i3);
+
+ WSDLGenerator gen=new WSDLGenerator();
+
+ java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c);
+
+ if (defns.size() != 3) {
+ fail("Four Definitions expected, but got: "+defns.size());
+ }
+
+ javax.wsdl.Definition defn1=defns.get(0);
+
+ if (defn1.getPortTypes().size() != 1) {
+ fail("1: Number of port types ("+defn1.getPortTypes().size()+
+ ") does not match number expected (1)");
+ }
+
+ if (defn1.getMessages().size() != 1) {
+ fail("1: Number of message ("+defn1.getMessages().size()+
+ ") does not match number expected (1)");
+ }
+
+ javax.wsdl.Definition defn2=defns.get(1);
+
+ if (defn2.getPortTypes().size() != 2) {
+ fail("2: Number of port types ("+defn2.getPortTypes().size()+
+ ") does not match number expected (2)");
+ }
+
+ if (defn2.getMessages().size() != 1) {
+ fail("2: Number of message ("+defn2.getMessages().size()+
+ ") does not match number expected (1)");
+ }
+
+ javax.wsdl.Definition defn3=defns.get(2);
+
+ if (defn3.getPortTypes().size() != 0) {
+ fail("3: Number of port types ("+defn3.getPortTypes().size()+
+ ") does not match number expected (0)");
+ }
+
+ if (defn3.getMessages().size() != 1) {
+ fail("3: Number of message ("+defn3.getMessages().size()+
+ ") does not match number expected (1)");
+ }
+ }
}
16 years, 6 months