有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用私有的WSDL创建web服务客户端

我想使用eclipse在java中创建一个soap web服务客户端。如果wsdl是私有的,我该怎么做

我尝试过这里描述的方法:https://www.youtube.com/watch?v=11iGyrvBhzc

我尝试了另一个WSDL链接(https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl),它生成了文件。所以它起作用了

还没到代码部分。我的问题是,当我尝试使用我感兴趣的WSDL链接时,它不起作用,因为WSDL链接是私有的。只有我公司的人才能使用它。我怎么接通

预期结果是在我的eclipse explorer中有一组文件


共 (2) 个答案

  1. # 1 楼答案

    我也遇到了同样的问题,不得不做彻底的研究。 这是我在Oracle Doc找到的

    Imported WSDL Files

    When you want to use an external web service from within Workshop, you should first obtain the WSDL file for the service you want to use. For public web services, the WSDL file will typically be available on the web site of the organization that publishes the web service.

    For private web services, contact the organization that supports the web service to obtain the WSDL file.

    当我联系发布Web服务的组织时,他们给了我以下信息

    1. Web服务url
    2. Web服务规范,包括xml请求和响应格式,以及Web服务方法

    有了上述信息,我就能够成功地使用organization web服务

  2. # 2 楼答案

    通过maven插件,您可以生成指向本地目录的文件,如下所示:

    <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>mkdir</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>mkdir</executable>
                                <arguments>
                                    <argument>-pv</argument>
                                    <argument>target/generated-sources/wsimport</argument>
                                </arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>wsdl</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>java</executable>
    
                                <arguments>
                                    <argument>-classpath</argument>
                                    <classpath/>
                                    <argument>com.sun.tools.ws.WsImport</argument>
                                    <argument>-extension</argument>
                                    <argument>-Xnocompile</argument>
                                    <argument>-catalog</argument>
                                    <argument>/META-INF/jax-ws-catalog.xml</argument>
                                    <argument>-wsdllocation</argument>
                                    <argument>/META-INF/file.wsdl</argument>
                                    <argument>-s</argument>
                                    <argument>target/generated-sources/wsimport</argument>
                                    <argument>src/main/resources/META-INF/file.wsdl</argument>
                                </arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>