Frage

i have soap client with generated sources with wsimport.
I use following settings in my pom.xml

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.10</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlFiles>
                            <wsdlFile>example.com_8080/services/test.wsdl</wsdlFile>
                        </wsdlFiles>
                        <wsdlLocation>http://example.com:8080/services/test?wsdl</wsdlLocation>
                        <staleFile>${project.build.directory}/jaxws/stale/test.stale</staleFile>
                    </configuration>
                    <id>wsimport-generate-test</id>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>javax.xml</groupId>
                    <artifactId>webservices-api</artifactId>
                    <version>1.4</version>
                </dependency>
            </dependencies>
            <configuration>
                <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                <xnocompile>true</xnocompile>
                <verbose>true</verbose>
                <extension>true</extension>
                <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
            </configuration>
        </plugin>

And i'm looking for the best way howto don't do request on wsdl/xsd from remote server(http://example.com:8080/services/test?wsdl) every time. So, i want to use local wsdl/xsd file. Is it possible to do it?genra

War es hilfreich?

Lösung

Had similar problem. wsimport should generate a .java file called your_ws_nameService.java. In this file you should have section that looks something like this:

static {
    URL url = null;
    try {
        URL baseUrl;
        baseUrl = com.oracle.xmlns.orawsv.ORAWSVService.class.getResource(".");
        url = new URL(baseUrl, "http://127.0.0.1:7101/test/test?WSDL");
    } catch (MalformedURLException e) {
        logger.warning("Failed to create URL for the wsdl Location: 'http://127.0.0.1:7101/test/test?WSDL', retrying as a local file");
        logger.warning(e.getMessage());
    }
    ORAWSVSERVICE_WSDL_LOCATION = url;
}

Change this section to something like this:

static {
    URL url = null;
    try {
        URL baseUrl;
        baseUrl = mypackage.my_ws_client.my_ws_clientService.class.getResource("my_ws.wsdl");
        url = new URL(baseUrl,"");
    } catch (MalformedURLException e) {
        logger.warning("Failed to create URL for the local wsdl file.");
        logger.warning(e.getMessage());
    }
    SENDINFOSERVICE_WSDL_LOCATION = url;
}

This will read the WSDL file that is located inside your client. Of course you need to first have it there, which, like kolossus suggested, you can just download from the browser.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top