API Manager错误创建SOAP API :(双网关)

时间:2018-03-29 13:33:24

标签: wso2 wso2-am

我们正在使用带有分布式部署的API Manager 2.1.0(双网关)。 当我们使用soap端点创建SOAP API时,我们会收到错误。 以下是我们在API创建者Web界面中遵循的步骤:

  1. 创建一个新的“我有SOAP端点”
  2. 在Design API中,我们添加了所需的所有信息并保存
  3. 保存时,导入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)
    

    并且导入的WSDL(在注册表中)在wsdl:port中的位置为null。 如果我们只使用一个网关并导入相同的WSDL,我们就没有错误,一切顺利。 该问题与WSDL无关,它与所有WSDL一起发生。 我们怎么解决呢?

1 个答案:

答案 0 :(得分:0)

我们已经解决了问题。这些是我们通过此链接(https://wso2.org/jira/browse/APIMANAGER-5843)和(https://github.com/wso2/carbon-apimgt/pull/4301/commits/c9d38bd0864bc84b3d8f5731ccc6a49068448f33)使用的步骤:

  1. 下载API Carbon Mgt版本的源代码并找到APIUtil.java(org.wso2.carbon.apimgt.impl / src / main / java / org / wso2 / carbon / apimgt / impl / utils / APIUtil .java)
  2. 找到方法getGatewayendpoint(String transports)并将其替换为以下代码行:

        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. 找到org.wso2.carbon.apimgt.impl_6.1.66并将该类替换为新的APIUtil.java

  4. 根据WSO2文档添加此补丁

现在您可以在多网关上发布