You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Asen <as...@gmail.com> on 2012/05/10 18:34:30 UTC

Axis2-1.6.2 generated stubs fails to use module rampart

Hi there,

I am trying to use wsdl2ejava Axis-1.6.2 generated stubs and including
Rampart-1.6.2 for the WS-Sec.
I have copied in to my application all the required Axis/Rampart jars,
modules and created the required directory structure when building it.
All my web services and generated code clients are deployed, visible
and ready to go.

But here is what I am experiencing when I try to invoke a client stub
and make him engage 'rampart' module to pass the WCF exposed service
with UsernameToken security.
"Unable to engage module : rampart"

Hmm, looked at the code and this seems to make sense even though all
axis2 and rampart modules are deployed during startup form the
WarBasedAxisConfigurator.
When the stub's service client is configured a null
ConfigurationContext is used as in previous versions but here the
check for if (MessageContext.getCurrentMessageContext() == null)
always
is true and new ConfigurationContext is created from file system which
uses the default axis2.xml and since a repository location is not
specified it seems that fails to find the deployed modules in
WEB-INF/modules
In other words I am receiving a AxisConfiguration without any modules.

What I am doing wrong here?
I had not have the issue with Axis-1.5 since there it was using a
Listener instead of MessageContext.getCurrentMessageContext()

My axis2.xml is the same as it comes from the distribution, but with
added two more globally engaged modules.

<module ref="addressing"/>
    <module ref="soapmonitor" />
    <module ref="rampart"/>

