private void setServiceDefinitionForWSDL2(org.apache.woden.wsdl20.Description definition, API api)
      throws APIManagementException {
    org.apache.woden.wsdl20.Service[] serviceMap = definition.getServices();
    URL addressURI;
    try {
      for (org.apache.woden.wsdl20.Service svc : serviceMap) {
        Endpoint[] portMap = svc.getEndpoints();
        for (Endpoint endpoint : portMap) {
          EndpointElement element = endpoint.toElement();

          addressURI = endpoint.getAddress().toURL();
          if (addressURI == null) {
            break;
          } else {
            String endpointTransport =
                determineURLTransport(endpoint.getAddress().getScheme(), api.getTransports());
            setAddressUrl(
                element,
                new URI(
                    APIUtil.getGatewayendpoint(endpointTransport)
                        + api.getContext()
                        + "/"
                        + api.getId().getVersion()));
          }
        }
      }

    } catch (Exception e) {
      log.error("Error occured while getting the wsdl address location", e);
      throw new APIManagementException(e);
    }
  }
  /**
   * Get the addressURl from the Extensibility element
   *
   * @param exElement - {@link ExtensibilityElement}
   * @throws APIManagementException
   */
  private void setAddressUrl(ExtensibilityElement exElement, String transports, API api)
      throws APIManagementException {

    if (exElement instanceof SOAP12AddressImpl) {
      ((SOAP12AddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else if (exElement instanceof SOAPAddressImpl) {
      ((SOAPAddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else if (exElement instanceof HTTPAddressImpl) {
      ((HTTPAddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else {
      String msg = "Unsupported WSDL errors!";
      log.error(msg);
      throw new APIManagementException(msg);
    }
  }