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 ke...@apache.org on 2007/12/16 09:02:20 UTC

svn commit: r604565 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: description/AxisService2WSDL11.java description/AxisService2WSDL20.java util/WSDLSerializationUtil.java

Author: keithc
Date: Sun Dec 16 00:02:19 2007
New Revision: 604565

URL: http://svn.apache.org/viewvc?rev=604565&view=rev
Log:
Adding a constructor to both AxisService2WSDL20 and AxisService2WSDL11 to specify the service name from outside. Enables us to generate WSDLs with what ever name we want in it. Default behaviour is 
to use the service name.


Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=604565&r1=604564&r2=604565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Sun Dec 16 00:02:19 2007
@@ -17,6 +17,7 @@
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
+import org.apache.axis2.AxisFault;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
 import org.apache.neethi.PolicyReference;
@@ -55,6 +56,8 @@
 
     private AxisService axisService;
 
+    private String serviceName;
+
     private String[] serviceEndpointURLs;
 
     private String targetNamespace;
@@ -87,13 +90,17 @@
 
     public AxisService2WSDL11(AxisService service) throws Exception {
         this.axisService = service;
+        this.serviceName = service.getName();
+        init();
+    }
 
+    private void init() throws AxisFault {
         // the EPR list of AxisService contains REST EPRs as well. Those REST EPRs will be used to generated HTTPBinding
         // and rest of the EPRs will be used to generate SOAP 1.1 and 1.2 bindings. Let's first initialize those set of
         // EPRs now to be used later, especially when we generate the WSDL.
-        serviceEndpointURLs = service.getEPRs();
+        serviceEndpointURLs = axisService.getEPRs();
         if (serviceEndpointURLs == null) {
-            Map endpointMap = service.getEndpoints();
+            Map endpointMap = axisService.getEndpoints();
              if (endpointMap.size() > 0) {
                 Iterator endpointItr = endpointMap.values().iterator();
                 if (endpointItr.hasNext()) {
@@ -102,21 +109,26 @@
                 }
 
             } else {
-                 serviceEndpointURLs = new String[]{service.getEndpointName()};
+                 serviceEndpointURLs = new String[]{axisService.getEndpointName()};
              }
         }
 
-        this.targetNamespace = service.getTargetNamespace();
+        this.targetNamespace = axisService.getTargetNamespace();
 
         serializer = new ExternalPolicySerializer();
         // CHECKME check whether service.getAxisConfiguration() return null ???
 
-        AxisConfiguration configuration = service.getAxisConfiguration();
+        AxisConfiguration configuration = axisService.getAxisConfiguration();
         if (configuration != null) {
             serializer.setAssertionsToFilter(configuration
                     .getLocalPolicyAssertions());
         }
+    }
 
