简体   繁体   English

Apache Axis:如何使用从wsdl2java生成的代码设置调用属性?

[英]Apache Axis: How to set call properties using code generated from wsdl2java?

I'm using Apache Axis 1.4 (yes, the old one), with wsdl2java to generate the client code for a webservice. 我正在使用带有wsdl2java的Apache Axis 1.4(是的,是旧版本)来生成Web服务的客户端代码。 I'd like to set additional properties on the Call object before calling methods on the generated stub. 在调用生成的存根上的方法之前,我想在Call对象上设置其他属性。

For example, I'd like to set username, password, perhaps add or modify existing headers, and change the client handlers to use different implementations. 例如,我想设置用户名,密码,或者添加或修改现有的标头,并更改客户端处理程序以使用不同的实现。

Currently, I'm doing this by modifying the generated Stub class and calling the appropriate setters. 当前,我正在通过修改生成的Stub类并调用适当的setter来做到这一点。 However, I'd like to achieve this without touching the generated files. 但是,我想在不触摸生成的文件的情况下实现这一目标。 I"m confused, though, because the Stub class has: 不过,我感到困惑,因为Stub类具有:

createCall()

which creates the call object and sets some properties. 这将创建调用对象并设置一些属性。 Currently, this is where I'm modifying the generated source code; 当前,这是我正在修改生成的源代码的地方。 then, the Stub contains: 然后,存根包含:

clientMethod1(){
    blahblah
    Call _call = createCall();
    ......
    _call.invoke();
}

So I can't see a way that I can use the serviceLocator to get a stub, modify the properties I want to modify, and then use the stub to call the methods I want to call, given that the stub methods call createCall() and then call invoke. 因此,我看不到可以使用serviceLocator获取存根,修改要修改的属性,然后使用存根调用要调用的方法的方法,因为存根方法调用createCall()然后调用invoke。 There doesn't appear to be a way to intercept the new Call object before it's invoked. 在调用新的Call对象之前,似乎没有办法拦截它。

So: How do you modify properties in the call without modifying the generated Stub class's source code? 因此:如何在不修改生成的Stub类的源代码的情况下修改调用中的属性?

Thanks for info or even pointers to existing documentation. 感谢您提供信息或什至指向现有文档的指针。

I wouldn't like to touch the generated code too. 我也不想触摸生成的代码。 The risk is that I once have to regenerate it and loose my edits. 这样做的风险是,我曾经不得不重新生成它并失去我的编辑。

Without knowing axis details - isn't it possible to subclass the Stub and override 'createCall'? 在不知道轴详细信息的情况下-不能继承Stub并重写'createCall'吗? Axis won't touch this subclass and you could set your properties in the overridden createCall method Axis不会触摸此子类,您可以在覆盖的createCall方法中设置属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM