1

I have a simple Axis2 client. I using Spring as light container. My question is: Is there an integration between axis2 client and spring? I past familiar with org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean class in Spring but don'y know it worked with axis2 or not.

Sam
  • 6,770
  • 7
  • 50
  • 91

1 Answers1

0

this link can give you a general idea Of what you need to do

At first you need to generate stub code from axis2 endpoint. Using maven and axis2 maven plugging is like this:

<plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>

                <version>${axis.version}</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>wsdl2code</goal>
                        </goals>
                        <configuration>
                            <wsdlFile>{axis2wsdl-url} or src/main/resources/wsdl/{downloaded wsdl file}</wsdlFile>
                            <packageName>com.cybersource.stub</packageName>
                            <databindingName>xmlbeans</databindingName>

                        </configuration>
                    </execution>
                </executions>               
            </plugin>

Next you need to install the generated jar files into maven repository. Before you do anything you need to go to the place the stub code is generated and run "ant" it will generate required jar files and you need to install them into your repo.

If you are using Spring Boot add these two beans:

@Bean
    public ConfigurationContext getConfigurationContext() throws AxisFault {
        ConfigurationContext ctx = ConfigurationContextFactory
                .createConfigurationContextFromFileSystem(config.getAxisConfigLocation(), null);
        return ctx;
    }

    @Bean
    public Policy getOMElement() throws FileNotFoundException {
        String policyLocation = config.getAxisConfigLocation() + "/conf/policy.xml";
        InputStream in = new FileInputStream(policyLocation);
        OMXMLParserWrapper omxmlParserWrapper = OMXMLBuilderFactory.createOMBuilder(in);
        Policy policy = PolicyEngine.getPolicy(omxmlParserWrapper.getDocumentElement());
        return policy;
    }

You should set config.getAxisConfigLocation() to somewhere you copied Axis config files like this:

enter image description here

in the above schema axis2.xml is important to generate axis2 context. policy.xml and rampart-xxx.mar files are for authentication which you need to know how your server deal with it.

In your connector section you need to inject ctx and/or policy beans and generate stub like this:

@Autowired
    ConfigurationContext ctx;

    @Autowired
    Policy policy;

private TransactionProcessorStub generateStub() throws AxisFault {
        TransactionProcessorStub stub = new TransactionProcessorStub(ctx, config.getServerurl());
        ServiceClient client = stub._getServiceClient();
        Options clientOptions = client.getOptions();
        clientOptions.setProperty(WSHandlerConstants.USER, config.getMerchantid());

        clientOptions.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
        client.setOptions(clientOptions);
        client.engageModule("rampart");

        return stub;
    }
Mehdi
  • 746
  • 1
  • 10
  • 25