Configuring Two client-config.wsdd in single axis engine

I faced a unique problem. The application was already using axis’s default client-config.wsdd (which comes with axis.jar file)file which does not support digest authentication which is required for Mappoint web service. As discussed in this post solution was to change clientt-config.wsdd and change the entry “<transport name=”local” pivot=”java:org.apache.axis.transport.local.LocalSender”/>” to “<transport name=”local” pivot=”java:org.apache.axis.transport.http.CommonsHTTPSender”/>” . But crux of the problem was that some existing system component is already using basic authentication, so we could not change the common client-config.wsdd(As there was only one axis.jar in the application or say only one axis engine axis engine per  application present in the application). Only one solution was to keep two client-config.wsdd one for the basic authentication with ” <transport name=”local” pivot=”java:org.apache.axis.transport.local.LocalSender”/>” entry and another for mappoint web services with “<transport name=”local” pivot=”java:org.apache.axis.transport.http.CommonsHTTPSender”/>” entry and configure axis engine so that for mappoint webservice it usages CommonHTTPSender and for rest it usages LocalSender and configure axis such that when Map related weservices is called axis usages client-config-mapoint.wsdd and when normal operation is done it usages default client-xonfig.wsdd file.

Here are the steps:-

1. Create another client-config-mapoint.wsdd  with the following entry. And put this in classpath.  Here we took default client-config.wsdd change changed the local transport to CommonHTTPsender.

<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender" />
<transport name="https" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/>
<!--  <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>-->
<transport name="local" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/>
</deployment>

2.  Write a factory class com.test.MapConfigFactory , this class extends default EngineConfigurationFactoryDefault . What is does it to check for input parameter in newFactory(). If any parameter is passed that means its being called for Mappoint webservice client and in that case we set a variable mapParam which is used in MapConfigFactory constructor to return either client-config or client-config-mapoint.wsdd.

package com.test.mapping;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.configuration.EngineConfigurationFactoryDefault;
import org.apache.axis.configuration.FileProvider;

public class TestMapConfig extends EngineConfigurationFactoryDefault{
private Object param;
protected static final String MAPPOINT_CLIENT_CONFIG_FILE = "mappoint-client-config.wsdd";
public static org.apache.axis.EngineConfigurationFactory newFactory(Object param){
if(param==null){
return EngineConfigurationFactoryDefault.newFactory(param);
}
return new TestMapConfig(param);
}

protected TestMapConfig(Object param){
super();
this.param = param;
}

public EngineConfiguration getClientEngineConfig(){
if(this.param!=null){
return new FileProvider(MAPPOINT_CLIENT_CONFIG_FILE);
}else{
return new FileProvider(clientConfigFile);
}
}
}

3. Load the above TestMapconfig in the application.

AxisProperties.setProperty(EngineConfigurationFactory.SYSTEM_PROPERTY_NAME, "com.test.TestMapConfig");

4. Modify the code to get stub with the parameter.

EngineConfigurationFactory factory = EngineConfigurationFactoryFinder.newFactory(<any not null parameter>);
RenderServiceSoap renderService = new RenderServiceLocator(factory.getClientEngineConfig()).getRenderServiceSoap(new URL(<MapPoint URL>));

when we call newFactory() method with some not null parameter the above configured TestMapConfig returns client property from client-config-mappoint.wsdd and when we call it will no parameter then TestMapConfig returns client property from client-config.wsdd. So mappoint related code can use newFactory(<not null>) and normal code can use  newFactory().

Advertisements

One response to “Configuring Two client-config.wsdd in single axis engine

  1. love you. That has been really really helpful. I can’t thank you more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s