gpt4 book ai didi

java - 空 SOAPAction Apache cxf

转载 作者:太空宇宙 更新时间:2023-11-04 13:44:10 25 4
gpt4 key购买 nike

我正在使用apache cxf创建一个soap客户端。我使用网络钩子(Hook)捕获数据并在Http header 中找到SOAPAction为空

SOAPAction : ""

下面是代码

 URL wsdlurl=SOAPWebServiceTransport.class.getClassLoader().
getResource("my.wsdl");
OnlinePort service= new OnlinePortService(wsdlurl).getOnlinePortPort();
Client proxy = ClientProxy.getClient(service);

// Provides WS-Security
WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor();
wss4jOut.setProperty("action", "UsernameToken");
wss4jOut.setProperty("user", userName);
wss4jOut.setProperty("passwordType", "PasswordText");
wss4jOut.setProperty("password", password);
wss4jOut.setProperty(WSHandlerConstants.ADD_UT_ELEMENTS,
WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);
wss4jOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, ServerPasswordCallback.class.getName());


proxy.getEndpoint().getOutInterceptors().add(wss4jOut);
setConduitProperties((HTTPConduit) proxy.getConduit(),url);

在 setConduitProperties 中,我只是设置一些 http 属性。在调查这个问题时,我找到了解决方法

Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("SOAPAction", Arrays.asList("myPrefix:mySoapMethod"));
proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);

但问题是,如果我有多个方法,那么在 Http header 中会将所有方法放入

SOAPAction : "myPrefix:mySoapMethod,myPrefix:mySoapMethod2"

有没有更好的解决方案来处理这个问题?

最佳答案

我建议为每个请求设置 SOAPAction header 。否则,服务器无法判断您要调用哪个方法。

关于java - 空 SOAPAction Apache cxf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31032949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com