【问题标题】:why is WSDL client not working on Windows为什么 WSDL 客户端不能在 Windows 上运行
【发布时间】:2019-10-10 02:10:51
【问题描述】:

我有一个WSDL 一直在从事的项目。该项目在Linuxwindows 上运行良好,直到我从Java 8 升级到openJDK 11。在 Linux 上它仍然可以工作,问题出在 Windows 上。我什至无法初始化WSDL studs,就像程序一旦到达它应该初始化并调用WSDL studs 的部分就完全停止,下面是我的WSDL 定义

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.1-b01-. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.1-b01-. -->
    <definitions
            xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
            xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.asycuda.org"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
            targetNamespace="http://www.asycuda.org" name="MyWbService">
        <types>
            <xsd:schema>
                <xsd:import namespace="http://www.asycuda.org"
                            schemaLocation="http://ip:port/asyws/WsItem?xsd=1"/>
            </xsd:schema>
        </types>
        <message name="wsItemStore">
            <part name="parameters" element="tns:wsItemStore"/>
        </message>
        <message name="wsItemStoreResponse">
            <part name="parameters" element="tns:wsItemStoreResponse"/>
        </message>
        <portType name="WsItem">
            <operation name="wsItemStore">
                <input wsam:Action="urn:wsItemStore" message="tns:wsItemStore"/>
                <output wsam:Action="http://www.asycuda.org/WsItem/wsItemStoreResponse" message="tns:wsItemStoreResponse"/>
            </operation>
        </portType>
        <binding name="WsItemServicePortBinding" type="tns:WsItem">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
            <operation name="wsItemStore">
                <soap:operation soapAction="urn:wsItemStore"/>
                <input>
                    <soap:body use="literal"/>
                </input>
                <output>
                    <soap:body use="literal"/>
                </output>
            </operation>
        </binding>
        <service name="WsItemService">
            <port name="WsItemServicePort" binding="tns:WsItemServicePortBinding">
                <soap:address location="http://ip:port/asyws/WsItem"/>
            </port>
        </service>
    </definitions>

以及我如何从Java 访问它

try{
        logger.debug("Initialization started");
        org.asycuda.WsItemService service = new org.asycuda.WsItemService();
        org.asycuda.WsItem port = service.getWsItemServicePort();
        Authenticator.setDefault(new WSAuthenticator(username, password));
        logger.debug("Initialization complete");
       }catch(Exception e){
         logger.error(e);
     }

当我在 Windows 中运行此代码时,程序只会在 logger.debug("Initialization started") 消息处停止,另一方面,当我在 Linux 中运行它时,初始化会完成。我该如何解决这个问题?

【问题讨论】:

  • 您几乎肯定需要配置modules。 Java 9 为 Java 添加了模块化。所以要么配置模块,要么降级到 Java 8。

标签: java wsdl webservice-client


【解决方案1】:

原来我遗漏了一些依赖项。在Linux 上运行应用程序时,我在intellij 上运行它,但要在 Windows 上运行它,我会从我的 IDE 编译一个 jar。 IDE 在运行时注入了缺失的依赖项,这就是它在 Linux 上运行良好但在 Windows 上运行良好的原因。

我必须添加这些依赖项才能使其与Java 11 正常工作

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.1</version>
    <type>pom</type>
</dependency>

<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.3.1</version>
</dependency>

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.3.0</version>
    <type>pom</type>
</dependency>

【讨论】:

    猜你喜欢
    • 2013-12-04
    • 2015-04-07
    • 1970-01-01
    • 2023-03-18
    • 2011-08-02
    • 1970-01-01
    • 2012-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多