【问题标题】:Building SOAP Wer Service Client using Spring Boot使用 Spring Boot 构建 SOAP Wer 服务客户端
【发布时间】:2018-01-07 02:55:22
【问题描述】:

我是 Spring Boot 新手,不熟悉 SOAP Web 服务的工作原理。

我正在尝试使用 Spring Boot 使用 SOAP Web 服务。我正在关注官网给出的参考:https://spring.io/guides/gs/consuming-web-service/

我的代码与参考中给出的代码完全相同。当我尝试使用mvn clean install 运行代码时,会引发以下编译错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project springboot-demo: Compilation fail
ure: Compilation failure:
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[9,17] error: package hello.wsdl does not exist
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[10,17] error: package hello.wsdl does not exist
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[16,11] error: cannot find symbol
[ERROR]   symbol:   class GetQuoteResponse
[ERROR]   location: class QuoteClient
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\Application.java:[3,17] error: package hello.wsdl does not exist
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[18,8] error: cannot find symbol
[ERROR]   symbol:   class GetQuote
[ERROR]   location: class QuoteClient
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[18,31] error: cannot find symbol
[ERROR]   symbol:   class GetQuote
[ERROR]   location: class QuoteClient
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[23,8] error: cannot find symbol
[ERROR]   symbol:   class GetQuoteResponse
[ERROR]   location: class QuoteClient
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\QuoteClient.java:[23,37] error: cannot find symbol
[ERROR]   symbol:   class GetQuoteResponse
[ERROR]   location: class QuoteClient
[ERROR] C:\Users\Archit\IdeaProjects\springboot-demo\src\main\java\hello\Application.java:[25,12] error: cannot find symbol
[ERROR] -> [Help 1]

我正在运行的代码位于:https://github.com/spring-guides/gs-consuming-web-service/tree/master/complete

【问题讨论】:

    标签: web-services spring-boot soap soap-client


    【解决方案1】:

    契约驱动的 SOAP Web 服务开发是您需要获取 WSDL 文件并生成 Java 域类和存根(通过 jaxb 实用程序),然后您可以开发客户端与服务器对话。

    您粘贴的错误消息意味着您的客户端存根类没有成功生成。我在该 github 存储库中本地找不到任何 WSDL 文件副本,并且对 WSDL 文件的访问似乎也转到 404 error

    因此,您可能需要尝试其他一些教程,例如 CXF ones。它也非常简单。

    【讨论】:

    • 谢谢@chenrui!我正在使用 wsdl 尝试上面的代码:dneonline.com/calculator.asmx?WSDL(It 不给出 404)。当我执行“wsimport dneonline.com/calculator.asmx?WSDL”时,这将为定义服务方法的所有类生成类文件。我知道我们可以使用 'keep' 选项来生成源文件,但我只想要我的仓库中的类文件。如果我只想包含“.class”文件,您知道在这种情况下如何在客户端中使用服务方法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-21
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 2021-05-07
    相关资源
    最近更新 更多