我在NetBeans中为SOAP Web服务创建了一组代理类。
我想在传出请求中添加HTTP标头。
Map<String, Object> requestHeaders = new HashMap<>();
requestHeaders.put("X-Header", header);
AccountManagementService service = new AccountManagementService();
AccountManagementServiceSoap soap = service.getAccountManagementServiceSoap();
GetMembershipSummaryResponse.GetMembershipSummaryResult membershipSummary = soap.getMembershipSummary("mikeb@foobar.com");
当您从服务获取单个端口时,我看到了一堆JAX-WS标头示例。有没有更简单的方法?我可以只将标题添加到服务或soap对象上的某个集合中吗?
答案 0 :(得分:0)
这不是一个完整的答案,所以我将在这里发布完整的答案:
AccountManagementService service = new AccountManagementService();
AccountManagementServiceSoap soap = service.getAccountManagementServiceSoap();
((BindingProvider)soap).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
Collections.singletonMap("X-Header",Collections.singletonList(header)));
GetMembershipSummaryResponse.GetMembershipSummaryResult membershipSummary = soap.getMembershipSummary("mikeb@foobar.com");