You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/07/07 19:55:32 UTC
svn commit: r1358606 - in /axis/axis2/java/core/trunk/modules/kernel:
src/org/apache/axis2/ src/org/apache/axis2/dataretrieval/
src/org/apache/axis2/description/ src/org/apache/axis2/util/
test/org/apache/axis2/description/
Author: sagara
Date: Sat Jul 7 17:55:31 2012
New Revision: 1358606
URL: http://svn.apache.org/viewvc?rev=1358606&view=rev
Log:
Applied patch provided for AXIS2-5279 with few formating corrections, this will fix AXIS2-3492,AXIS2-5278. WSDL 1.1 customization required for AXIS2-3653, AXIS2-5240 also fixed.
Added:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java (with props)
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java (with props)
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java (with props)
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java (with props)
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java (with props)
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLSupplier.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java?rev=1358606&r1=1358605&r2=1358606&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java Sat Jul 7 17:55:31 2012
@@ -321,6 +321,12 @@ public class Constants extends org.apach
public static final String AXIS2_ENUM_NAMESPACE_URI = "http://ws.apache.org/namespaces/axis2/enum";
public static final String ENUM_ELEMENT_NAME = "enum";
+ public static final String WSDL_11_SUPPLIER_CLASS_PARAM ="WSDL1SupplierClass";
+
+ public static final String WSDL_20_SUPPLIER_CLASS_PARAM ="WSDL2SupplierClass";
+
+ public static final String WSDL_SUPPLIER_PARAM ="WSDLSupplier";
+
public static interface Configuration {
public static final String ENABLE_REST = "enableREST";
public static final String ENABLE_HTTP_CONTENT_NEGOTIATION = "httpContentNegotiation";
Added: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.dataretrieval;
+
+import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisService2WSDL11;
+
+public abstract class WSDL11SupplierTemplate extends AxisService2WSDL11 implements WSDLSupplier {
+
+ public final void init(AxisService service) {
+ super.axisService = service;
+ this.serviceName = service.getName();
+ try {
+ super.init();
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public Object getWSDL(AxisService service) throws AxisFault {
+ try {
+ return generateOM();
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+
+ @Override
+ public final OMElement generateOM() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement definition = generateDefinition(fac);
+
+ OMElement documentation = customizeDocumentation(generateDocumentation(fac));
+ if (documentation != null) {
+ definition.addChild(documentation);
+ }
+
+ OMElement types = customizeTypes(generateTypes(fac));
+ if (types != null) {
+ definition.addChild(types);
+ }
+
+ List<OMElement> messages = customizeMessages(generateMessages(fac));
+ for (OMElement message : messages) {
+ if (message != null) {
+ definition.addChild(message);
+ }
+ }
+
+ OMElement portType = customizePortType(generatePortType(fac));
+ definition.addChild(portType);
+
+ if (!isDisableSOAP11()) {
+ definition.addChild(portType);
+ }
+
+ customizeService(generateService(fac, definition, isDisableREST(), isDisableSOAP12(),
+ isDisableSOAP11()));
+ addPoliciesToDefinitionElement(getPoliciesInDefinitions().values().iterator(), definition);
+ return definition;
+ }
+
+ protected OMElement customizeDocumentation(OMElement documentation) {
+ return documentation;
+ }
+
+ protected OMElement customizeTypes(OMElement types) {
+ return types;
+ }
+
+ protected List<OMElement> customizeMessages(List<OMElement> messages) {
+ return messages;
+ }
+
+ protected OMElement customizePortType(OMElement portType) {
+ return portType;
+ }
+
+ protected final OMElement customizeService(OMElement service) {
+ return service;
+ }
+
+ protected OMElement customizePort(OMElement port) {
+ return port;
+ }
+
+ protected OMElement customizeBinding(OMElement binding) {
+ return binding;
+ }
+
+ /**
+ * This method use by AxisService2WSDL11 and users should not touch this
+ * method.
+ */
+ @Override
+ protected final OMElement modifyPort(OMElement port) {
+ return customizePort(port);
+ }
+
+ /**
+ * This method use by AxisService2WSDL11 and users should not touch this
+ * method.
+ */
+ @Override
+ protected final OMElement modifyBinding(OMElement binding) {
+ return customizeBinding(binding);
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL11SupplierTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.dataretrieval;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+
+public class WSDL20SupplierTemplate implements WSDLSupplier{
+
+ public Object getWSDL(AxisService service) throws AxisFault {
+ return null;
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLSupplier.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLSupplier.java?rev=1358606&r1=1358605&r2=1358606&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLSupplier.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDLSupplier.java Sat Jul 7 17:55:31 2012
@@ -22,8 +22,6 @@ package org.apache.axis2.dataretrieval;
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.AxisService;
-import javax.wsdl.Definition;
-
/**
* Return a WSDL as an OMElement. This is used by any AxisService that wishes
* to override the standard AxisService2WSDL (see the org.apache.axis2.description
@@ -31,5 +29,5 @@ import javax.wsdl.Definition;
* Parameters under the name "WSDLSupplier", it will be queried.
*/
public interface WSDLSupplier {
- Definition getWSDL(AxisService service) throws AxisFault;
+ Object getWSDL(AxisService service) throws AxisFault;
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=1358606&r1=1358605&r2=1358606&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java Sat Jul 7 17:55:31 2012
@@ -38,6 +38,7 @@ import org.apache.axis2.dataretrieval.Da
import org.apache.axis2.dataretrieval.LocatorType;
import org.apache.axis2.dataretrieval.OutputForm;
import org.apache.axis2.dataretrieval.SchemaSupplier;
+import org.apache.axis2.dataretrieval.WSDL11SupplierTemplate;
import org.apache.axis2.dataretrieval.WSDLSupplier;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.util.ExcludeInfo;
@@ -106,6 +107,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.SocketException;
import java.net.URISyntaxException;
@@ -1433,18 +1435,43 @@ public class AxisService extends AxisDes
return;
}
- // If we find a WSDLSupplier, use that
- WSDLSupplier supplier = (WSDLSupplier) getParameterValue("WSDLSupplier");
+ // If we find a WSDLSupplier with WSDL 1.1 content, use that
+ WSDLSupplier supplier = getUserDefinedWSDLSupplier("wsdl");
+ if(supplier == null){
+ supplier = (WSDLSupplier) getParameterValue(Constants.WSDL_SUPPLIER_PARAM);
+ if(supplier instanceof WSDL11SupplierTemplate){
+ ((WSDL11SupplierTemplate)supplier).init(this);
+ }
+ }
if (supplier != null) {
- try {
- Definition definition = supplier.getWSDL(this);
- if (definition != null) {
- changeImportAndIncludeLocations(definition);
- printDefinitionObject(getWSDLDefinition(definition, null),
- out, requestIP);
+ Object wsdlContent = supplier.getWSDL(this);
+ if( wsdlContent instanceof Definition){
+ try {
+ Definition definition = (Definition) wsdlContent;
+ if (definition != null) {
+ changeImportAndIncludeLocations(definition);
+ printDefinitionObject(getWSDLDefinition(definition, null),
+ out, requestIP);
+ }
+ } catch (Exception e) {
+ printWSDLError(out, e);
+ }
+ // wsdlContent can be a OMElement
+ } else if (wsdlContent instanceof OMElement) {
+ OMElement wsdlElement = (OMElement) wsdlContent;
+ QName wsdlName = wsdlElement.getQName();
+ if (wsdlName != null
+ && wsdlName.getLocalPart().equals("definitions")
+ && wsdlName.getNamespaceURI().equals("http://schemas.xmlsoap.org/wsdl/")) {
+ // TODO How to address port number/ ip name customization
+ // here ?
+ try {
+ XMLPrettyPrinter.prettify(wsdlElement, out);
+ out.flush();
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
}
- } catch (Exception e) {
- printWSDLError(out, e);
}
return;
}
@@ -1758,6 +1785,46 @@ public class AxisService extends AxisDes
*/
public void printWSDL2(OutputStream out, String requestIP) throws AxisFault {
AxisService2WSDL20 axisService2WSDL2 = new AxisService2WSDL20(this);
+
+ // If we find a WSDLSupplier with WSDL 2.0 content, use that
+ WSDLSupplier supplier = getUserDefinedWSDLSupplier("wsdl2");
+ if(supplier == null){
+ supplier = (WSDLSupplier) getParameterValue(Constants.WSDL_SUPPLIER_PARAM);
+ }
+ if (supplier != null) {
+ Object wsdlContent = supplier.getWSDL(this);
+ if( wsdlContent instanceof Description){
+ try {
+ Description definition = (Description) wsdlContent;
+ if (definition != null) {
+ //TODO -- Need to implement this method for WSDL 2.0
+ //changeImportAndIncludeLocations(definition);
+ printDescriptionObject(definition, out, requestIP);
+ }
+ } catch (Exception e) {
+ printWSDLError(out, e);
+ }
+
+ // wsdlContent can be a OMElement
+ } else if (wsdlContent instanceof OMElement) {
+ OMElement wsdlElement = (OMElement) wsdlContent;
+ QName wsdlName = wsdlElement.getQName();
+ if (wsdlName != null
+ && wsdlName.getLocalPart().equals("definitions")
+ && wsdlName.getNamespaceURI().equals("http://schemas.xmlsoap.org/wsdl/")) {
+ // TODO How to address port number/ ip name customization
+ // here ?
+ try {
+ XMLPrettyPrinter.prettify(wsdlElement, out);
+ out.flush();
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+ }
+ return;
+ }
+
try {
if (requestIP != null) {
axisService2WSDL2.setEPRs(calculateEPRs(requestIP));
@@ -3322,5 +3389,54 @@ public class AxisService extends AxisDes
WSDL2Constants.ATTR_WSOAP_VERSION));
}
return axisService;
+ }
+ private void printDescriptionObject(Description definition,
+ OutputStream out, String requestIP) {
+ //TODO - complete this method
+ org.apache.woden.WSDLFactory fac;
+ try {
+ fac = org.apache.woden.WSDLFactory.newInstance();
+ org.apache.woden.WSDLWriter writer = fac.newWSDLWriter();
+ writer.writeWSDL(definition.toElement(), out);
+ } catch (org.apache.woden.WSDLException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+ private WSDLSupplier getUserDefinedWSDLSupplier(String wsdlVersion){
+ WSDLSupplier wsdlSupplier = null;
+ if("wsdl".equals(wsdlVersion)){
+ Parameter para = getParameter(Constants.WSDL_11_SUPPLIER_CLASS_PARAM);
+ if (para != null) {
+ try {
+ wsdlSupplier = (WSDLSupplier) Class.forName((String) para.getValue()).newInstance();
+ if( wsdlSupplier instanceof WSDL11SupplierTemplate){
+ ((WSDL11SupplierTemplate)wsdlSupplier).init(this);
+ }
+ } catch (Exception e) {
+ System.err.println("Following exception occurred when generating WSDL using "
+ + para);
+ e.printStackTrace();
+ }
+ }
+ } else if("wsdl2".equals(wsdlVersion)){
+ Parameter para = getParameter(Constants.WSDL_20_SUPPLIER_CLASS_PARAM);
+ if(para != null){
+ try {
+ wsdlSupplier = (WSDLSupplier) Class.forName((String) para.getValue()).newInstance() ;
+ //TODO
+// if( wsdlSupplier instanceof WSDL20SupplierTemplate){
+// ((WSDL20SupplierTemplate)wsdlSupplier).init(this);
+// }
+ } catch (Exception e) {
+ System.err.println("Following exception occurred when generating WSDL using "+ para );
+ e.printStackTrace();
+ }
+ }
+
+ }
+ return wsdlSupplier;
}
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=1358606&r1=1358605&r2=1358606&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Sat Jul 7 17:55:31 2012
@@ -19,7 +19,13 @@
package org.apache.axis2.description;
-import org.apache.axiom.om.*;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
@@ -28,7 +34,12 @@ import org.apache.axis2.addressing.Addre
import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.namespace.Constants;
-import org.apache.axis2.util.*;
+import org.apache.axis2.util.ExternalPolicySerializer;
+import org.apache.axis2.util.JavaUtils;
+import org.apache.axis2.util.PolicyLocator;
+import org.apache.axis2.util.PolicyUtil;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.util.WSDLSerializationUtil;
import org.apache.axis2.util.XMLUtils;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
import org.apache.axis2.wsdl.WSDLConstants;
@@ -40,15 +51,24 @@ import org.apache.neethi.PolicyRegistryI
import org.apache.ws.commons.schema.XmlSchema;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
import java.io.StringReader;
import java.io.StringWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
public class AxisService2WSDL11 implements Java2WSDLConstants {
- private AxisService axisService;
+ protected AxisService axisService;
- private String serviceName;
+ protected String serviceName;
private String targetNamespace;
@@ -72,13 +92,15 @@ public class AxisService2WSDL11 implemen
private String use = LITERAL;
- private HashMap policiesInDefinitions;
+ private Map<String, Policy> policiesInDefinitions;
private ExternalPolicySerializer serializer;
private HashMap messagesMap;
private boolean checkIfEndPointActive = true;
+
+ public AxisService2WSDL11() { }
public AxisService2WSDL11(AxisService service) throws Exception {
this.axisService = service;
@@ -98,7 +120,7 @@ public class AxisService2WSDL11 implemen
checkIfEndPointActive = flag;
}
- private void init() throws AxisFault {
+ protected void init() throws AxisFault {
/*
// the EPR list of AxisService contains REST EPRs as well. Those REST
// EPRs will be used to generated HTTPBinding
@@ -150,109 +172,46 @@ public class AxisService2WSDL11 implemen
public OMElement generateOM() throws Exception {
OMFactory fac = OMAbstractFactory.getOMFactory();
- wsdl = fac.createOMNamespace(WSDL_NAMESPACE, DEFAULT_WSDL_NAMESPACE_PREFIX);
- OMElement ele = fac.createOMElement("definitions", wsdl);
- setDefinitionElement(ele);
-
- policiesInDefinitions = new HashMap();
-
- Map namespaceMap = axisService.getNamespaceMap();
- if (namespaceMap == null)
- namespaceMap = new HashMap();
-
- WSDLSerializationUtil.populateNamespaces(ele, namespaceMap);
- soap = ele.declareNamespace(URI_WSDL11_SOAP, SOAP11_PREFIX);
- soap12 = ele.declareNamespace(URI_WSDL12_SOAP, SOAP12_PREFIX);
- http = ele.declareNamespace(HTTP_NAMESPACE, HTTP_PREFIX);
- mime = ele.declareNamespace(MIME_NAMESPACE, MIME_PREFIX);
- wsaw = ele.declareNamespace(AddressingConstants.Final.WSAW_NAMESPACE, "wsaw");
- String prefix = WSDLSerializationUtil.getPrefix(axisService.getTargetNamespace(),
- namespaceMap);
- if (prefix == null || "".equals(prefix)) {
- if (axisService.getTargetNamespacePrefix() != null) {
- prefix = axisService.getTargetNamespacePrefix();
- } else {
- prefix = DEFAULT_TARGET_NAMESPACE_PREFIX;
- }
- }
-
- namespaceMap.put(prefix, axisService.getTargetNamespace());
- tns = ele.declareNamespace(axisService.getTargetNamespace(), prefix);
-
- // axis2.xml indicated no HTTP binding?
- boolean disableREST = false;
- Parameter disableRESTParameter = axisService.getParameter(
- org.apache.axis2.Constants.Configuration.DISABLE_REST);
- if (disableRESTParameter != null
- && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
- disableREST = true;
- }
-
- boolean disableSOAP11 = false;
- Parameter disableSOAP11Parameter = axisService
- .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
- if (disableSOAP11Parameter != null
- && JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
- disableSOAP11 = true;
- }
-
- // axis2.xml indicated no SOAP 1.2 binding?
- boolean disableSOAP12 = false;
- Parameter disableSOAP12Parameter = axisService
- .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
- if (disableSOAP12Parameter != null
- && JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
- disableSOAP12 = true;
- }
+ OMElement definition = generateDefinition(fac);
+
// adding documentation element
// <documentation><b>NEW!</b> This method accepts an ISBN
// string and returns <b>Amazon.co.uk</b> Sales Rank for
// that book.</documentation>
- WSDLSerializationUtil.addWSDLDocumentationElement(axisService, ele, fac, wsdl);
-
- ele.addAttribute("targetNamespace", axisService.getTargetNamespace(), null);
- OMElement wsdlTypes = fac.createOMElement("types", wsdl);
- ele.addChild(wsdlTypes);
-
- // populate the schema mappings
- axisService.populateSchemaMappings();
-
- ArrayList schemas = axisService.getSchema();
- for (int i = 0; i < schemas.size(); i++) {
- StringWriter writer = new StringWriter();
-
- // XmlSchema schema = (XmlSchema) schemas.get(i);
- XmlSchema schema = axisService.getSchema(i);
-
- String targetNamespace = schema.getTargetNamespace();
- if (!Constants.NS_URI_XML.equals(targetNamespace)) {
- schema.write(writer);
- String schemaString = writer.toString();
- if (!"".equals(schemaString)) {
- wsdlTypes.addChild(XMLUtils.toOM(new StringReader(schemaString)));
- }
- }
- }
- generateMessages(fac, ele);
- generatePortType(fac, ele);
-
- // generateSOAP11Binding(fac, ele);
- // if (!disableSOAP12) {
- // generateSOAP12Binding(fac, ele);
- // }
- // if (!disableREST) {
- // generateHTTPBinding(fac, ele);
- // }
+ OMElement documentation = generateDocumentation(fac);
+ if(documentation != null){
+ definition.addChild(documentation);
+ }
+
+ OMElement types = generateTypes(fac);
+ if(types != null){
+ definition.addChild(types);
+ }
+
+ List<OMElement> messages = generateMessages(fac);
+ for( OMElement message : messages){
+ if(message != null){
+ definition.addChild(message);
+ }
+ }
+
+ OMElement portType = generatePortType(fac);
+ definition.addChild(portType);
+
+ if(!isDisableSOAP11()){
+ definition.addChild(portType);
+ }
- generateService(fac, ele, disableREST, disableSOAP12 , disableSOAP11);
+ generateService(fac, definition, isDisableREST(), isDisableSOAP12() , isDisableSOAP11());
addPoliciesToDefinitionElement(policiesInDefinitions.values().iterator(), definition);
- return ele;
+ return definition;
}
- private void generateMessages(OMFactory fac, OMElement defintions) {
+ protected List<OMElement> generateMessages(OMFactory fac) {
HashSet faultMessageNames = new HashSet();
+ List<OMElement> messageList = new ArrayList<OMElement>();
messagesMap = new HashMap();
Iterator operations = axisService.getOperations();
@@ -271,8 +230,8 @@ public class AxisService2WSDL11 implemen
AxisMessage inaxisMessage =
axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (inaxisMessage != null) {
- writeMessage(inaxisMessage, fac, defintions);
- generateHeaderMessages(inaxisMessage, fac, defintions);
+ messageList.add(writeMessage(inaxisMessage, fac));
+ messageList.add(generateHeaderMessages(inaxisMessage, fac));
}
}
@@ -284,8 +243,8 @@ public class AxisService2WSDL11 implemen
AxisMessage outAxisMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
if (outAxisMessage != null) {
- writeMessage(outAxisMessage, fac, defintions);
- generateHeaderMessages(outAxisMessage, fac, defintions);
+ messageList.add(writeMessage(outAxisMessage, fac));
+ messageList.add(generateHeaderMessages(outAxisMessage, fac));
}
}
@@ -295,12 +254,13 @@ public class AxisService2WSDL11 implemen
for (AxisMessage faultyMessage : faultyMessages) {
String name = faultyMessage.getName();
if (faultMessageNames.add(name)) {
- writeMessage(faultyMessage, fac, defintions);
- generateHeaderMessages(faultyMessage, fac, defintions);
+ messageList.add(writeMessage(faultyMessage, fac));
+ messageList.add(generateHeaderMessages(faultyMessage, fac));
}
}
}
}
+ return messageList;
}
/**
@@ -338,14 +298,12 @@ public class AxisService2WSDL11 implemen
}
}
- private void generateHeaderMessages(AxisMessage axismessage, OMFactory fac,
- OMElement defintions) {
+ private OMElement generateHeaderMessages(AxisMessage axismessage, OMFactory fac) {
ArrayList extList = axismessage.getSoapHeaders();
for (Object anExtList : extList) {
SOAPHeaderMessage header = (SOAPHeaderMessage)anExtList;
OMElement messageElement = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
messageElement.addAttribute(ATTRIBUTE_NAME, header.getMessage().getLocalPart(), null);
- defintions.addChild(messageElement);
OMElement messagePart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
messageElement.addChild(messagePart);
messagePart.addAttribute(ATTRIBUTE_NAME, header.part(), null);
@@ -357,16 +315,17 @@ public class AxisService2WSDL11 implemen
WSDLSerializationUtil.getPrefix(header.getElement()
.getNamespaceURI(), axisService.getNamespaceMap())
+ ":" + header.getElement().getLocalPart(), null);
+ return messageElement;
}
+ return null;
}
- private void writeMessage(AxisMessage axismessage, OMFactory fac, OMElement defintions) {
+ private OMElement writeMessage(AxisMessage axismessage, OMFactory fac) {
if (axismessage.getName() != null && messagesMap.get(axismessage.getName()) == null) {
messagesMap.put(axismessage.getName(), axismessage);
QName schemaElementName = axismessage.getElementQName();
OMElement messageElement = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
- messageElement.addAttribute(ATTRIBUTE_NAME, axismessage.getName(), null);
- defintions.addChild(messageElement);
+ messageElement.addAttribute(ATTRIBUTE_NAME, axismessage.getName(), null);
if (schemaElementName != null) {
OMElement messagePart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
messageElement.addChild(messagePart);
@@ -382,7 +341,9 @@ public class AxisService2WSDL11 implemen
axisService.getNamespaceMap())
+ ":" + schemaElementName.getLocalPart(), null);
}
+ return messageElement;
}
+ return null;
}
@@ -395,13 +356,13 @@ public class AxisService2WSDL11 implemen
* the active OMFactory
* @param defintions
* the WSDL <definitions> element
+ * @return
* @throws Exception
* if there's a problem
*/
- private void generatePortType(OMFactory fac, OMElement defintions)
+ protected OMElement generatePortType(OMFactory fac)
throws Exception {
OMElement portType = fac.createOMElement(PORT_TYPE_LOCAL_NAME, wsdl);
- defintions.addChild(portType);
String portTypeName = serviceName + PORT_TYPE_SUFFIX;
@@ -497,6 +458,7 @@ public class AxisService2WSDL11 implemen
}
}
+ return portType;
}
/**
@@ -511,10 +473,11 @@ public class AxisService2WSDL11 implemen
* if false, generate REST binding, if true, don't
* @param disableSOAP12
* if false, generate SOAP 1.2 binding, if true, don't
+ * @return
* @throws Exception
* if there's a problem
*/
- public void generateService(OMFactory fac, OMElement defintions, boolean disableREST,
+ public OMElement generateService(OMFactory fac, OMElement defintions, boolean disableREST,
boolean disableSOAP12, boolean disableSOAP11)
throws Exception {
OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
@@ -540,6 +503,7 @@ public class AxisService2WSDL11 implemen
// generateHTTPPorts(fac, service);
generateHttpPort(fac, definition, service);
}
+ return service;
}
private void writeSoapHeaders(AxisMessage inaxisMessage, OMFactory fac,
@@ -643,7 +607,7 @@ public class AxisService2WSDL11 implemen
}
}
- private void addPoliciesToDefinitionElement(Iterator iterator,
+ protected void addPoliciesToDefinitionElement(Iterator iterator,
OMElement definitionElement) throws Exception {
Policy policy;
OMElement policyElement;
@@ -702,8 +666,7 @@ public class AxisService2WSDL11 implemen
String version = (String) axisBinding
.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(version)) {
- OMElement port = fac.createOMElement(PORT, wsdl);
- service.addChild(port);
+ OMElement port = fac.createOMElement(PORT, wsdl);
port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(),
null);
QName qname = axisBinding.getName();
@@ -715,8 +678,16 @@ public class AxisService2WSDL11 implemen
: endpointURL, soap);
generateEPRElement(fac, port, endpointURL);
addPolicyAsExtElement(axisEndpoint, port);
- generateSoap11Binding(fac, definition, axisEndpoint
+ service.addChild(modifyPort(port));
+ if (isAlreadyAdded(axisBinding, definition)) {
+ return;
+ }
+ OMElement binding = generateSoap11Binding(fac, axisEndpoint
.getBinding());
+ OMElement serviceElement = definition.getFirstChildWithName(new QName(
+ wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
+ serviceElement.insertSiblingBefore(modifyBinding(binding));
+
}
}
}
@@ -745,8 +716,7 @@ public class AxisService2WSDL11 implemen
.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(version)) {
- OMElement port = fac.createOMElement(PORT, wsdl);
- service.addChild(port);
+ OMElement port = fac.createOMElement(PORT, wsdl);
port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(),
null);
QName qname = axisBinding.getName();
@@ -758,8 +728,13 @@ public class AxisService2WSDL11 implemen
: endpointURL, soap12);
generateEPRElement(fac, port, endpointURL);
addPolicyAsExtElement(axisEndpoint, port);
- generateSoap12Binding(fac, definition, axisEndpoint
+ service.addChild(modifyPort(port));
+ if (isAlreadyAdded(axisBinding, definition)) {
+ return;
+ }
+ OMElement binding = generateSoap12Binding(fac, definition, axisEndpoint
.getBinding());
+ service.insertSiblingBefore(modifyBinding(binding));
}
}
}
@@ -782,8 +757,7 @@ public class AxisService2WSDL11 implemen
axisBinding = axisEndpoint.getBinding();
String type = axisBinding.getType();
if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
- OMElement port = fac.createOMElement(PORT, wsdl);
- service.addChild(port);
+ OMElement port = fac.createOMElement(PORT, wsdl);
port.addAttribute(ATTRIBUTE_NAME, axisEndpoint.getName(), null);
QName qname = axisBinding.getName();
port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":"
@@ -795,21 +769,20 @@ public class AxisService2WSDL11 implemen
port.addChild(extElement);
addPolicyAsExtElement(axisEndpoint, port);
- generateHttpBinding(fac, definition, axisEndpoint.getBinding());
+ service.addChild(modifyPort(port));
+ if (isAlreadyAdded(axisBinding, definition)) {
+ return;
+ }
+ OMElement binding = generateHttpBinding(fac, definition, axisEndpoint.getBinding());
+ service.insertSiblingBefore(modifyBinding(binding));
+
}
}
}
- private void generateSoap11Binding(OMFactory fac, OMElement defintions,
- AxisBinding axisBinding) throws Exception {
- if (isAlreadyAdded(axisBinding, defintions)) {
- return;
- }
- OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
- OMElement serviceElement = defintions.getFirstChildWithName(new QName(
- wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
- serviceElement.insertSiblingBefore(binding);
-
+ protected OMElement generateSoap11Binding(OMFactory fac, AxisBinding axisBinding) throws Exception {
+
+ OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
QName qname = axisBinding.getName();
binding.addAttribute(ATTRIBUTE_NAME, qname.getLocalPart(), null);
@@ -946,17 +919,15 @@ public class AxisService2WSDL11 implemen
}
}
}
+ return binding;
}
- private void generateSoap12Binding(OMFactory fac, OMElement definitions,
+ private OMElement generateSoap12Binding(OMFactory fac, OMElement definitions,
AxisBinding axisBinding) throws Exception {
- if (isAlreadyAdded(axisBinding, definitions)) {
- return;
- }
+
OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
OMElement serviceElement = definitions.getFirstChildWithName(new QName(
- wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
- serviceElement.insertSiblingBefore(binding);
+ wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
QName qname = axisBinding.getName();
binding.addAttribute(ATTRIBUTE_NAME, qname.getLocalPart(), null);
@@ -1093,17 +1064,16 @@ public class AxisService2WSDL11 implemen
}
}
}
+ return binding;
}
- private void generateHttpBinding(OMFactory fac, OMElement definitions,
+ private OMElement generateHttpBinding(OMFactory fac, OMElement definitions,
AxisBinding axisBinding) throws Exception {
- if (isAlreadyAdded(axisBinding, definitions)) {
- return;
- }
+
OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
OMElement serviceElement = definitions.getFirstChildWithName(new QName(
wsdl.getNamespaceURI(), SERVICE_LOCAL_NAME));
- serviceElement.insertSiblingBefore(binding);
+
QName qname = axisBinding.getName();
binding.addAttribute(ATTRIBUTE_NAME, qname.getLocalPart(), null);
@@ -1216,6 +1186,7 @@ public class AxisService2WSDL11 implemen
}
}
}
+ return binding;
}
private void addPolicyAsExtElement(AxisDescription axisDescription,
@@ -1435,4 +1406,121 @@ public class AxisService2WSDL11 implemen
port.addChild(wsaEpr);
}
+
+ protected OMElement generateDocumentation(OMFactory fac){
+ return WSDLSerializationUtil.generateDocumentationElement(axisService, fac, wsdl);
+ }
+
+ protected OMElement generateTypes(OMFactory fac){
+
+ OMElement wsdlTypes = fac.createOMElement("types", wsdl);
+
+ // populate the schema mappings
+ axisService.populateSchemaMappings();
+
+ ArrayList schemas = axisService.getSchema();
+ for (int i = 0; i < schemas.size(); i++) {
+ StringWriter writer = new StringWriter();
+
+ // XmlSchema schema = (XmlSchema) schemas.get(i);
+ XmlSchema schema = axisService.getSchema(i);
+
+ String targetNamespace = schema.getTargetNamespace();
+ if (!Constants.NS_URI_XML.equals(targetNamespace)) {
+ schema.write(writer);
+ String schemaString = writer.toString();
+ if (!"".equals(schemaString)) {
+ try {
+ wsdlTypes.addChild(XMLUtils.toOM(new StringReader(schemaString)));
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+ }
+ return wsdlTypes;
+ }
+
+
+ protected OMElement generateDefinition(OMFactory fac){
+
+ wsdl = fac.createOMNamespace(WSDL_NAMESPACE, DEFAULT_WSDL_NAMESPACE_PREFIX);
+ OMElement ele = fac.createOMElement("definitions", wsdl);
+ setDefinitionElement(ele);
+
+ policiesInDefinitions = new HashMap<String, Policy>();
+
+ Map namespaceMap = axisService.getNamespaceMap();
+ if (namespaceMap == null)
+ namespaceMap = new HashMap();
+
+ WSDLSerializationUtil.populateNamespaces(ele, namespaceMap);
+ soap = ele.declareNamespace(URI_WSDL11_SOAP, SOAP11_PREFIX);
+ soap12 = ele.declareNamespace(URI_WSDL12_SOAP, SOAP12_PREFIX);
+ http = ele.declareNamespace(HTTP_NAMESPACE, HTTP_PREFIX);
+ mime = ele.declareNamespace(MIME_NAMESPACE, MIME_PREFIX);
+ wsaw = ele.declareNamespace(AddressingConstants.Final.WSAW_NAMESPACE, "wsaw");
+ String prefix = WSDLSerializationUtil.getPrefix(axisService.getTargetNamespace(),
+ namespaceMap);
+ if (prefix == null || "".equals(prefix)) {
+ if (axisService.getTargetNamespacePrefix() != null) {
+ prefix = axisService.getTargetNamespacePrefix();
+ } else {
+ prefix = DEFAULT_TARGET_NAMESPACE_PREFIX;
+ }
+ }
+
+ namespaceMap.put(prefix, axisService.getTargetNamespace());
+ tns = ele.declareNamespace(axisService.getTargetNamespace(), prefix);
+
+ definition.addAttribute("targetNamespace", axisService.getTargetNamespace(), null);
+
+ return ele;
+ }
+
+ protected boolean isDisableREST() {
+ // axis2.xml indicated no HTTP binding?
+ boolean disableREST = false;
+ Parameter disableRESTParameter = axisService
+ .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_REST);
+ if (disableRESTParameter != null
+ && JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
+ disableREST = true;
+ }
+ return disableREST;
+ }
+
+ protected boolean isDisableSOAP11() {
+ boolean disableSOAP11 = false;
+ Parameter disableSOAP11Parameter = axisService
+ .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
+ if (disableSOAP11Parameter != null
+ && JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
+ disableSOAP11 = true;
+ }
+ return disableSOAP11;
+ }
+
+ protected boolean isDisableSOAP12() {
+ // axis2.xml indicated no SOAP 1.2 binding?
+ boolean disableSOAP12 = false;
+ Parameter disableSOAP12Parameter = axisService
+ .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP12);
+ if (disableSOAP12Parameter != null
+ && JavaUtils.isTrueExplicitly(disableSOAP12Parameter.getValue())) {
+ disableSOAP12 = true;
+ }
+ return disableSOAP12;
+ }
+
+ protected Map<String, Policy> getPoliciesInDefinitions() {
+ return policiesInDefinitions;
+ }
+ protected OMElement modifyPort(OMElement port){
+ return port;
+ }
+ protected OMElement modifyBinding(OMElement binding){
+ return binding;
+ }
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java?rev=1358606&r1=1358605&r2=1358606&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java Sat Jul 7 17:55:31 2012
@@ -477,15 +477,23 @@ public class WSDLSerializationUtil {
}
public static void addWSDLDocumentationElement(AxisDescription axisDescription,
- OMElement omElement, OMFactory omFactory,
- OMNamespace wsdl) {
+ OMElement omElement, OMFactory omFactory, OMNamespace wsdl) {
+ OMElement documentation = generateDocumentationElement(axisDescription, omFactory, wsdl);
+ if (documentation != null) {
+ omElement.addChild(documentation);
+ }
+ }
+
+ public static OMElement generateDocumentationElement(AxisDescription axisDescription,
+ OMFactory omFactory, OMNamespace wsdl) {
OMNode documentationNode = axisDescription.getDocumentationNode();
OMElement documentation;
if (documentationNode != null) {
documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
documentation.addChild(documentationNode);
- omElement.addChild(documentation);
+ return documentation;
}
+ return null;
}
public static void addPoliciesAsExtensibleElement(
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.dataretrieval.WSDLSupplier;
+
+public class TestWSDL11Supplier implements WSDLSupplier {
+ public Definition getWSDL(AxisService service) throws AxisFault {
+ Definition def = null;
+ try {
+ def = WSDLFactory.newInstance().newDefinition();
+ def.setQName(new QName("TestWSDL11SupplierDefinition"));
+ } catch (WSDLException e) {
+ e.printStackTrace();
+ }
+ return def;
+
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11Supplier.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.dataretrieval.WSDL11SupplierTemplate;
+
+class TestWSDL11SupplierTemplate extends WSDL11SupplierTemplate {
+
+ @Override
+ protected OMElement customizeDocumentation(OMElement documentation) {
+ OMFactory fac = documentation.getOMFactory();
+ OMElement details = fac.createOMElement("detail", "http://axis.apache.org", "ap");
+ OMElement name = fac.createOMElement("name", "http://axis.apache.org", "ap");
+ name.setText("Apache Axis2");
+ OMElement mail = fac.createOMElement("email", "http://axis.apache.org", "ap");
+ mail.setText("user@axis.apache.org");
+ details.addChild(name);
+ details.addChild(mail);
+ documentation.addChild(details);
+ OMElement doc = documentation.getFirstChildWithName(new QName("documentation"));
+ doc.detach();
+ return documentation;
+ }
+
+ @Override
+ protected OMElement customizePort(OMElement service) {
+ OMElement address = service.getFirstElement();
+ OMAttribute location = address.getAttribute(new QName("location"));
+ String url = location.getAttributeValue();
+ url = url.replace("192.168.1.3", "localhost");
+ location.setAttributeValue(url);
+ return service;
+ }
+
+}
\ No newline at end of file
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL11SupplierTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.dataretrieval.WSDLSupplier;
+import org.apache.woden.wsdl20.Description;
+
+class TestWSDL20Supplier implements WSDLSupplier {
+ public Description getWSDL(AxisService service) throws AxisFault {
+ Description des = null;
+ try {
+ des = org.apache.woden.WSDLFactory.newInstance().newEdDescription();
+
+ } catch (org.apache.woden.WSDLException e) {
+ e.printStackTrace();
+ }
+ return des;
+
+ }
+}
\ No newline at end of file
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20Supplier.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java?rev=1358606&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java Sat Jul 7 17:55:31 2012
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.description;
+
+import javax.xml.namespace.QName;
+
+import java.io.ByteArrayOutputStream;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.Constants;
+import org.apache.axis2.dataretrieval.WSDL11SupplierTemplate;
+import org.apache.axis2.engine.AxisConfiguration;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class WSDLSupplierTest extends TestCase {
+
+ private AxisService axisService;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ axisService = new AxisService();
+ axisService.setName("TestWSDLService");
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMElement documentation = factory.createOMElement(new QName("documentation"));
+ axisService.setDocumentation(documentation);
+
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ axisService = null;
+ super.tearDown();
+ }
+
+ public void testWSDLSupplierWSDL11() throws Exception {
+ Object value = new TestWSDL11Supplier();
+ axisService.addParameter(Constants.WSDL_SUPPLIER_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl
+ .contains("<wsdl:definitions name=\"TestWSDL11SupplierDefinition\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">"));
+ assertTrue(wsdl.contains("</wsdl:definitions>"));
+ }
+
+ public void testWSDLSupplierWSDL1SupplierClass() throws Exception {
+ String value = TestWSDL11Supplier.class.getName();
+ axisService.addParameter(Constants.WSDL_11_SUPPLIER_CLASS_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl
+ .contains("<wsdl:definitions name=\"TestWSDL11SupplierDefinition\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">"));
+ assertTrue(wsdl.contains("</wsdl:definitions>"));
+ }
+
+ public void testWSDLSupplierWSDL20() throws Exception {
+ String value = TestWSDL20Supplier.class.getName();
+ axisService.addParameter(Constants.WSDL_20_SUPPLIER_CLASS_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL2(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl.contains("<wsdl:description xmlns:wsdl=\"http://www.w3.org/ns/wsdl\">"));
+ assertTrue(wsdl.contains("</wsdl:description>"));
+ }
+
+ public void testWSDLSupplierWSDL2SupplierClass() throws Exception {
+ Object value = new TestWSDL20Supplier();
+ axisService.addParameter(Constants.WSDL_SUPPLIER_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL2(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl.contains("<wsdl:description xmlns:wsdl=\"http://www.w3.org/ns/wsdl\">"));
+ assertTrue(wsdl.contains("</wsdl:description>"));
+ }
+
+ public void testWSDL11SupplierTemplate() throws Exception {
+ WSDL11SupplierTemplate value = new TestWSDL11SupplierTemplate();
+ axisService.addParameter(Constants.WSDL_SUPPLIER_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl
+ .contains("<wsdl:definitions xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:wsaw=\"http://www.w3.org/2006/05/"
+ + "addressing/wsdl\" xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" "
+ + "xmlns:tns=\"http://ws.apache.org/axis2\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" "
+ + "xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\" xmlns:soap12=\"http://schemas.xmlsoap.org/wsdl/soap12/\" "
+ + "targetNamespace=\"http://ws.apache.org/axis2\">"));
+ assertTrue(wsdl.contains("<wsdl:documentation>"));
+ assertTrue(wsdl.contains("<ap:detail xmlns:ap=\"http://axis.apache.org\">"));
+ assertTrue(wsdl.contains("<ap:name>Apache Axis2</ap:name>"));
+ assertTrue(wsdl.contains("<ap:email>user@axis.apache.org</ap:email>"));
+ assertTrue(wsdl.contains(" </ap:detail>"));
+ assertTrue(wsdl.contains("</wsdl:documentation>"));
+ assertFalse(wsdl.contains("<documentation/>"));
+ }
+
+ public void testWSDL11SupplierTemplateWSDL1SupplierClass() throws Exception {
+ String value = TestWSDL11SupplierTemplate.class.getName();
+ axisService.addParameter(Constants.WSDL_11_SUPPLIER_CLASS_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl
+ .contains("<wsdl:definitions xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:wsaw=\"http://www.w3.org/2006/05/"
+ + "addressing/wsdl\" xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" "
+ + "xmlns:tns=\"http://ws.apache.org/axis2\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" "
+ + "xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\" xmlns:soap12=\"http://schemas.xmlsoap.org/wsdl/soap12/\" "
+ + "targetNamespace=\"http://ws.apache.org/axis2\">"));
+ assertTrue(wsdl.contains("<wsdl:documentation>"));
+ assertTrue(wsdl.contains("<ap:detail xmlns:ap=\"http://axis.apache.org\">"));
+ assertTrue(wsdl.contains("<ap:name>Apache Axis2</ap:name>"));
+ assertTrue(wsdl.contains("<ap:email>user@axis.apache.org</ap:email>"));
+ assertTrue(wsdl.contains(" </ap:detail>"));
+ assertTrue(wsdl.contains("</wsdl:documentation>"));
+ assertFalse(wsdl.contains("<documentation/>"));
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java
------------------------------------------------------------------------------
svn:eol-style = native