为什么WSDL客户端在Windows上不起作用

问题描述 投票:0回答:1

我有一个正在从事的WSDL项目。在我从Linux升级到windows之前,该项目在Java 8openJDK 11上都运行良好。在Linux上它仍然可以正常工作,问题出在Windows上。我什至无法获得WSDL螺柱进行初始化,就好像程序到达要初始化并调用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中运行该程序时,将进行初始化。我该如何解决?

java wsdl webservice-client
1个回答
0
投票

事实证明我缺少一些依赖项。在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>
© www.soinside.com 2019 - 2024. All rights reserved.