+    public AxisService2WSDL11(AxisService service, String serviceName) throws Exception {
+        this.axisService = service;
+        this.serviceName = serviceName;
+        init();
     }
 
     public OMElement generateOM() throws Exception {
@@ -342,7 +354,7 @@
         OMElement portType = fac.createOMElement(PORT_TYPE_LOCAL_NAME, wsdl);
         defintions.addChild(portType);
 
-        portType.addAttribute(ATTRIBUTE_NAME, axisService.getName()
+        portType.addAttribute(ATTRIBUTE_NAME, serviceName
                 + PORT_TYPE_SUFFIX, null);
 
         addPolicyAsExtAttribute(PolicyInclude.PORT_TYPE_POLICY, axisService
@@ -454,11 +466,12 @@
      * @param disableSOAP12 if false, generate SOAP 1.2 binding, if true, don't
      * @throws Exception if there's a problem
      */
-    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST, boolean disableSOAP12)
+    public void generateService(OMFactory fac, OMElement defintions, boolean disableREST,
+                                boolean disableSOAP12)
             throws Exception {
         OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
         defintions.addChild(service);
-        service.addAttribute(ATTRIBUTE_NAME, axisService.getName(), null);
+        service.addAttribute(ATTRIBUTE_NAME, serviceName, null);
         generateSOAP11Ports(fac, service);
         if (!disableSOAP12) {
             generateSOAP12Ports(fac, service);
@@ -482,14 +495,14 @@
                 String protocol = new URI(urlString).getScheme();
                 OMElement port = fac.createOMElement(PORT, wsdl);
                 service.addChild(port);
-                String name = axisService.getName() + SOAP11PORT
+                String name = serviceName + SOAP11PORT
                         + ((protocol == null) ? "" : "_" + protocol);
                 if (i > 0) {
                     name += i;
                 }
                 port.addAttribute(ATTRIBUTE_NAME, name, null);
                 port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-                        + axisService.getName() + BINDING_NAME_SUFFIX, null);
+                        + serviceName + BINDING_NAME_SUFFIX, null);
                 WSDLSerializationUtil.addExtensionElement(fac, port, SOAP_ADDRESS, LOCATION, urlString,
                                     soap);
 
@@ -507,13 +520,13 @@
             if (urlString != null && urlString.startsWith("http")) {
                 OMElement port = fac.createOMElement(PORT, wsdl);
                 service.addChild(port);
-                String name = axisService.getName() + HTTP_PORT;
+                String name = serviceName + HTTP_PORT;
                 if (i > 0) {
                     name += i;
                 }
                 port.addAttribute(ATTRIBUTE_NAME, name, null);
                 port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-                        + axisService.getName() + HTTP_BINDING, null);
+                        + serviceName + HTTP_BINDING, null);
                 OMElement extElement = fac.createOMElement("address", http);
                 port.addChild(extElement);
 //                urlString = urlString.replaceAll(servicePath, "rest");
@@ -530,14 +543,14 @@
                 String protocol = new URI(urlString).getScheme();
                 OMElement port = fac.createOMElement(PORT, wsdl);
                 service.addChild(port);
-                String name = axisService.getName() + SOAP12PORT
+                String name = serviceName + SOAP12PORT
                         + ((protocol == null) ? "" : "_" + protocol);
                 if (i > 0) {
                     name += i;
                 }
                 port.addAttribute(ATTRIBUTE_NAME, name, null);
                 port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
-                        + axisService.getName() + SOAP12BINDING_NAME_SUFFIX, null);
+                        + serviceName + SOAP12BINDING_NAME_SUFFIX, null);
                 WSDLSerializationUtil.addExtensionElement(fac, port, SOAP_ADDRESS, LOCATION, urlString,
                                     soap12);
 
