API 管理器创建 SOAP 时出错 API:(双网关)
API Manager error creating SOAP API: (Double Gateway)
我们正在使用具有分布式部署(双网关)的 API Manager 2.1.0。
当我们使用 soap 端点创建 SOAP API 时,出现错误。
这些是我们在 API 创建者网络界面中遵循的步骤:
- 新建 API 'I Have SOAP endpoint'
- 在设计中 API 我们添加所有需要的信息并保存
保存时,我们在导入 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 中的位置有一个空值。
如果我们只使用一个网关并导入相同的 WSDL,我们就不会出现错误,一切都会顺利进行。
该问题与 WSDL 无关,所有 WSDL 都会发生。
我们该如何解决?
我们已经解决了这个问题。这些是我们在 link (https://wso2.org/jira/browse/APIMANAGER-5843) and (https://github.com/wso2/carbon-apimgt/pull/4301/commits/c9d38bd0864bc84b3d8f5731ccc6a49068448f33):
之后使用的步骤
- 下载您的 API Carbon Mgt 版本的源代码并找到 APIUtil.java (org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java)
找到方法 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;
}
找到 org.wso2.carbon.apimgt.impl_6.1.66 并将 class 替换为新的 APIUtil.java
- 根据WSO2文档添加这个补丁
现在您可以在多个网关上发布
我们正在使用具有分布式部署(双网关)的 API Manager 2.1.0。 当我们使用 soap 端点创建 SOAP API 时,出现错误。 这些是我们在 API 创建者网络界面中遵循的步骤:
- 新建 API 'I Have SOAP endpoint'
- 在设计中 API 我们添加所有需要的信息并保存
保存时,我们在导入 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 中的位置有一个空值。 如果我们只使用一个网关并导入相同的 WSDL,我们就不会出现错误,一切都会顺利进行。 该问题与 WSDL 无关,所有 WSDL 都会发生。 我们该如何解决?
我们已经解决了这个问题。这些是我们在 link (https://wso2.org/jira/browse/APIMANAGER-5843) and (https://github.com/wso2/carbon-apimgt/pull/4301/commits/c9d38bd0864bc84b3d8f5731ccc6a49068448f33):
之后使用的步骤- 下载您的 API Carbon Mgt 版本的源代码并找到 APIUtil.java (org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java)
找到方法 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; }
找到 org.wso2.carbon.apimgt.impl_6.1.66 并将 class 替换为新的 APIUtil.java
- 根据WSO2文档添加这个补丁
现在您可以在多个网关上发布