private void configureServiceClient(ConfigurationContext
configContext, AxisService axisService)
            throws AxisFault {
        if (configContext == null) {
            if (MessageContext.getCurrentMessageContext() == null) {
                configContext = ConfigurationContextFactory.
                        createConfigurationContextFromFileSystem(null, null);
                createConfigCtx = true;
            } else {
                configContext =
MessageContext.getCurrentMessageContext().getConfigurationContext();
            }
        }
        this.configContext = configContext;
        hashCode = (int)anonServiceCounter.incrementAndGet();

        // Initialize transports
        ListenerManager transportManager = configContext.getListenerManager();
        if (transportManager == null) {
            transportManager = new ListenerManager();
            transportManager.init(this.configContext);
        }

        // save the axisConfig and service
        axisConfig = configContext.getAxisConfiguration();

        if (axisService == null) {
            axisService = createAnonymousService();
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Axis2-1.6.2 generated stubs fails to use module rampart

Posted by Asen <as...@gmail.com>.
Solved:

1. I have set two system properties from my startup servlet.

System.setProperty(org.apache.axis2.Constants.AXIS2_CONF,
config.getServletContext().getRealPath("/WEB-INF/conf/axis2.xml"));
System.setProperty(org.apache.axis2.Constants.AXIS2_REPO,
config.getServletContext().getRealPath("/WEB-INF"));

2. added  <module ref="rampart"/> to axis2.xml and added the rampart
modules to the WEB-INF/modues dir of Tomcat.

3. I have created the configuration context only ones and have reused
it when creating a new client

MyStub stub = new MyStub(MyConfigFactory.getConfigCtx());

Is that sounds like the right way of doing it?




On Fri, May 18, 2012 at 1:53 PM, Kishanthan Thangarajah
<ks...@gmail.com> wrote:
>
>
> On Thu, May 10, 2012 at 10:04 PM, Asen <as...@gmail.com> wrote:
>>
>> Hi there,
>>
>> I am trying to use wsdl2ejava Axis-1.6.2 generated stubs and including
>> Rampart-1.6.2 for the WS-Sec.
>> I have copied in to my application all the required Axis/Rampart jars,
>> modules and created the required directory structure when building it.
>> All my web services and generated code clients are deployed, visible
>> and ready to go.
>>
>> But here is what I am experiencing when I try to invoke a client stub
>> and make him engage 'rampart' module to pass the WCF exposed service
>> with UsernameToken security.
>> "Unable to engage module : rampart"
>>
>> Hmm, looked at the code and this seems to make sense even though all
>> axis2 and rampart modules are deployed during startup form the
>> WarBasedAxisConfigurator.
>> When the stub's service client is configured a null
>> ConfigurationContext is used as in previous versions but here the
>> check for if (MessageContext.getCurrentMessageContext() == null)
>> always
>> is true and new ConfigurationContext is created from file system which
>> uses the default axis2.xml and since a repository location is not
>> specified it seems that fails to find the deployed modules in
>> WEB-INF/modules
>> In other words I am receiving a AxisConfiguration without any modules.
>>
>> What I am doing wrong here?
>
>
> Can you give us some more info on how you configured rampart on client
> side?. Some code section from your client would be better. Just to be
> sure, check whether rampart and other third party libraries are in the
> client class path. Also when creating the ConfigurationContext from file
> system using a repository, please make sure that you have given the correct
> location and also the rampart module (rampart.mar) is placed under modules
> directory.
>
> Thanks,
> Kishanthan.
>>
>> I had not have the issue with Axis-1.5 since there it was using a
>> Listener instead of MessageContext.getCurrentMessageContext()
>>
>> My axis2.xml is the same as it comes from the distribution, but with
>> added two more globally engaged modules.
>>
>> <module ref="addressing"/>
>>    <module ref="soapmonitor" />
>>    <module ref="rampart"/>
>>
>> private void configureServiceClient(ConfigurationContext
>> configContext, AxisService axisService)
>>            throws AxisFault {
>>        if (configContext == null) {
>>            if (MessageContext.getCurrentMessageContext() == null) {
>>                configContext = ConfigurationContextFactory.
>>                        createConfigurationContextFromFileSystem(null,
>> null);
>>                createConfigCtx = true;
>>            } else {
>>                configContext =
>> MessageContext.getCurrentMessageContext().getConfigurationContext();
>>            }
>>        }
>>        this.configContext = configContext;
>>        hashCode = (int)anonServiceCounter.incrementAndGet();
>>
>>        // Initialize transports
>>        ListenerManager transportManager =
>> configContext.getListenerManager();
>>        if (transportManager == null) {
>>            transportManager = new ListenerManager();
>>            transportManager.init(this.configContext);
>>        }
>>
>>        // save the axisConfig and service
>>        axisConfig = configContext.getAxisConfiguration();
>>
>>        if (axisService == null) {
>>            axisService = createAnonymousService();
>>        }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: java-user-help@axis.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Axis2-1.6.2 generated stubs fails to use module rampart

Posted by Kishanthan Thangarajah <ks...@gmail.com>.
On Thu, May 10, 2012 at 10:04 PM, Asen <as...@gmail.com> wrote:

> Hi there,
>
> I am trying to use wsdl2ejava Axis-1.6.2 generated stubs and including
> Rampart-1.6.2 for the WS-Sec.
> I have copied in to my application all the required Axis/Rampart jars,
> modules and created the required directory structure when building it.
> All my web services and generated code clients are deployed, visible
> and ready to go.
>
> But here is what I am experiencing when I try to invoke a client stub
> and make him engage 'rampart' module to pass the WCF exposed service
> with UsernameToken security.
> "Unable to engage module : rampart"
>
> Hmm, looked at the code and this seems to make sense even though all
> axis2 and rampart modules are deployed during startup form the
> WarBasedAxisConfigurator.
> When the stub's service client is configured a null
> ConfigurationContext is used as in previous versions but here the
> check for if (MessageContext.getCurrentMessageContext() == null)
> always
> is true and new ConfigurationContext is created from file system which
> uses the default axis2.xml and since a repository location is not
> specified it seems that fails to find the deployed modules in
> WEB-INF/modules
> In other words I am receiving a AxisConfiguration without any modules.
>
> What I am doing wrong here?
>

Can you give us some more info on how you configured rampart on client
side?. Some code section from your client would be better. Just to be
sure, check whether rampart and other third party libraries are in the
client class path. Also when creating the ConfigurationContext from file
system using a repository, please make sure that you have given the correct
location and also the rampart module (rampart.mar) is placed under modules
directory.

Thanks,
Kishanthan.

> I had not have the issue with Axis-1.5 since there it was using a
> Listener instead of MessageContext.getCurrentMessageContext()
>
> My axis2.xml is the same as it comes from the distribution, but with
> added two more globally engaged modules.
>
> <module ref="addressing"/>
>    <module ref="soapmonitor" />
>    <module ref="rampart"/>
>
> private void configureServiceClient(ConfigurationContext
> configContext, AxisService axisService)
>            throws AxisFault {
>        if (configContext == null) {
>            if (MessageContext.getCurrentMessageContext() == null) {
>                configContext = ConfigurationContextFactory.
>                        createConfigurationContextFromFileSystem(null,
> null);
>                createConfigCtx = true;
>            } else {
>                configContext =
> MessageContext.getCurrentMessageContext().getConfigurationContext();
>            }
>        }
>        this.configContext = configContext;
>        hashCode = (int)anonServiceCounter.incrementAndGet();
>
>        // Initialize transports
>        ListenerManager transportManager =
> configContext.getListenerManager();
>        if (transportManager == null) {
>            transportManager = new ListenerManager();
>            transportManager.init(this.configContext);
>        }
>
>        // save the axisConfig and service
>        axisConfig = configContext.getAxisConfiguration();
>
>        if (axisService == null) {
>            axisService = createAnonymousService();
>        }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>