@@ -558,10 +571,10 @@
             throws Exception {
         OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
         defintions.addChild(binding);
-        binding.addAttribute(ATTRIBUTE_NAME, axisService.getName()
+        binding.addAttribute(ATTRIBUTE_NAME, serviceName
                 + BINDING_NAME_SUFFIX, null);
         binding.addAttribute("type", tns.getPrefix() + ":"
-                + axisService.getName() + PORT_TYPE_SUFFIX, null);
+                + serviceName + PORT_TYPE_SUFFIX, null);
 
         addPolicyAsExtElement(PolicyInclude.BINDING_POLICY, axisService
                 .getPolicyInclude(), binding);
@@ -690,10 +703,10 @@
             throws Exception {
         OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
         defintions.addChild(binding);
-        binding.addAttribute(ATTRIBUTE_NAME, axisService.getName()
+        binding.addAttribute(ATTRIBUTE_NAME, serviceName
                 + SOAP12BINDING_NAME_SUFFIX, null);
         binding.addAttribute("type", tns.getPrefix() + ":"
-                + axisService.getName() + PORT_TYPE_SUFFIX, null);
+                + serviceName + PORT_TYPE_SUFFIX, null);
 
         addPolicyAsExtElement(PolicyInclude.BINDING_POLICY, axisService
                 .getPolicyInclude(), binding);
@@ -815,10 +828,10 @@
             throws Exception {
         OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
         defintions.addChild(binding);
-        binding.addAttribute(ATTRIBUTE_NAME, axisService.getName()
+        binding.addAttribute(ATTRIBUTE_NAME, serviceName
                 + HTTP_BINDING, null);
         binding.addAttribute("type", tns.getPrefix() + ":"
-                + axisService.getName() + PORT_TYPE_SUFFIX, null);
+                + serviceName + PORT_TYPE_SUFFIX, null);
 
         // Adding ext elements
         OMElement httpBinding = fac.createOMElement("binding", http);
@@ -838,7 +851,7 @@
 
             OMElement httpOperation = fac.createOMElement("operation", http);
             operation.addChild(httpOperation);
-            httpOperation.addAttribute("location", axisService.getName() + "/" + axisOperation.getName()
+            httpOperation.addAttribute("location", serviceName + "/" + axisOperation.getName()
                     .getLocalPart(), null);
 
             String MEP = axisOperation.getMessageExchangePattern();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=604565&r1=604564&r2=604565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Sun Dec 16 00:02:19 2007
@@ -59,11 +59,18 @@
 public class AxisService2WSDL20 implements WSDL2Constants {
 
     private AxisService axisService;
+    private String serviceName;
     private String[] eprs = null;
     private OMNamespace wsaw;
 
     public AxisService2WSDL20(AxisService service) {
         this.axisService = service;
+        this.serviceName = service.getName();
+    }
+
+    public AxisService2WSDL20(AxisService service, String serviceName) {
+        this.axisService = service;
+        this.serviceName = serviceName;
     }
 
     /**
@@ -216,7 +223,7 @@
         if (endpointMap != null && endpointMap.size() > 0) {
             String[] eprs = axisService.getEPRs();
             if (eprs == null) {
-                eprs = new String[]{axisService.getName()};
+                eprs = new String[]{serviceName};
             }
             OMElement serviceElement = getServiceElement(wsdl, tns, omFactory, interfaceName);
             Iterator iterator = endpointMap.values().iterator();
@@ -278,7 +285,7 @@
                                                    interfaceName,
                                                    axisService.getNamespaceMap(),
                                                    axisService.getWSAddressingFlag(),
-                                                   axisService.getName(),wsaw));
+                                                   serviceName,wsaw));
             }
 
             descriptionElement.addChild(serviceElement);
@@ -287,21 +294,23 @@
             // There are no andpoints defined hence generate default bindings and endpoints
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
-                                                                tns));
+                                                                tns, serviceName));
             if (!disableSOAP12) {
             descriptionElement.addChild(
                     WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl, wsoap,
-                                                                tns));
+                                                                tns, serviceName));
             }
             if (!disableREST) {
                 descriptionElement.addChild(
                         WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
                                                                   whttp,
-                                                                  tns));
+                                                                  tns, serviceName));
             }
             descriptionElement
                     .addChild(WSDLSerializationUtil.generateServiceElement(omFactory, wsdl, tns,
-                                                                           axisService, disableREST, disableSOAP12, eprs));
+                                                                           axisService, disableREST,
+                                                                           disableSOAP12, eprs,
+                                                                          serviceName));
         }
 
         return descriptionElement;
@@ -375,7 +384,7 @@
                 omFactory.createOMElement(WSDL2Constants.SERVICE_LOCAL_NAME, wsdl);
         serviceElement.addAttribute(
                 omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null,
-                                            axisService.getName()));
+                                            serviceName));
         serviceElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.INTERFACE_LOCAL_NAME,
                                                                 null, tns.getPrefix() + ":" +
                 interfaceName));

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java?rev=604565&r1=604564&r2=604565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java Sun Dec 16 00:02:19 2007
@@ -175,10 +175,10 @@
      */
     public static OMElement generateSOAP11Binding(OMFactory fac, AxisService axisService,
                                                   OMNamespace wsdl, OMNamespace wsoap,
-                                                  OMNamespace tns) {
+                                                  OMNamespace tns, String serviceName) {
         OMElement binding = fac.createOMElement(WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
         binding.addAttribute(
-                fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, axisService.getName() +
+                fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, serviceName +
                         Java2WSDLConstants.BINDING_NAME_SUFFIX));
         binding.addAttribute(fac.createOMAttribute(WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
                 .getPrefix() + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
@@ -204,10 +204,10 @@
      */
     public static OMElement generateSOAP12Binding(OMFactory fac, AxisService axisService,
                                                   OMNamespace wsdl, OMNamespace wsoap,
-                                                  OMNamespace tns) {
+                                                  OMNamespace tns, String serviceName) {
         OMElement binding = fac.createOMElement(WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
         binding.addAttribute(
-                fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, axisService.getName() +
+                fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, serviceName +
                         Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
         binding.addAttribute(fac.createOMAttribute(WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
                 .getPrefix() + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
@@ -233,9 +233,8 @@
      */
     public static OMElement generateHTTPBinding(OMFactory fac, AxisService axisService,
                                                 OMNamespace wsdl, OMNamespace whttp,
-                                                OMNamespace tns) {
+                                                OMNamespace tns, String serviceName) {
         OMElement binding = fac.createOMElement(WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
-        String serviceName = axisService.getName();
         binding.addAttribute(
                 fac.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, serviceName +
                         Java2WSDLConstants.HTTP_BINDING));
@@ -290,9 +289,11 @@
      */
     public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
                                                    OMNamespace tns, AxisService axisService,
-                                                   boolean disableREST, boolean disableSOAP12)
+                                                   boolean disableREST, boolean disableSOAP12,
+                                                   String serviceName)
             throws AxisFault {
-        return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, disableSOAP12, null);
+        return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, disableSOAP12,
+                                      null, serviceName);
     }
     
     /**
@@ -308,18 +309,19 @@
      */
     public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
                                                    OMNamespace tns, AxisService axisService,
-                                                   boolean disableREST, boolean disableSOAP12, String[] eprs)
+                                                   boolean disableREST, boolean disableSOAP12,
+                                                   String[] eprs, String serviceName)
             throws AxisFault {
         if(eprs == null){
             eprs = axisService.getEPRs();
             if (eprs == null) {
-                eprs = new String[]{axisService.getName()};
+                eprs = new String[]{serviceName};
             }
         }
         OMElement serviceElement;
         serviceElement = omFactory.createOMElement(WSDL2Constants.SERVICE_LOCAL_NAME, wsdl);
                     serviceElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME,
-                                                                            null, axisService.getName()));
+                                                                            null, serviceName));
                     serviceElement.addAttribute(omFactory.createOMAttribute(
                             WSDL2Constants.INTERFACE_LOCAL_NAME, null,
                             tns.getPrefix() + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
@@ -337,7 +339,7 @@
                     name + WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME));
             soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
                     WSDL2Constants.BINDING_LOCAL_NAME, null,
-                    tns.getPrefix() + ":" + axisService.getName() +
+                    tns.getPrefix() + ":" + serviceName +
                             Java2WSDLConstants.BINDING_NAME_SUFFIX));
             soap11EndpointElement.addAttribute(
                     omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
@@ -352,7 +354,7 @@
                         name + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
                 soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
                         WSDL2Constants.BINDING_LOCAL_NAME, null,
-                        tns.getPrefix() + ":" + axisService.getName() +
+                        tns.getPrefix() + ":" + serviceName +
                                 Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
                 soap12EndpointElement.addAttribute(
                         omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
@@ -368,7 +370,7 @@
                         name + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
                 httpEndpointElement.addAttribute(omFactory.createOMAttribute(
                         WSDL2Constants.BINDING_LOCAL_NAME, null,
-                        tns.getPrefix() + ":" + axisService.getName() + Java2WSDLConstants
+                        tns.getPrefix() + ":" + serviceName + Java2WSDLConstants
                                 .HTTP_BINDING));
                 httpEndpointElement.addAttribute(
                         omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org