Axis2 1.4客户端并发问题(重用Stub)

Tom*_*mCo 6 java concurrency spring axis2 web-services

我已经被分配了一项工作来调查并提出修复一个间歇性和(显然)不可复制的错误,导致Web服务调用失败并出现以下错误:

Message does not conform to configured policy [ TimestampPolicy(S) AuthenticationTokenPolicy(S) ]:  No Security Header found
Run Code Online (Sandbox Code Playgroud)

该应用程序是面向高流量网站的在线公众的基于Spring的后端.使用Axis2 1.4客户端访问Web服务.

我认为我已经设法将问题跟踪到可能的并发问题,但它似乎并没有完全依赖于负载,故障统计数据不支持它(有时候负载较低的天数比高负载天数更差)加载).

无论如何,Web服务的所有客户端代码都包含在带有@Repository注释的单个类中.需要访问此WebServiceClient类的更广泛的应用程序中的类使用@Resource注释在类作用域中声明它,并根据需要自动装入.

我看到的问题是,在WebServiceClient中,存根在类范围内声明如下:

private ValidationStub validationStub;
private CustInfoStub custInfoStub;
Run Code Online (Sandbox Code Playgroud)

并在调用Web服务时在方法范围中初始化

this.validationStub= new ValidationStub (this.url);
prepareStub(this.validationPort, username, password);
Run Code Online (Sandbox Code Playgroud)

其中prepareStub方法创建安全标头并将其添加如下:

stub._getServiceClient().addHeader(element);
Run Code Online (Sandbox Code Playgroud)

我想如果我将存根从类范围移动到方法范围,它将解决问题,如下所示:

ValidationStub validationStub = new ValidationStub(this.url);
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过类似的问题?我有点担心做出这种改变会对性能产生影响.