【问题标题】:JAX-WS wsimport use local wsdl a xsd fileJAX-WS wsimport 使用本地 wsdl 一个 xsd 文件
【发布时间】:2013-05-27 08:53:49
【问题描述】:

我有一个带有 wsimport 生成源的肥皂客户端。
我在 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>

我正在寻找如何不每次都从远程服务器(http://example.com:8080/services/test?wsdl)对 wsdl/xsd 进行请求的最佳方法。 所以,我想使用本地 wsdl/xsd 文件。有可能吗?genra

【问题讨论】:

  • 在浏览器中查看xsd url并保存本地副本

标签: maven jax-ws wsimport


【解决方案1】:

有类似的问题。 wsimport 应该生成一个名为 your_ws_nameService.java 的 .java 文件。在此文件中,您应该有如下所示的部分:

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;
}

将此部分更改为如下内容:

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;
}

这将读取位于客户端内部的 WSDL 文件。当然你需要先把它放在那里,就像 kolossus 建议的那样,你可以从浏览器下载。

【讨论】:

    猜你喜欢
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多