Axisurltemplate拦截器报错。
创始人
2024-09-29 07:00:26
0

可能的原因是在配置拦截器时出现了错误,需要仔细检查配置是否正确。如果确认配置无误,可以尝试使用以下代码:

public class AxisUrlTemplateInterceptor extends AbstractPhaseInterceptor {

    public AxisUrlTemplateInterceptor() {
        super(Phase.PRE_PROTOCOL);
    }

    @Override
    public void handleMessage(Message message) throws Fault {
        try {
            AddressingProperties inProps = ContextUtils.retrieveMAPs(message, false, true);
            if (inProps != null && inProps.getAction() != null) {
                String action = inProps.getAction().getValue();
                EndpointReferenceType to = inProps.getTo();
                if (to != null && to.getAddress() != null) {
                    String toAddress = to.getAddress().getValue();
                    String wsdlURL = null; // set your WSDL url here
                    String portName = null; // set your port name here
                    String endPointName = null; // set your endpoint name here
                    String contextPath = null; // set your context path here

                    String urlTemplate = wsdlURL + "#" + portName + "#" + endPointName + "#" + action;
                    urlTemplate = URLDecoder.decode(urlTemplate, "UTF-8");

                    String fullURL = urlTemplate.replaceAll("\\{contextPath\\}", contextPath);

                    String[] pathSegments = fullURL.split("/");
                    String last = pathSegments[pathSegments.length - 1];

                    if (!last.contains("?")) {
                        fullURL += "?";
                    } else if (!last.endsWith("&")) {
                        fullURL += "&";
                    }

                    fullURL += URL_PARAM_CONTEXT_PATH + "=" + contextPath;

                    Map> parameterMap = new HashMap>();
                    Map readyMap = new HashMap();

                    this.getWsdl11Reader().readWsdl(wsdlURL).collectEndpointParamters(portName, readyMap, parameterMap);

                    Map paramtersFromAddress = getParamtersFromAddress(toAddress);
                    Iterator>> itr = parameterMap.entrySet().iterator();
                    while (itr.hasNext()) {
                        Entry> nxt = itr.next();
                        String key = nxt.getKey();
                        String value = null;
                        if (paramtersFromAddress.containsKey(key)) {
                            value = paramtersFromAddress.remove(key);
                        } else {
                            List vals = nxt.getValue();
                            if (vals.size() == 1) {
                                value = vals.iterator().next();
                            }
                        }

                        if (value != null) {
                            fullURL += "&" + key + "=" + value;
                        }
                    }

                    itr = paramtersFromAddress.entrySet().iterator();
                    while (itr.hasNext()) {
                        Entry nxt = itr.next();
                        String key = nxt.getKey();
                        String value = nxt.getValue();
                        fullURL += "&" + key + "=" + value;
                    }

                    int idx = fullURL.indexOf("}");
                    if (idx != -1 && fullURL.indexOf("{") == -1) {
                        fullURL = fullURL.substring(0, idx) + fullURL.substring(idx + 1);
                    }

                    fullURL = fullURL.replaceAll("&", "&");
                    message.put(Message.ENDPOINT_ADDRESS, fullURL);
                }
            }
        } catch (Exception e) {
            throw new Fault(e);
        }
    }

    private Map getParamtersFromAddress(String toAddress) {
        Map parameterMap = new HashMap();
        StringBuffer buf = new StringBuffer(toAddress);
        int idx = buf.indexOf("?");
        if (idx != -1) {
            String params = to

相关内容

热门资讯

【NI Multisim 14...   目录 序言 一、工具栏 🍊1.“标准”工具栏 🍊 2.视图工具...
银河麒麟V10SP1高级服务器... 银河麒麟高级服务器操作系统简介: 银河麒麟高级服务器操作系统V10是针对企业级关键业务...
不能访问光猫的的管理页面 光猫是现代家庭宽带网络的重要组成部分,它可以提供高速稳定的网络连接。但是,有时候我们会遇到不能访问光...
AWSECS:访问外部网络时出... 如果您在AWS ECS中部署了应用程序,并且该应用程序需要访问外部网络,但是无法正常访问,可能是因为...
Android|无法访问或保存... 这个问题可能是由于权限设置不正确导致的。您需要在应用程序清单文件中添加以下代码来请求适当的权限:此外...
北信源内网安全管理卸载 北信源内网安全管理是一款网络安全管理软件,主要用于保护内网安全。在日常使用过程中,卸载该软件是一种常...
AWSElasticBeans... 在Dockerfile中手动配置nginx反向代理。例如,在Dockerfile中添加以下代码:FR...
AsusVivobook无法开... 首先,我们可以尝试重置BIOS(Basic Input/Output System)来解决这个问题。...
ASM贪吃蛇游戏-解决错误的问... 要解决ASM贪吃蛇游戏中的错误问题,你可以按照以下步骤进行:首先,确定错误的具体表现和问题所在。在贪...
月入8000+的steam搬砖... 大家好,我是阿阳 今天要给大家介绍的是 steam 游戏搬砖项目,目前...