dubbo-2.5.4-SNAPSHOT,使用Servlet Bridge Server并指定 contextpath 时,发布的webservice,url路径错误, dubbo无法访问问题处理。
问题原因:
com.alibaba.dubbo.rpc.protocol.webservice.WebServiceProtocol.doExport 方法中,
final ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
serverFactoryBean.setAddress(url.getAbsolutePath());
其中url.getAbsolutePath() 包含了 contextpath 。
修改方法:
1,修改ServiceConfig.java , 在454行之前增加:
if(contextPath!=null&&contextPath.length()>0){
map.put("contextpath", contextPath);
}
2,修改com.alibaba.dubbo.rpc.protocol.webservice.WebServiceProtocol.doExport方法:
final ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
serverFactoryBean.setAddress(url.getAbsolutePath());
修改为:
String contextpath = url.getParameter("contextpath");
String address = url.getAbsolutePath();
if (contextpath != null && contextpath.length() > 0) {
address = address.substring(contextpath.length() + 1);
}
final ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
serverFactoryBean.setAddress(address);