0
votes

We are using API Manager 2.1.0 with a distributed deployment (double gateways). When we create a SOAP API using a soap endpoint, we get an error. These are the steps we followed in the API creator web interface:

  1. Create a new API 'I Have SOAP endpoint'
  2. In the Design API we add all the information required and save

When saving, we have an error when importing the WSDL:

ERROR {org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader} -  Error occurred while getting the wsdl address location {org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader}
java.net.MalformedURLException: no protocol: null/testphone/1.0
    at java.net.URL.<init>(URL.java:593)
    at java.net.URL.<init>(URL.java:490)
    at java.net.URL.<init>(URL.java:439)
    at org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader.setServiceDefinition(APIMWSDLReader.java:307)
    at org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader.updateWSDL(APIMWSDLReader.java:156)
    at org.wso2.carbon.apimgt.impl.utils.APIUtil.createWSDL(APIUtil.java:1375)
    at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateWsdl(APIProviderImpl.java:731)
    at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateAPI(APIProviderImpl.java:836)
    at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.manageAPI(UserAwareAPIProvider.java:72)
    at org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.saveAPI(APIProviderHostObject.java:1061)
    at org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.jsFunction_updateAPIImplementation(APIProviderHostObject.java:672)
    at sun.reflect.GeneratedMethodAccessor392.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)

and the WSDL imported (in the registry) has a null in the location in wsdl:port. If we use only one gateway and import the same WSDL we do not have the error and everything works smoothly. The problem is not related to the WSDL and it happens with all WSDL. How can we solve it?

1
This is a bug and it is fixed in latest APIM 2.2.0.Anuruddha Lanka Liyanarachchi

1 Answers

0
votes

We have solved the problem. These are the steps we used following this link (https://wso2.org/jira/browse/APIMANAGER-5843) and (https://github.com/wso2/carbon-apimgt/pull/4301/commits/c9d38bd0864bc84b3d8f5731ccc6a49068448f33):

  1. Download the source code of the version of your API Carbon Mgt and locate APIUtil.java (org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java)
  2. Find the method getGatewayendpoint(String transports) and replace it with this code lines:

        public static String getGatewayendpoint(String transports) {
                String gatewayURLs;
    
                Map<String, Environment> gatewayEnvironments = ServiceReferenceHolder.getInstance()
                        .getAPIManagerConfigurationService()
                        .getAPIManagerConfiguration()
                        .getApiGatewayEnvironments();
                if (gatewayEnvironments.size() > 1) {
                 for (Environment environment : gatewayEnvironments.values()) {
                        if (APIConstants.GATEWAY_ENV_TYPE_HYBRID.equals(environment.getType())) {
                            gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
                            // pick correct endpoint
                            return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
                        }
                    }
                    for (Environment environment : gatewayEnvironments.values()) {
                        if (APIConstants.GATEWAY_ENV_TYPE_PRODUCTION.equals(environment.getType())) {
                            gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
                         // pick correct endpoint
                            return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
                        }
                    }
                    for (Environment environment : gatewayEnvironments.values()) {
                        if (APIConstants.GATEWAY_ENV_TYPE_SANDBOX.equals(environment.getType())) {
                            gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
                            // pick correct endpoint
                            return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
                        }
                    }
                } else {
                    gatewayURLs = ((Environment) gatewayEnvironments.values().toArray()[0]).getApiGatewayEndpoint();
                    return extractHTTPSEndpoint(gatewayURLs, transports);
                }
    
                return null;
            }
    
  3. Locate org.wso2.carbon.apimgt.impl_6.1.66 and replace the class with the new APIUtil.java

  4. Add this patch according to WSO2 documentation

Now you can publish on mutliple gateway