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

相关内容

热门资讯

教程攻略!aapoker怎么设... 教程攻略!aapoker怎么设置提高好牌几率,wepoker有机器人吗,可靠教程(有挂技巧)关于aa...
一分钟揭秘!pokermast... 一分钟揭秘!pokermaster脚本,大菠萝免费辅助器,AI教程(有挂教程);玩家必备必赢加哟《1...
科技揭秘!aapoker透视脚... 1、科技揭秘!aapoker透视脚本入口,pokerrrr2辅助,系统教程(有挂技巧);详细教程。2...
热点讨论!pokemmo脚本辅... 热点讨论!pokemmo脚本辅助下载,hhpoker怎么开透视,透牌教程(有挂方法);人气非常高,a...
专业讨论!wepoker破解是... 1、专业讨论!wepoker破解是真的还是假的,hhpoker破解工具,安装教程(有挂透明)。2、w...
一分钟教你!pokemmo手机... 一分钟教你!pokemmo手机辅助软件,hhpoker有没有辅助,2025新版技巧(有挂教程)1、很...
科技分享!uupoker有透视... 科技分享!uupoker有透视吗,wepoker模拟器哪个,安装教程(有挂透视);《WPK辅助透视》...
推荐一款!德普之星辅助工具如何... 推荐一款!德普之星辅助工具如何打开,pokemmo脚本最新版,2025版教程(有挂透明)是一款可以让...
我来教大家!wepoker怎么... 《我来教大家!wepoker怎么发冤家牌,wepoker私局代打,第三方教程(有挂辅助)》 wepo...
分享一款!购买wepoker模... 分享一款!购买wepoker模拟器,aapoker怎么选牌,wpk教程(有挂技巧);1.购买wepo...