@Override
    public String rewrite(ProviderContext ctx, InputStream wsdlStream, ApiDefinitionType apiDefinitionType)
            throws IOException, StorageException, GatewayAuthenticationException, Exception {
        IStorage storage = ctx.getStorage();
        ApiVersionBean avb = ctx.getAvb();
        String orgId = avb.getApi().getOrganization().getId();
        String apiId = avb.getApi().getId();
        String apiVersion = avb.getVersion();

        Document document = readWsdlInputStream(wsdlStream);

        // Collection of all SOAP binding addresses
        List<Element> allSoapAddresses = new LinkedList<>();

        for (String soapNamespace : SOAP_NAMESPACES) {
            NodeList soapAddresses = document.getDocumentElement().getElementsByTagNameNS(soapNamespace, SOAP_ADDRESS);
            if (soapAddresses.getLength() > 0) {
                for (int j = 0; j < soapAddresses.getLength(); j++) {
                    allSoapAddresses.add((Element) soapAddresses.item(j));
                }
            }
        }

        // Find IDs of all GWs this ApiVersion is published onto.
        String firstGateway = avb.getGateways().stream()
                                      .map(ApiGatewayBean::getGatewayId)
                                      .findFirst()
                                      .orElse("");

        GatewayBean gateway = storage.getGateway(firstGateway);
        IGatewayLink link = ctx.getGatewayLinkFactory().create(gateway);

        // Go through the addresses we've found (if any) and update the 'location' attribute if needed.
        String endpoint = link.getApiEndpoint(orgId, apiId, apiVersion).getEndpoint();
        for (Element addressElem : allSoapAddresses) {
            String location = addressElem.getAttribute(LOCATION);
            if (!location.equals(endpoint)) {
                addressElem.setAttribute(LOCATION, endpoint);
            }
        }

        // Convert document back to string and update in storage.
        return xmlDocumentToString(document);
    }
Rewrite WSDL schema to point to managed Apiman gateway endpoint (adapted from old WsdlHelper).
<p>
Multiple endpoints are not supported for this schema type.

@see <a href="https://www.w3.org/TR/wsdl20/">WSDL</a>
@author eric.wittmann@redhat.com
@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/rest-impl/src/main/java/io/apiman/manager/api/schema/format/WsdlRewriter.java