How to avoid hardcoded URLs in generating Axis code?

The project that I support uses the axis-maven-plugin module to generate the source code. This source code is used to invoke the PDF generator service.

However, the service URL is hardcoded in the generated Java code.

public class GenerateReportServServiceLocator
             extends org.apache.axis.client.Service
             implements com.company.GenerateReportServService
{
    // ... 

    // Use to get a proxy class for GenerateReportServ
    private java.lang.String GenerateReportServ_address =
    /* Hardcoded URL */   "http://host:port/PdfEngine/GenerateReportServ.jws";

   // ...
}

How can I specify the axis-maven plugin to use our property configuration file to search for URLs?

Here is the pom file:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.4</version>
    <configuration>
        <urls>
           <url>http://host:port/PdfEngine/GenerateReportServ.jws</url>
        </urls>
        <packageSpace>com.company.project.core.pdf.engine</packageSpace>
        <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
    </configuration>
    <dependencies> 
      // ...
    </dependencies>
    <executions>
        <execution>
            <id>generate-ws-service-impression</id>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
+4
source share
1 answer

I did not find any option from Axis to avoid this problem. As a result, I decided to rewrite the code that Axis had previously created.

A chance for me, I only needed to write a few classes. My code is now environment independent.

0
source

Source: https://habr.com/ru/post/1547569/


All Articles