You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2008/08/14 23:44:20 UTC
svn commit: r686054 - in
/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws:
WSDL2Ws.java info/WSDLInfo.java
Author: nadiramra
Date: Thu Aug 14 14:44:20 2008
New Revision: 686054
URL: http://svn.apache.org/viewvc?rev=686054&view=rev
Log:
Simplify, remove redundant code.
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java?rev=686054&r1=686053&r2=686054&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java Thu Aug 14 14:44:20 2008
@@ -89,11 +89,7 @@
private boolean c_userRequestedWSDLWrappingStyle = false;
private String c_targetoutputLocation = null;
private String c_targetEngine = null;
-
- private String c_targetEndpointURI = null;
-
- private BindingEntry c_bindingEntry;
-
+
// WSDL parser symbol table
private SymbolTable c_symbolTable;
@@ -111,12 +107,12 @@
System.out.println(
"java WSDL2Ws -<options> <wsdlfile>\n"
+ "-h, -help print this message\n"
- + "-o<folder> target output folder - default is current folder\n"
- + "-l<c++|c> target language (c++|c) - default is c++\n"
- + "-s<server|client> target side (server|client) - default is server\n"
- + "-v, -verbose be verbose\n"
- + "-t<timeout> uri resolution timeout in seconds - default is 0 (no timeout)\n"
- + "-w<wrapped|unwrapped> generate wrapper style or not - default is wrapped\n"
+ + "-o<folder> target output folder - default is current folder.\n"
+ + "-l<c++|c> target language (c++|c) - default is c++.\n"
+ + "-s<server|client> target side (server|client) - default is server.\n"
+ + "-v, -verbose be verbose.\n"
+ + "-t<timeout> uri resolution timeout in seconds - default is 0 (no timeout).\n"
+ + "-w<wrapped|unwrapped> generate wrapper style or not - default is wrapped.\n"
);
}
@@ -221,39 +217,9 @@
// At this time we require a service definition to be defined, but in
// future if not found that caller needs to specify a binding to use in
// order for us to generate the stubs. Not having service definition will
- // only result in not knowing the Web service endpoint, so it is really not necessary.
+ // only result in not knowing the Web service end point, so it is really not necessary.
if (c_wsdlInfo.getServices().size() == 0)
throw new WrapperFault("Service definition not found. A service definition must be specified.");
-
- // ==================================================
- // Get service definition
- // ==================================================
-
- Service service = (Service)c_wsdlInfo.getServices().get(0);
-
- // ==================================================
- // Get binding information
- // ==================================================
-
- //TODO resolve this
- // this code support only the service with one bindings it will not care about the
- // second binding if exists..resolve by letting user specify which binding to use.
- Iterator ports = service.getPorts().values().iterator();
- Binding binding = null;
- if (ports.hasNext())
- binding = ((Port) ports.next()).getBinding();
-
- if (binding == null)
- throw new WrapperFault("No binding specified");
-
- c_bindingEntry = c_symbolTable.getBindingEntry(binding.getQName());
-
- // ==================================================
- // Get target end point
- // ==================================================
-
- ports = service.getPorts().values().iterator();
- c_targetEndpointURI = WSDLInfo.getTargetEndPointURI(ports);
}
catch (Exception e)
{
@@ -267,7 +233,7 @@
*
* @throws WrapperFault
*/
- public void generateWrappers() throws WrapperFault
+ public void generateWrappers() throws Exception
{
CUtils.setLanguage(c_language);
@@ -294,25 +260,45 @@
}
// ==================================================
- // Generate the artifacts
- // ==================================================
+ // Get service, ports, binding, and port type
+ // ==================================================
+
+ //TODO resolve this
+ // this code will generate one stub corresponding to a port. Other ports
+ // are ignored. Should really generate one service stub per port.
+
+ // Get service definition, binding entry, port type. We first ask for SOAP 1.1 ports
+ // that have a binding style of document....if there is none, then we ask for
+ // SOAP 1.1 ports that have a binding style of rpc.
+ Service service = (Service)c_wsdlInfo.getServices().get(0);
+ ArrayList servicePorts = c_wsdlInfo.getPortsSOAP11Document(service);
+ if (servicePorts.isEmpty())
+ servicePorts = c_wsdlInfo.getPortsSOAP11RPC(service);
+ if (servicePorts.isEmpty())
+ throw new WrapperFault("A port with a supported binding was not found.");
+
+ Port port = (Port)servicePorts.get(0);
+ Binding binding = port.getBinding();
+ BindingEntry bindingEntry = c_symbolTable.getBindingEntry(binding.getQName());
+ PortType portType = bindingEntry.getBinding().getPortType();
+ if (portType == null)
+ throw new WrapperFault("Port type specified in binding '" + binding.getQName().getLocalPart() + "' not found");
+
+ // ==================================================
+ // Build the context that is needed by the code generators.
+ // ==================================================
+
// Wrapper info
- String c_serviceStyle = c_bindingEntry.getBindingStyle().getName();
-
WrapperInfo wrapperInfo =
- new WrapperInfo(c_serviceStyle, c_language,
- c_targetoutputLocation, c_targetEngine,
+ new WrapperInfo(bindingEntry.getBindingStyle().getName(),
+ c_language, c_targetoutputLocation, c_targetEngine,
c_wsdlInfo.getTargetNameSpaceOfWSDL());
// Service info
- PortType portType = c_bindingEntry.getBinding().getPortType();
- if (portType == null)
- throw new WrapperFault("Port type entry not found");
-
String serviceName = WrapperUtils.getClassNameFromFullyQualifiedName(portType.getQName().getLocalPart());
- ArrayList serviceMethods = processServiceMethods(portType, c_bindingEntry);
- ServiceInfo serviceInfo = new ServiceInfo(serviceName, serviceMethods, c_targetEndpointURI);
+ ArrayList serviceMethods = processServiceMethods(portType, bindingEntry);
+ ServiceInfo serviceInfo = new ServiceInfo(serviceName, serviceMethods, WSDLInfo.getTargetEndPointURI(port));
// Context
WebServiceContext wsContext = new WebServiceContext(wrapperInfo, serviceInfo, c_typeMap);
@@ -339,7 +325,10 @@
}
}
- // Generate code
+ // ==================================================
+ // Generate the artifacts
+ // ==================================================
+
wsg.generate();
}
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java?rev=686054&r1=686053&r2=686054&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java Thu Aug 14 14:44:20 2008
@@ -31,8 +31,6 @@
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.xml.namespace.QName;
-
import org.apache.axis.Constants;
import org.apache.axis.wsdl.gen.Parser;
import org.apache.axis.wsdl.symbolTable.BindingEntry;
@@ -176,21 +174,20 @@
return c_services;
}
- public static String getTargetEndPointURI(Iterator ports)
+ /**
+ * Returns end point URI for a Port by looking for the soap:address extensibility element.
+ *
+ * @param port
+ * @return
+ */
+ public static String getTargetEndPointURI(Port port)
{
- // we are checking only the first port.
- // if the targetEndPointURI not specifed we continue having it null
-
- if (ports.hasNext())
- {
- Port port = (Port) ports.next();
- List adresslist = port.getExtensibilityElements();
- if (adresslist != null
- && adresslist.size() != 0
- && (adresslist.get(0) instanceof javax.wsdl.extensions.soap.SOAPAddress))
- return ((javax.wsdl.extensions.soap.SOAPAddress) adresslist.get(0))
- .getLocationURI();
- }
+ List adresslist = port.getExtensibilityElements();
+ if (adresslist != null
+ && adresslist.size() != 0
+ && (adresslist.get(0) instanceof javax.wsdl.extensions.soap.SOAPAddress))
+ return ((javax.wsdl.extensions.soap.SOAPAddress) adresslist.get(0)).getLocationURI();
+
return null;
}
@@ -261,32 +258,54 @@
/**
* Returns list of Port objects in the specified service. All ports in the list
- * will either have a binding style of document or rpc (i.e. one or the other) and
- * uses the SOAP 1.1 binding.
+ * will have a binding style of document and uses the SOAP 1.1 binding.
*
- * @param s
- * @param styleDocument
- * @return
+ * @param s service definition
+ * @return list of ports that match the criteria described above.
* @throws Exception
*/
- public ArrayList getPortsSOAP11(Service s, boolean styleDocument) throws Exception
+ public ArrayList getPortsSOAP11Document(Service s) throws Exception
{
- return getServicePorts(s, styleDocument, true, false, false);
+ return getServicePorts(s, true, true, false, false);
}
/**
* Returns list of Port objects in the specified service. All ports in the list
- * will either have a binding style of document or rpc (i.e. one or the other) and
- * uses the SOAP 1.2 binding.
+ * will have a binding style of rpc and uses the SOAP 1.1 binding.
*
- * @param s
- * @param styleDocument
- * @return
+ * @param s service definition
+ * @return list of ports that match the criteria described above.
+ * @throws Exception
+ */
+ public ArrayList getPortsSOAP11RPC(Service s) throws Exception
+ {
+ return getServicePorts(s, false, true, false, false);
+ }
+
+ /**
+ * Returns list of Port objects in the specified service. All ports in the list
+ * will have a binding style of document and uses the SOAP 1.2 binding.
+ *
+ * @param s service definition
+ * @return list of ports that match the criteria described above.
+ * @throws Exception
+ */
+ public ArrayList getPortsSOAP12Document(Service s) throws Exception
+ {
+ return getServicePorts(s, true, false, true, false);
+ }
+
+ /**
+ * Returns list of Port objects in the specified service. All ports in the list
+ * will have a binding style of rpc and uses the SOAP 1.2 binding.
+ *
+ * @param s service definition
+ * @return list of ports that match the criteria described above.
* @throws Exception
*/
- public ArrayList getPortsSOAP12Document(Service s, boolean styleDocument) throws Exception
+ public ArrayList getPortsSOAP12RPC(Service s) throws Exception
{
- return getServicePorts(s, styleDocument, false, true, false);
+ return getServicePorts(s, false, false, true, false);
}
/**
@@ -335,12 +354,11 @@
if (b == null || be == null)
throw new WrapperFault("No binding exists for port '" + p.getName() + "'.");
- if ((be.getBindingType() == BindingEntry.TYPE_SOAP)
- && (soap11 || soap12))
+ if ((be.getBindingType() == BindingEntry.TYPE_SOAP) && (soap11 || soap12))
{
String style = be.getBindingStyle().getName();
if (style == null)
- style = "rpc"; // TODO need to revisit.
+ style = "rpc"; // TODO need to revisit. Standards say "document"
if ((styleDocument && style.equalsIgnoreCase("document"))
|| (!styleDocument && style.equalsIgnoreCase("rpc")))