【问题标题】:Java JAX-WS Web Service calls Axis2 client, how do I add custom http request header?Java JAX-WS Web Service 调用 Axis2 客户端,如何添加自定义 http 请求标头?
【发布时间】:2021-09-02 06:00:04
【问题描述】:

我正在使用 java 1.4 。 axis2 版本是 1.5.6 。我想要做的是将用户名和密码添加到 htt_request_header,同时将数据发送到使用 JAX-WS RI 2.2.9 开发的 Web 服务。

我想在 SOAP screenshot. 的 Headers 选项卡中添加两项

【问题讨论】:

    标签: java jax-ws axis2 custom-headers


    【解决方案1】:

    问题已解决。由于 wsdl 地址创建为 https,所以在 stub 文件中固定为 http,并使用以下方法添加 header。

    ServiceClient serviceClient = stub._getServiceClient(); 列出标头 = (List) serviceClient.getOptions().getProperty(HTTPConstants.HTTP_HEADERS);
    如果(标题 == null){
    标头 = 新的 ArrayList(); } headers.add(new Header("用户名", 用户名)); headers.add(new Header("密码", 密码)); serviceClient.getOptions().setProperty(HTTPConstants.HTTP_HEADERS, headers);

    【讨论】:

      猜你喜欢
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      • 2012-07-09
      • 2011-05-02
      • 1970-01-01
      • 2010-11-11
      • 2016-02-10
      • 2016-09-29
      相关资源
      最近更新 更多