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/08/25 07:33:52 UTC
svn commit: r1377218 - in /axis/axis2/java/core/trunk/modules/kernel:
src/org/apache/axis2/dataretrieval/ src/org/apache/axis2/description/
src/org/apache/axis2/util/ test/org/apache/axis2/description/
Author: sagara
Date: Sat Aug 25 05:33:51 2012
New Revision: 1377218
URL: http://svn.apache.org/viewvc?rev=1377218&view=rev
Log:
AXIS2-5279 - applied wsdl2 patch.
Added:
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.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/AxisService2WSDL20.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/WSDLSerializationUtil.java
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java
Modified: 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=1377218&r1=1377217&r2=1377218&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/dataretrieval/WSDL20SupplierTemplate.java Sat Aug 25 05:33:51 2012
@@ -19,13 +19,112 @@
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;
+import org.apache.axis2.description.AxisService2WSDL20;
+
+public class WSDL20SupplierTemplate extends AxisService2WSDL20 implements WSDLSupplier{
+
+ public final void init(AxisService service) {
+ super.axisService = service;
+ super.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);
+ }
+ }
+
+
+ public OMElement generateOM() throws Exception {
+
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMElement descriptionElement = generateDescription(omFactory);
+
+ // Add the documentation element
+ OMElement documentation = customizeDocumentation(generateDocumentation(omFactory));
+ if (documentation != null) {
+ descriptionElement.addChild(documentation);
+ }
+
+ OMElement types = customizeTypes(generateTypes(omFactory));
+ if (types != null) {
+ descriptionElement.addChild(types);
+ }
+
+ OMElement interfaces = customizeInterface(generateInterface(omFactory));
+ if (interfaces != null) {
+ descriptionElement.addChild(interfaces);
+ }
+
+ customizeService(generateService(omFactory, descriptionElement, isDisableREST(), isDisableSOAP12(),
+ isDisableSOAP11()));
+
+ addPoliciesToDescriptionElement(getPoliciesInDefinitions(),
+ descriptionElement);
+
+ return descriptionElement;
+ }
+
+
+
+
+ protected OMElement customizeDocumentation(OMElement documentation) {
+ return documentation;
+ }
+
+ protected OMElement customizeTypes(OMElement types) {
+ return types;
+ }
+
+
+ protected OMElement customizeInterface(OMElement portType) {
+ return portType;
+ }
+
+ protected final OMElement customizeService(OMElement service) {
+ return service;
+ }
+
+ protected OMElement customizeEndpoint(OMElement port) {
+ return port;
+ }
+
+ protected OMElement customizeBinding(OMElement binding) {
+ return binding;
+ }
+
+ /**
+ * This method use by AxisService2WSDL11 and users should not touch this
+ * method.
+ */
+ protected final OMElement modifyEndpoint(OMElement endpoint) {
+ return customizeEndpoint(endpoint);
+ }
-public class WSDL20SupplierTemplate implements WSDLSupplier{
+ /**
+ * This method use by AxisService2WSDL11 and users should not touch this
+ * method.
+ */
+ protected final OMElement modifyBinding(OMElement binding) {
+ return customizeBinding(binding);
+ }
- public Object getWSDL(AxisService service) throws AxisFault {
- return null;
- }
+
}
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=1377218&r1=1377217&r2=1377218&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 Aug 25 05:33:51 2012
@@ -38,6 +38,7 @@ import org.apache.axis2.dataretrieval.Lo
import org.apache.axis2.dataretrieval.OutputForm;
import org.apache.axis2.dataretrieval.SchemaSupplier;
import org.apache.axis2.dataretrieval.WSDL11SupplierTemplate;
+import org.apache.axis2.dataretrieval.WSDL20SupplierTemplate;
import org.apache.axis2.dataretrieval.WSDLSupplier;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.util.ExcludeInfo;
@@ -1819,7 +1820,10 @@ public class AxisService extends AxisDes
// 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);
+ supplier = (WSDLSupplier) getParameterValue(Constants.WSDL_SUPPLIER_PARAM);
+ if(supplier instanceof WSDL20SupplierTemplate){
+ ((WSDL20SupplierTemplate)supplier).init(this);
+ }
}
if (supplier != null) {
Object wsdlContent = supplier.getWSDL(this);
@@ -1840,8 +1844,8 @@ public class AxisService extends AxisDes
OMElement wsdlElement = (OMElement) wsdlContent;
QName wsdlName = wsdlElement.getQName();
if (wsdlName != null
- && wsdlName.getLocalPart().equals("definitions")
- && wsdlName.getNamespaceURI().equals("http://schemas.xmlsoap.org/wsdl/")) {
+ && wsdlName.getLocalPart().equals("description")
+ && wsdlName.getNamespaceURI().equals("http://www.w3.org/ns/wsdl")) {
// TODO How to address port number/ ip name customization
// here ?
try {
@@ -3456,10 +3460,9 @@ public class AxisService extends AxisDes
if(para != null){
try {
wsdlSupplier = (WSDLSupplier) Class.forName((String) para.getValue()).newInstance() ;
- //TODO
-// if( wsdlSupplier instanceof WSDL20SupplierTemplate){
-// ((WSDL20SupplierTemplate)wsdlSupplier).init(this);
-// }
+ if( wsdlSupplier instanceof WSDL20SupplierTemplate){
+ ((WSDL20SupplierTemplate)wsdlSupplier).init(this);
+ }
} catch (Exception e) {
System.err.println("Following exception occurred when generating WSDL using "+ para );
e.printStackTrace();
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=1377218&r1=1377217&r2=1377218&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Sat Aug 25 05:33:51 2012
@@ -71,15 +71,28 @@ import java.util.Set;
public class AxisService2WSDL20 implements WSDL2Constants {
- private AxisService axisService;
- private String serviceName;
+ protected AxisService axisService;
+ protected String serviceName;
private String[] eprs = null;
private OMNamespace wsaw;
+ private OMNamespace wsdl;
+ private OMNamespace wsoap;
+ private OMNamespace whttp;
+ private OMNamespace wsdlx;
+ private OMNamespace wrpc;
+ private OMNamespace tns;
+ private String interfaceName;
private HashMap policiesInDescription = new HashMap();
private ExternalPolicySerializer filter = null;
private boolean checkIfEndPointActive = true;
+
+ public AxisService2WSDL20() { }
+
+ protected void init() throws AxisFault {
+
+ }
public AxisService2WSDL20(AxisService service) {
this.axisService = service;
@@ -110,296 +123,33 @@ public class AxisService2WSDL20 implemen
*/
public OMElement generateOM() throws Exception {
- Map nameSpacesMap = axisService.getNamespaceMap();
OMFactory omFactory = OMAbstractFactory.getOMFactory();
- OMNamespace wsdl;
-
- //
- filter = new ExternalPolicySerializer();
- AxisConfiguration axisConfiguration = axisService
- .getAxisConfiguration();
- if (axisConfiguration != null) {
- filter.setAssertionsToFilter(axisConfiguration
- .getLocalPolicyAssertions());
- }
- //
-
- if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.WSDL_NAMESPACE)) {
- wsdl = omFactory
- .createOMNamespace(WSDL2Constants.WSDL_NAMESPACE,
- WSDLSerializationUtil.getPrefix(
- WSDL2Constants.WSDL_NAMESPACE, nameSpacesMap));
- } else {
- wsdl = omFactory
- .createOMNamespace(WSDL2Constants.WSDL_NAMESPACE,
- WSDL2Constants.DEFAULT_WSDL_NAMESPACE_PREFIX);
- }
-
- OMElement descriptionElement = omFactory.createOMElement(WSDL2Constants.DESCRIPTION, wsdl);
-
- // Declare all the defined namespaces in the document
- WSDLSerializationUtil.populateNamespaces(descriptionElement, nameSpacesMap);
-
- descriptionElement.declareNamespace(axisService.getTargetNamespace(),
- axisService.getTargetNamespacePrefix());
- wsaw = descriptionElement.declareNamespace(AddressingConstants.Final.WSAW_NAMESPACE, "wsaw");
- // Need to add the targetnamespace as an attribute according to the wsdl 2.0 spec
- OMAttribute targetNamespace = omFactory
- .createOMAttribute(WSDL2Constants.TARGET_NAMESPACE, null,
- axisService.getTargetNamespace());
- descriptionElement.addAttribute(targetNamespace);
-
- // Check whether the required namespaces are already in namespaceMap, if they are not
- // present declare them.
- OMNamespace wsoap;
- OMNamespace whttp;
- OMNamespace wsdlx;
- OMNamespace wrpc;
-
- OMNamespace tns = omFactory
- .createOMNamespace(axisService.getTargetNamespace(),
- axisService.getTargetNamespacePrefix());
- if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_SOAP)) {
- wsoap = omFactory
- .createOMNamespace(WSDL2Constants.URI_WSDL2_SOAP,
- WSDLSerializationUtil.getPrefix(
- WSDL2Constants.URI_WSDL2_SOAP, nameSpacesMap));
- } else {
- wsoap = descriptionElement
- .declareNamespace(WSDL2Constants.URI_WSDL2_SOAP, WSDL2Constants.SOAP_PREFIX);
- }
- if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_HTTP)) {
- whttp = omFactory
- .createOMNamespace(WSDL2Constants.URI_WSDL2_HTTP,
- WSDLSerializationUtil.getPrefix(
- WSDL2Constants.URI_WSDL2_HTTP, nameSpacesMap));
- } else {
- whttp = descriptionElement
- .declareNamespace(WSDL2Constants.URI_WSDL2_HTTP, WSDL2Constants.HTTP_PREFIX);
- }
- if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_EXTENSIONS)) {
- wsdlx = omFactory
- .createOMNamespace(WSDL2Constants.URI_WSDL2_EXTENSIONS,
- WSDLSerializationUtil.getPrefix(
- WSDL2Constants.URI_WSDL2_EXTENSIONS, nameSpacesMap));
- } else {
- wsdlx = descriptionElement.declareNamespace(WSDL2Constants.URI_WSDL2_EXTENSIONS,
- WSDL2Constants.WSDL_EXTENTION_PREFIX);
- }
- if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_RPC)) {
- wrpc = omFactory
- .createOMNamespace(WSDL2Constants.URI_WSDL2_RPC,
- WSDLSerializationUtil.getPrefix(
- WSDL2Constants.URI_WSDL2_RPC, nameSpacesMap));
- } else {
- wrpc = descriptionElement.declareNamespace(WSDL2Constants.URI_WSDL2_RPC,
- WSDL2Constants.WSDL_RPC_PREFIX);
- }
+ OMElement descriptionElement = generateDescription(omFactory);
// Add the documentation element
- WSDLSerializationUtil
- .addWSDLDocumentationElement(axisService, descriptionElement, omFactory, wsdl);
-
- // Add types element
- OMElement typesElement = omFactory.createOMElement(WSDL2Constants.TYPES_LOCAL_NALE, wsdl);
- axisService.populateSchemaMappings();
- ArrayList schemas = axisService.getSchema();
- for (int i = 0; i < schemas.size(); i++) {
- StringWriter writer = new StringWriter();
- XmlSchema schema = axisService.getSchema(i);
-
- if (!org.apache.axis2.namespace.Constants.URI_2001_SCHEMA_XSD
- .equals(schema.getTargetNamespace())) {
- schema.write(writer);
- String schemaString = writer.toString();
-
- if (!"".equals(schemaString)) {
- try {
- typesElement.addChild(
- XMLUtils.toOM(new ByteArrayInputStream(schemaString.getBytes())));
- } catch (XMLStreamException e) {
- throw AxisFault.makeFault(e);
- }
- }
- }
+ OMElement documentation = generateDocumentation(omFactory);
+ if (documentation != null) {
+ descriptionElement.addChild(documentation);
}
- descriptionElement.addChild(typesElement);
- Parameter parameter = axisService.getParameter(WSDL2Constants.INTERFACE_LOCAL_NAME);
- String interfaceName;
- if (parameter != null) {
- interfaceName = (String) parameter.getValue();
- } else {
- interfaceName = WSDL2Constants.DEFAULT_INTERFACE_NAME;
+ OMElement types = generateTypes(omFactory);
+ if (types != null) {
+ descriptionElement.addChild(types);
}
- // Add the interface element
- descriptionElement.addChild(getInterfaceElement(wsdl, tns, wsdlx, wrpc, omFactory,
- interfaceName));
-
- // axis2.xml indicated no HTTP binding?
- boolean disableREST = false;
- Parameter disableRESTParameter =
- axisService.getParameter(Constants.Configuration.DISABLE_REST);
- if (disableRESTParameter != null &&
- JavaUtils.isTrueExplicitly(disableRESTParameter.getValue())) {
- disableREST = true;
+ OMElement interfaces = generateInterface(omFactory);
+ if (interfaces != null) {
+ descriptionElement.addChild(interfaces);
}
- boolean disableSOAP11 = false;
- Parameter disableSOAP11Parameter = axisService
- .getParameter(org.apache.axis2.Constants.Configuration.DISABLE_SOAP11);
- if (disableSOAP11Parameter != null
- && JavaUtils.isTrueExplicitly(disableSOAP11Parameter.getValue())) {
- disableSOAP11 = true;
- }
+ generateService(omFactory, descriptionElement, isDisableREST(), isDisableSOAP12(),
+ isDisableSOAP11());
- // 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;
- }
-
- // Check whether the axisService has any endpoints. If they exists serialize them else
- // generate default endpoint elements.
- Set bindings = new HashSet();
- Map endpointMap = axisService.getEndpoints();
- Object value = axisService.getParameterValue("isCodegen");
- boolean isCodegen = false;
- if (JavaUtils.isTrueExplicitly(value)) {
- isCodegen = true;
- }
- if (endpointMap != null && endpointMap.size() > 0) {
-
- OMElement serviceElement = getServiceElement(wsdl, tns, omFactory, interfaceName);
- Iterator iterator = endpointMap.values().iterator();
- while (iterator.hasNext()) {
- // With the new binding hierachy in place we need to do some extra checking here.
- // If a service has both http and https listners up we should show two separate eprs
- // If the service was deployed with a WSDL and it had two endpoints for http and
- // https then we have two endpoints populated so we should serialize them instead
- // of updating the endpoints.
- AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
- /*
- * Some transports might not be active at runtime.
- */
- if (!isCodegen && checkIfEndPointActive && !axisEndpoint.isActive()) {
- continue;
- }
- AxisBinding axisBinding = axisEndpoint.getBinding();
- String type = axisBinding.getType();
-
- // If HTTP binding is disabled, do not add.
- if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
- if (disableREST) {
- continue;
- }
- }
-
- // If SOAP 1.2 binding is disabled, do not add.
- String propertySOAPVersion =
- (String) axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
- if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
- if (disableSOAP12) {
- continue;
- }
- }
-
- if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
- if (disableSOAP11) {
- continue;
- }
- }
-
-
-
- bindings.add(axisBinding);
- OMElement endpointElement = axisEndpoint.toWSDL20(wsdl, tns, whttp);
- boolean endpointAlreadyAdded = false;
- Iterator endpointsAdded = serviceElement.getChildren();
- while (endpointsAdded.hasNext()) {
- OMElement endpoint = (OMElement) endpointsAdded.next();
- // Checking whether a endpoint with the same binding and address exists.
- if (endpoint.getAttribute(new QName(WSDL2Constants.BINDING_LOCAL_NAME))
- .getAttributeValue().equals(endpointElement.getAttribute(
- new QName(WSDL2Constants.BINDING_LOCAL_NAME)).getAttributeValue())
- && endpoint
- .getAttribute(new QName(WSDL2Constants.ATTRIBUTE_ADDRESS))
- .getAttributeValue().equals(endpointElement.getAttribute(
- new QName(WSDL2Constants.ATTRIBUTE_ADDRESS)).getAttributeValue())) {
- endpointAlreadyAdded = true;
- }
-
- }
- if (!endpointAlreadyAdded) {
-// addPolicyAsExtensibleElement(axisEndpoint, endpointElement);
- Parameter modifyAddressParam = axisService
- .getParameter("modifyUserWSDLPortAddress");
- if (modifyAddressParam != null) {
- if (Boolean.parseBoolean((String) modifyAddressParam
- .getValue())) {
- String endpointURL = axisEndpoint
- .calculateEndpointURL();
- endpointElement
- .getAttribute(
- new QName(
- WSDL2Constants.ATTRIBUTE_ADDRESS))
- .setAttributeValue(endpointURL);
- }
- }
- serviceElement.addChild(endpointElement);
- }
- }
- Iterator iter = bindings.iterator();
- while (iter.hasNext()) {
- AxisBinding binding = (AxisBinding) iter.next();
- OMElement bindingElement = binding.toWSDL20(wsdl, tns, wsoap, whttp,
- interfaceName,
- axisService.getNamespaceMap(),
- AddressingHelper.getAddressingRequirementParemeterValue(axisService),
- serviceName,wsaw);
- descriptionElement
- .addChild(bindingElement);
- }
-
- descriptionElement.addChild(serviceElement);
- } else {
-
- // There are no andpoints defined hence generate default bindings and endpoints
- descriptionElement.addChild(
- WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
- tns, serviceName));
- if (!disableSOAP12) {
- descriptionElement.addChild(
- WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl, wsoap,
- tns, serviceName));
- }
- if (!disableSOAP11) {
- descriptionElement.addChild(
- WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
- tns, serviceName));
- }
- if (!disableREST) {
- descriptionElement.addChild(
- WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
- whttp,
- tns, serviceName));
- }
- descriptionElement
- .addChild(WSDLSerializationUtil.generateServiceElement(omFactory, wsdl, tns,
- axisService, disableREST,
- disableSOAP12,disableSOAP11, eprs,
- serviceName));
- }
-
- ArrayList policies = new ArrayList(policiesInDescription.values());
- addPoliciesToDescriptionElement(policies, descriptionElement);
+ addPoliciesToDescriptionElement(getPoliciesInDefinitions(),
+ descriptionElement);
return descriptionElement;
- }
+ }
/**
* Generates the interface element for the service
@@ -866,7 +616,7 @@ public class AxisService2WSDL20 implemen
}
}
- private void addPoliciesToDescriptionElement(List policies,
+ protected void addPoliciesToDescriptionElement(List policies,
OMElement descriptionElement) throws XMLStreamException,
FactoryConfigurationError {
@@ -882,4 +632,464 @@ public class AxisService2WSDL20 implemen
}
}
}
+
+ protected OMElement generateDescription(OMFactory omFactory) {
+
+
+ Map nameSpacesMap = axisService.getNamespaceMap();
+ filter = new ExternalPolicySerializer();
+ AxisConfiguration axisConfiguration = axisService
+ .getAxisConfiguration();
+ if (axisConfiguration != null) {
+ filter.setAssertionsToFilter(axisConfiguration
+ .getLocalPolicyAssertions());
+ }
+ //
+
+ if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.WSDL_NAMESPACE)) {
+ wsdl = omFactory
+ .createOMNamespace(WSDL2Constants.WSDL_NAMESPACE,
+ WSDLSerializationUtil.getPrefix(
+ WSDL2Constants.WSDL_NAMESPACE, nameSpacesMap));
+ } else {
+ wsdl = omFactory
+ .createOMNamespace(WSDL2Constants.WSDL_NAMESPACE,
+ WSDL2Constants.DEFAULT_WSDL_NAMESPACE_PREFIX);
+ }
+
+ OMElement descriptionElement = omFactory.createOMElement(WSDL2Constants.DESCRIPTION, wsdl);
+
+ // Declare all the defined namespaces in the document
+ WSDLSerializationUtil.populateNamespaces(descriptionElement, nameSpacesMap);
+
+ descriptionElement.declareNamespace(axisService.getTargetNamespace(),
+ axisService.getTargetNamespacePrefix());
+ wsaw = descriptionElement.declareNamespace(AddressingConstants.Final.WSAW_NAMESPACE, "wsaw");
+ // Need to add the targetnamespace as an attribute according to the wsdl 2.0 spec
+ OMAttribute targetNamespace = omFactory
+ .createOMAttribute(WSDL2Constants.TARGET_NAMESPACE, null,
+ axisService.getTargetNamespace());
+ descriptionElement.addAttribute(targetNamespace);
+
+ // Check whether the required namespaces are already in namespaceMap, if they are not
+ // present declare them.
+
+
+ tns = omFactory
+ .createOMNamespace(axisService.getTargetNamespace(),
+ axisService.getTargetNamespacePrefix());
+ if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_SOAP)) {
+ wsoap = omFactory
+ .createOMNamespace(WSDL2Constants.URI_WSDL2_SOAP,
+ WSDLSerializationUtil.getPrefix(
+ WSDL2Constants.URI_WSDL2_SOAP, nameSpacesMap));
+ } else {
+ wsoap = descriptionElement
+ .declareNamespace(WSDL2Constants.URI_WSDL2_SOAP, WSDL2Constants.SOAP_PREFIX);
+ }
+ if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_HTTP)) {
+ whttp = omFactory
+ .createOMNamespace(WSDL2Constants.URI_WSDL2_HTTP,
+ WSDLSerializationUtil.getPrefix(
+ WSDL2Constants.URI_WSDL2_HTTP, nameSpacesMap));
+ } else {
+ whttp = descriptionElement
+ .declareNamespace(WSDL2Constants.URI_WSDL2_HTTP, WSDL2Constants.HTTP_PREFIX);
+ }
+ if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_EXTENSIONS)) {
+ wsdlx = omFactory
+ .createOMNamespace(WSDL2Constants.URI_WSDL2_EXTENSIONS,
+ WSDLSerializationUtil.getPrefix(
+ WSDL2Constants.URI_WSDL2_EXTENSIONS, nameSpacesMap));
+ } else {
+ wsdlx = descriptionElement.declareNamespace(WSDL2Constants.URI_WSDL2_EXTENSIONS,
+ WSDL2Constants.WSDL_EXTENTION_PREFIX);
+ }
+ if (nameSpacesMap != null && nameSpacesMap.containsValue(WSDL2Constants.URI_WSDL2_RPC)) {
+ wrpc = omFactory
+ .createOMNamespace(WSDL2Constants.URI_WSDL2_RPC,
+ WSDLSerializationUtil.getPrefix(
+ WSDL2Constants.URI_WSDL2_RPC, nameSpacesMap));
+ } else {
+ wrpc = descriptionElement.declareNamespace(WSDL2Constants.URI_WSDL2_RPC,
+ WSDL2Constants.WSDL_RPC_PREFIX);
+ }
+ return descriptionElement;
+ }
+
+ protected OMElement generateDocumentation(OMFactory omFactory) {
+ return WSDLSerializationUtil.generateDocumentationElement(axisService,
+ omFactory, wsdl);
+
+ }
+
+ protected OMElement generateTypes(OMFactory omFactory) throws AxisFault {
+ // Add types element
+ OMElement typesElement = omFactory.createOMElement(WSDL2Constants.TYPES_LOCAL_NALE, wsdl);
+ axisService.populateSchemaMappings();
+ ArrayList schemas = axisService.getSchema();
+ for (int i = 0; i < schemas.size(); i++) {
+ StringWriter writer = new StringWriter();
+ XmlSchema schema = axisService.getSchema(i);
+
+ if (!org.apache.axis2.namespace.Constants.URI_2001_SCHEMA_XSD
+ .equals(schema.getTargetNamespace())) {
+ schema.write(writer);
+ String schemaString = writer.toString();
+
+ if (!"".equals(schemaString)) {
+ try {
+ typesElement.addChild(
+ XMLUtils.toOM(new ByteArrayInputStream(schemaString.getBytes())));
+ } catch (XMLStreamException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+ }
+ }
+ return typesElement;
+ }
+
+ protected OMElement generateInterface(OMFactory omFactory) throws AxisFault, URISyntaxException, XMLStreamException, FactoryConfigurationError {
+ Parameter parameter = axisService.getParameter(WSDL2Constants.INTERFACE_LOCAL_NAME);
+
+ if (parameter != null) {
+ interfaceName = (String) parameter.getValue();
+ } else {
+ interfaceName = WSDL2Constants.DEFAULT_INTERFACE_NAME;
+ }
+
+ // Add the interface element
+ return getInterfaceElement(wsdl, tns, wsdlx, wrpc, omFactory,
+ interfaceName);
+ }
+
+ protected OMElement generateService(OMFactory omFactory, OMElement descriptionElement,
+ boolean disableREST, boolean disableSOAP12, boolean disableSOAP11) throws AxisFault {
+ // Check whether the axisService has any endpoints. If they exists serialize them else
+ // generate default endpoint elements.
+ OMElement serviceElement;
+ Set bindings = new HashSet();
+ Map endpointMap = axisService.getEndpoints();
+ Object value = axisService.getParameterValue("isCodegen");
+ boolean isCodegen = false;
+ if (JavaUtils.isTrueExplicitly(value)) {
+ isCodegen = true;
+ }
+ if (endpointMap != null && endpointMap.size() > 0) {
+
+ serviceElement = getServiceElement(wsdl, tns, omFactory, interfaceName);
+ Iterator iterator = endpointMap.values().iterator();
+ while (iterator.hasNext()) {
+ // With the new binding hierachy in place we need to do some extra checking here.
+ // If a service has both http and https listners up we should show two separate eprs
+ // If the service was deployed with a WSDL and it had two endpoints for http and
+ // https then we have two endpoints populated so we should serialize them instead
+ // of updating the endpoints.
+ AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
+ /*
+ * Some transports might not be active at runtime.
+ */
+ if (!isCodegen && checkIfEndPointActive && !axisEndpoint.isActive()) {
+ continue;
+ }
+ AxisBinding axisBinding = axisEndpoint.getBinding();
+ String type = axisBinding.getType();
+
+ // If HTTP binding is disabled, do not add.
+ if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) {
+ if (isDisableREST()) {
+ continue;
+ }
+ }
+
+ // If SOAP 1.2 binding is disabled, do not add.
+ String propertySOAPVersion =
+ (String) axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
+ if (isDisableSOAP12()) {
+ continue;
+ }
+ }
+
+ if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(propertySOAPVersion)) {
+ if (isDisableSOAP11()) {
+ continue;
+ }
+ }
+
+
+
+ bindings.add(axisBinding);
+ OMElement endpointElement = axisEndpoint.toWSDL20(wsdl, tns, whttp);
+ boolean endpointAlreadyAdded = false;
+ Iterator endpointsAdded = serviceElement.getChildren();
+ while (endpointsAdded.hasNext()) {
+ OMElement endpoint = (OMElement) endpointsAdded.next();
+ // Checking whether a endpoint with the same binding and address exists.
+ if (endpoint.getAttribute(new QName(WSDL2Constants.BINDING_LOCAL_NAME))
+ .getAttributeValue().equals(endpointElement.getAttribute(
+ new QName(WSDL2Constants.BINDING_LOCAL_NAME)).getAttributeValue())
+ && endpoint
+ .getAttribute(new QName(WSDL2Constants.ATTRIBUTE_ADDRESS))
+ .getAttributeValue().equals(endpointElement.getAttribute(
+ new QName(WSDL2Constants.ATTRIBUTE_ADDRESS)).getAttributeValue())) {
+ endpointAlreadyAdded = true;
+ }
+
+ }
+ if (!endpointAlreadyAdded) {
+// addPolicyAsExtensibleElement(axisEndpoint, endpointElement);
+ Parameter modifyAddressParam = axisService
+ .getParameter("modifyUserWSDLPortAddress");
+ if (modifyAddressParam != null) {
+ if (Boolean.parseBoolean((String) modifyAddressParam
+ .getValue())) {
+ String endpointURL = axisEndpoint
+ .calculateEndpointURL();
+ endpointElement
+ .getAttribute(
+ new QName(
+ WSDL2Constants.ATTRIBUTE_ADDRESS))
+ .setAttributeValue(endpointURL);
+ }
+ }
+ serviceElement.addChild(modifyEndpoint(endpointElement));
+ }
+ }
+ Iterator iter = bindings.iterator();
+ while (iter.hasNext()) {
+ AxisBinding binding = (AxisBinding) iter.next();
+ OMElement bindingElement = binding.toWSDL20(wsdl, tns, wsoap, whttp,
+ interfaceName,
+ axisService.getNamespaceMap(),
+ AddressingHelper.getAddressingRequirementParemeterValue(axisService),
+ serviceName,wsaw);
+ descriptionElement
+ .addChild(modifyBinding(bindingElement));
+ }
+
+ descriptionElement.addChild(serviceElement);
+ } else {
+
+ // There are no andpoints defined hence generate default bindings and endpoints
+ descriptionElement.addChild(
+ WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
+ tns, serviceName));
+ if (!isDisableSOAP12()) {
+ descriptionElement.addChild(modifyBinding(
+ WSDLSerializationUtil.generateSOAP12Binding(omFactory, axisService, wsdl, wsoap,
+ tns, serviceName)));
+ }
+ if (!isDisableSOAP11()) {
+ descriptionElement.addChild(modifyBinding(
+ WSDLSerializationUtil.generateSOAP11Binding(omFactory, axisService, wsdl, wsoap,
+ tns, serviceName)));
+ }
+ if (!isDisableREST()) {
+ descriptionElement.addChild(modifyBinding(
+ WSDLSerializationUtil.generateHTTPBinding(omFactory, axisService, wsdl,
+ whttp,
+ tns, serviceName)));
+ }
+
+ serviceElement = generateServiceElement(omFactory, wsdl, tns, axisService,
+ isDisableREST(), isDisableSOAP12(), isDisableSOAP11(), eprs, serviceName);
+ descriptionElement.addChild(serviceElement);
+ }
+ return serviceElement;
+
+ }
+
+ 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 List getPoliciesInDefinitions() {
+ return new ArrayList(policiesInDescription.values());
+ }
+
+ protected OMElement modifyEndpoint(OMElement endpoint) {
+ return endpoint;
+ }
+
+ protected OMElement modifyBinding(OMElement binding) {
+ return binding;
+ }
+
+ /**
+ * Generates a default service element
+ * @param omFactory - The OMFactory
+ * @param wsdl the WSDL namespace
+ * @param tns - The targetnamespace
+ * @param axisService - The AxisService
+ * @param disableREST only generate REST endpoint if this is false
+ * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
+ * @return - The generated service element
+ * @throws AxisFault - Thrown in case an exception occurs
+ */
+ public OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
+ OMNamespace tns, AxisService axisService,
+ boolean disableREST, boolean disableSOAP12, boolean disableSOAP11,
+ String serviceName)
+ throws AxisFault {
+ return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, disableSOAP12,disableSOAP11,
+ null, serviceName);
+ }
+
+ /**
+ * Generates a default service element
+ * @param omFactory - The OMFactory
+ * @param wsdl the WSDL namespace
+ * @param tns - The targetnamespace
+ * @param axisService - The AxisService
+ * @param disableREST only generate REST endpoint if this is false
+ * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
+ * @return - The generated service element
+ * @throws AxisFault - Thrown in case an exception occurs
+ */
+ public OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
+ OMNamespace tns, AxisService axisService,
+ boolean disableREST, boolean disableSOAP12, boolean disableSOAP11,
+ String[] eprs, String serviceName)
+ throws AxisFault {
+ if(eprs == null){
+ eprs = axisService.getEPRs();
+ if (eprs == null) {
+ eprs = new String[]{serviceName};
+ }
+ }
+ OMElement serviceElement;
+ serviceElement = omFactory.createOMElement(WSDL2Constants.SERVICE_LOCAL_NAME, wsdl);
+ serviceElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME,
+ null, serviceName));
+ serviceElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.INTERFACE_LOCAL_NAME, null,
+ tns.getPrefix() + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
+ for (int i = 0; i < eprs.length; i++) {
+ String name = "";
+ String epr = eprs[i];
+ if (epr.startsWith("https://")) {
+ name = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
+ }
+
+ OMElement soap11EndpointElement =
+ null;
+ if (!disableSOAP11) {
+ soap11EndpointElement = omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+ soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.ATTRIBUTE_NAME, null,
+ name + WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME));
+ soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.BINDING_LOCAL_NAME, null,
+ tns.getPrefix() + ":" + serviceName +
+ Java2WSDLConstants.BINDING_NAME_SUFFIX));
+ soap11EndpointElement.addAttribute(
+ omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
+ serviceElement.addChild(modifyEndpoint(soap11EndpointElement));
+ }
+
+ OMElement soap12EndpointElement = null;
+ if (!disableSOAP12) {
+ soap12EndpointElement =
+ omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+ soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.ATTRIBUTE_NAME, null,
+ name + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
+ soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.BINDING_LOCAL_NAME, null,
+ tns.getPrefix() + ":" + serviceName +
+ Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
+ soap12EndpointElement.addAttribute(
+ omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
+ serviceElement.addChild(modifyEndpoint(soap12EndpointElement));
+ }
+
+ OMElement httpEndpointElement = null;
+ if (!disableREST) {
+ httpEndpointElement =
+ omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+ httpEndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.ATTRIBUTE_NAME, null,
+ name + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
+ httpEndpointElement.addAttribute(omFactory.createOMAttribute(
+ WSDL2Constants.BINDING_LOCAL_NAME, null,
+ tns.getPrefix() + ":" + serviceName + Java2WSDLConstants
+ .HTTP_BINDING));
+ httpEndpointElement.addAttribute(
+ omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
+ serviceElement.addChild(modifyEndpoint(httpEndpointElement));
+ }
+
+ if (epr.startsWith("https://")) {
+ if (!disableSOAP11) {
+ OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTPS");
+ soap11EndpointElement.addChild(soap11Documentation);
+ }
+ if (!disableSOAP12) {
+ OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTPS");
+ soap12EndpointElement.addChild(soap12Documentation);
+ }
+ if (!disableREST) {
+ OMElement httpDocumentation =
+ omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTPS");
+ httpEndpointElement.addChild(httpDocumentation);
+ }
+ } else if (epr.startsWith("http://")) {
+ if (!disableSOAP11) {
+ OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTP");
+ soap11EndpointElement.addChild(soap11Documentation);
+ }
+ if (!disableSOAP12) {
+ OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTP");
+ soap12EndpointElement.addChild(soap12Documentation);
+ }
+ if (!disableREST) {
+ OMElement httpDocumentation =
+ omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
+ httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTP");
+ httpEndpointElement.addChild(httpDocumentation);
+ }
+ }
+ }
+ return serviceElement;
+ }
+
+
}
\ No newline at end of file
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=1377218&r1=1377217&r2=1377218&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 Aug 25 05:33:51 2012
@@ -277,148 +277,7 @@ public class WSDLSerializationUtil {
}
}
- /**
- * Generates a default service element
- * @param omFactory - The OMFactory
- * @param wsdl the WSDL namespace
- * @param tns - The targetnamespace
- * @param axisService - The AxisService
- * @param disableREST only generate REST endpoint if this is false
- * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
- * @return - The generated service element
- * @throws AxisFault - Thrown in case an exception occurs
- */
- public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
- OMNamespace tns, AxisService axisService,
- boolean disableREST, boolean disableSOAP12, boolean disableSOAP11,
- String serviceName)
- throws AxisFault {
- return generateServiceElement(omFactory, wsdl, tns, axisService, disableREST, disableSOAP12,disableSOAP11,
- null, serviceName);
- }
-
- /**
- * Generates a default service element
- * @param omFactory - The OMFactory
- * @param wsdl the WSDL namespace
- * @param tns - The targetnamespace
- * @param axisService - The AxisService
- * @param disableREST only generate REST endpoint if this is false
- * @param disableSOAP12 only generate SOAP 1.2 endpoint if this is false
- * @return - The generated service element
- * @throws AxisFault - Thrown in case an exception occurs
- */
- public static OMElement generateServiceElement(OMFactory omFactory, OMNamespace wsdl,
- OMNamespace tns, AxisService axisService,
- boolean disableREST, boolean disableSOAP12, boolean disableSOAP11,
- String[] eprs, String serviceName)
- throws AxisFault {
- if(eprs == null){
- eprs = axisService.getEPRs();
- if (eprs == null) {
- eprs = new String[]{serviceName};
- }
- }
- OMElement serviceElement;
- serviceElement = omFactory.createOMElement(WSDL2Constants.SERVICE_LOCAL_NAME, wsdl);
- serviceElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME,
- null, serviceName));
- serviceElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.INTERFACE_LOCAL_NAME, null,
- tns.getPrefix() + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
- for (int i = 0; i < eprs.length; i++) {
- String name = "";
- String epr = eprs[i];
- if (epr.startsWith("https://")) {
- name = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
- }
- OMElement soap11EndpointElement =
- null;
- if (!disableSOAP11) {
- soap11EndpointElement = omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
- soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.ATTRIBUTE_NAME, null,
- name + WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME));
- soap11EndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.BINDING_LOCAL_NAME, null,
- tns.getPrefix() + ":" + serviceName +
- Java2WSDLConstants.BINDING_NAME_SUFFIX));
- soap11EndpointElement.addAttribute(
- omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
- serviceElement.addChild(soap11EndpointElement);
- }
-
- OMElement soap12EndpointElement = null;
- if (!disableSOAP12) {
- soap12EndpointElement =
- omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
- soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.ATTRIBUTE_NAME, null,
- name + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
- soap12EndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.BINDING_LOCAL_NAME, null,
- tns.getPrefix() + ":" + serviceName +
- Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
- soap12EndpointElement.addAttribute(
- omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
- serviceElement.addChild(soap12EndpointElement);
- }
-
- OMElement httpEndpointElement = null;
- if (!disableREST) {
- httpEndpointElement =
- omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
- httpEndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.ATTRIBUTE_NAME, null,
- name + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
- httpEndpointElement.addAttribute(omFactory.createOMAttribute(
- WSDL2Constants.BINDING_LOCAL_NAME, null,
- tns.getPrefix() + ":" + serviceName + Java2WSDLConstants
- .HTTP_BINDING));
- httpEndpointElement.addAttribute(
- omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS, null, epr));
- serviceElement.addChild(httpEndpointElement);
- }
-
- if (epr.startsWith("https://")) {
- if (!disableSOAP11) {
- OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTPS");
- soap11EndpointElement.addChild(soap11Documentation);
- }
- if (!disableSOAP12) {
- OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTPS");
- soap12EndpointElement.addChild(soap12Documentation);
- }
- if (!disableREST) {
- OMElement httpDocumentation =
- omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTPS");
- httpEndpointElement.addChild(httpDocumentation);
- }
- } else if (epr.startsWith("http://")) {
- if (!disableSOAP11) {
- OMElement soap11Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- soap11Documentation.setText("This endpoint exposes a SOAP 11 binding over a HTTP");
- soap11EndpointElement.addChild(soap11Documentation);
- }
- if (!disableSOAP12) {
- OMElement soap12Documentation = omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- soap12Documentation.setText("This endpoint exposes a SOAP 12 binding over a HTTP");
- soap12EndpointElement.addChild(soap12Documentation);
- }
- if (!disableREST) {
- OMElement httpDocumentation =
- omFactory.createOMElement(WSDL2Constants.DOCUMENTATION, wsdl);
- httpDocumentation.setText("This endpoint exposes a HTTP binding over a HTTP");
- httpEndpointElement.addChild(httpDocumentation);
- }
- }
- }
- return serviceElement;
- }
/**
* Adds the namespaces to the given OMElement
Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java?rev=1377218&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java Sat Aug 25 05:33:51 2012
@@ -0,0 +1,56 @@
+/*
+ * 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.WSDL20SupplierTemplate;
+
+class TestWSDL20SupplierTemplate extends WSDL20SupplierTemplate {
+
+
+ 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;
+ }
+
+
+ protected OMElement customizeEndpoint(OMElement ep) {
+ OMAttribute location = ep.getAttribute(new QName("address"));
+ String url = location.getAttributeValue();
+ url = url.replace("192.168.1.2", "localhost");
+ location.setAttributeValue(url);
+ return ep;
+ }
+
+}
\ No newline at end of file
Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/TestWSDL20SupplierTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=1377218&r1=1377217&r2=1377218&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDLSupplierTest.java Sat Aug 25 05:33:51 2012
@@ -28,7 +28,6 @@ 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;
@@ -139,4 +138,44 @@ public class WSDLSupplierTest extends Te
assertFalse(wsdl.contains("<documentation/>"));
}
+ public void testWSDL20SupplierTemplate() throws Exception {
+ TestWSDL20SupplierTemplate value = new TestWSDL20SupplierTemplate();
+ axisService.addParameter(Constants.WSDL_SUPPLIER_PARAM, value);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ axisService.printWSDL2(outputStream);
+ String wsdl = outputStream.toString();
+ assertTrue(wsdl.contains("<wsdl2:description"));
+ assertTrue(wsdl.contains("xmlns:wsdl2=\"http://www.w3.org/ns/wsdl\""));
+ assertTrue(wsdl.contains("xmlns:wsaw=\"http://www.w3.org/2006/05/addressing/wsd"));
+ assertTrue(wsdl.contains("xmlns:tns=\"http://ws.apache.org/axis2\""));
+ assertTrue(wsdl.contains("xmlns:wsoap=\"http://www.w3.org/ns/wsdl/soap\" "));
+ assertTrue(wsdl.contains("<wsdl2: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("</wsdl2:documentation>"));
+ assertFalse(wsdl.contains("<documentation/>"));
+ }
+
+ public void testWSDL11SupplierTemplateWSDL20SupplierClass() throws Exception {
+ String value = TestWSDL20SupplierTemplate.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("<wsdl2:description"));
+ assertTrue(wsdl.contains("xmlns:wsdl2=\"http://www.w3.org/ns/wsdl\""));
+ assertTrue(wsdl.contains("xmlns:wsaw=\"http://www.w3.org/2006/05/addressing/wsd"));
+ assertTrue(wsdl.contains("xmlns:tns=\"http://ws.apache.org/axis2\""));
+ assertTrue(wsdl.contains("xmlns:wsoap=\"http://www.w3.org/ns/wsdl/soap\" "));
+ assertTrue(wsdl.contains("<wsdl2: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("</wsdl2:documentation>"));
+ assertFalse(wsdl.contains("<documentation/>"));
+ }
+
}