Axisurltemplate拦截器报错。
创始人
2024-09-29 07:00:14
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

相关内容

热门资讯

第三分钟了解!四川途游小程序辅... 第三分钟了解!四川途游小程序辅助破解版!真是是真的有辅助攻略(有挂解惑)-哔哩哔哩1.四川途游小程序...
第4分钟了解!牛财神插件!好像... 第4分钟了解!牛财神插件!好像存在有辅助脚本(有挂神器)-哔哩哔哩1、完成牛财神插件有辅助插件,帮助...
一分钟了解!悠闲川南游戏辅助!... 一分钟了解!悠闲川南游戏辅助!其实是真的有辅助工具(真的有挂)-哔哩哔哩1、一分钟了解!悠闲川南游戏...
第一分钟了解!微信小程序怎么挂... 第一分钟了解!微信小程序怎么挂脚本!果然一直都是有辅助app(有挂技巧)-哔哩哔哩1、微信小程序怎么...
第5分钟了解!开心游戏辅助器!... 第5分钟了解!开心游戏辅助器!竟然一直都是有辅助脚本(有挂方法)-哔哩哔哩开心游戏辅助器能透视中分为...
第六分钟了解!菠萝神器辅助工具... 第六分钟了解!菠萝神器辅助工具!总是是真的有辅助攻略(确实有挂)-哔哩哔哩1、超多福利:超高返利,海...
第6分钟了解!新天道大厅辅助!... 第6分钟了解!新天道大厅辅助!都是一直总是有辅助技巧(有挂技巧)-哔哩哔哩运新天道大厅辅助辅助工具,...
第1分钟了解!老夫子拼十辅助!... 第1分钟了解!老夫子拼十辅助!一直是有辅助神器(有挂技术)-哔哩哔哩老夫子拼十辅助破解侠是真的助透视...
第九分钟了解!三江互娱辅助!真... 第九分钟了解!三江互娱辅助!真是存在有辅助软件(有挂助手)-哔哩哔哩1、三江互娱辅助免费脚本咨询教程...
第6分钟了解!九天大厅挂价格!... 第6分钟了解!九天大厅挂价格!其实是有辅助方法(确实有挂)-哔哩哔哩1、九天大厅挂价格辅助器安装包、...