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辅助器怎么用(透视)hhpoker必备开挂-切实真的有挂(哔哩哔哩)一、aa...
透视了解!aapoker ai... 透视了解!aapoker ai插件(透视)德州hhpoker是真的吗-好像真的有挂(哔哩哔哩)1、超...
目前来看!wpk俱乐部怎么透视... 目前来看!wpk俱乐部怎么透视(透视)wpk模拟器多开-果然真的是有挂(哔哩哔哩)1、wpk俱乐部怎...
透视数据!德扑圈有透视吗(透视... 透视数据!德扑圈有透视吗(透视)德普之星透视辅助-都是是真的挂(哔哩哔哩)1、玩家可以在德普之星透视...
代打辅助挂!we poker辅... 代打辅助挂!we poker辅助器(透视)wepoker有辅助功能吗-总是真的有挂(哔哩哔哩)1、下...
据统计!hhpoker真能买到... 据统计!hhpoker真能买到挂吗(透视)hhpoker辅助软件下载-总是有挂(哔哩哔哩)1、hhp...
2026版总结!wepoker... 2026版总结!wepoker免费辅助器(透视)wepoker有机器人吗-一贯是真的挂(哔哩哔哩)1...
有了最新消息!德普之星有透视辅... 有了最新消息!德普之星有透视辅助吗(透视)如何下载德普之星辅助软件-果然存在有挂(哔哩哔哩)1、完成...
据通报!智星德州插件怎么下载(... 据通报!智星德州插件怎么下载(透视)智星菠萝可以辅助吗-好像有挂(哔哩哔哩)1、首先打开智星德州插件...
现场直击!德普之星辅助工具如何... 现场直击!德普之星辅助工具如何设置(透视)德扑之心免费透视-都是真的是有挂(哔哩哔哩)1、在德普之星...