【问题标题】:Empty SOAPAction Apache cxf空 SOAPAction Apache cxf
【发布时间】:2015-06-24 17:15:27
【问题描述】:

我正在使用 apache cxf 创建一个肥皂客户端。我使用网络挂钩捕获数据并在 Http 标头 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 标头中将所有方法放入其中

SOAPAction : "myPrefix:mySoapMethod,myPrefix:mySoapMethod2"

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

【问题讨论】:

    标签: java cxf jax-ws soap-client cxf-client


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      • 2019-03-19
      相关资源
      最近更新 更多