Question

I use jaxws-maven-plugin to produce java from wsdl. wsdl located in local network, but refers to some xsd in internet.

It becomes troubles in generation code with maven plugin, becouse it has lack of advanced http proxy settings.

Is there a workaround for this issue? My config is:

    <plugin>
        <groupId>org.jvnet.jax-ws-commons</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.2</version>
        <executions>
            <execution>
                <goals>
                    <goal>wsimport</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
         <!--<httpproxy>127.0.0.1:5865</httpproxy>-->
            <packageName>my.pkg</packageName>
            <verbose>true</verbose>
            <wsdlUrls>
                <wsdlUrl>
                    http://10.31.7.64:13080/service.wsdl
                </wsdlUrl>
            </wsdlUrls>
        </configuration>
    </plugin>

Without proxy I got

parsing WSDL...

[ERROR] IOException thrown when processing "http://www.w3.org/2005/05/xmlmime". Exception: java.net.ConnectException: Connection refused: connect.

With proxy I got

parsing WSDL...


[ERROR] Server returned HTTP response code: 504 for URL: http://10.31.7.64:13080/service.wsdl

May be it problem of proxy, but I don't have another proxy behind corporate network.

Was it helpful?

Solution 2

AFAIU, when we enable the httpproxy, all request will go to that proxy, including with the <wsdlUrl>.

The server returns

HTTP response code: 504 for URL: http://10.31.7.64:13080/service.wsdl 

The Status Code Definitions told us as the following: -

504 Gateway Timeout

The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.

The root cause may be the proxy does not known our address, in this case it is 10.31.7.64

IMHO please try to download the wsdl and put it to local machine. Then configured by using the wsdlFiles as the following example: -

 <configuration>
     <wsdlFiles>
         <wsdlFile>${basedir}/path/to/wsdl</wsdlFile>
     </wsdlFiles>
 </configuration>

I hope this may help.

OTHER TIPS

A better approach is to use the noProxy variable of the JVM. Then your build fails when the WSDL is not available (In my case very useful for integration tests) You can add this to the jaxws-maven-plugin configuration:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
    <execution>
        <id>wsdltoJava</id>
        <goals>
            <goal>wsimport</goal>
        </goals>
        <configuration>
            <wsdlUrls>
                <wsdlUrl>https://someService.yourcompany.net/Service/Service?wsdl</wsdlUrl>
            </wsdlUrls>
            <vmArgs>
                <vmArg>-Dhttp.nonProxyHosts=*.yourcompany.net, 10.31.7.64</vmArg>
            </vmArgs>
            <keep>true</keep>
            <packageName>com.yourcompany.package</packageName>
            <sourceDestDir>your/target/directory</sourceDestDir>
        </configuration>
    </execution>
</executions>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top