【发布时间】:2016-06-08 12:11:13
【问题描述】:
我使用 Axis2 RPCServiceClient 来调用 Web 服务。并且对服务的所有调用都必须包含 3 个参数:UserName、Password 和 reqID。 reqID 是我自己生成的 GUID 参数。
需要reqID放入header中。
当我使用soapUI 测试服务时,通过Http Analyzer,我可以发现reqID 包含在带有SOAPAction、Content-type、User-Agent 和Authorization 的请求标头中。
如何将reqID添加到header中?
`RPCServiceClient client = new RPCServiceClient();
Options option = client.getOptions();
option.setAction("http://localhost:8080/api/Getbooks");
EndpointReference erf = new EndpointReference(serviceAddress);
option.setTo(erf);
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername("test");
auth.setPassword("test");
auth.setPreemptiveAuthentication(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);'
[![this is request headers][1]][1]
【问题讨论】:
标签: web-services soap header axis2