使用Spring Boot构建SOAP Wer服务客户端

时间:2018-01-07 02:55:22

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

我是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

1 个答案:

答案 0 :(得分:0)

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

您粘贴的错误消息表示您的客户端存根类未成功生成。我在github repo中找不到本地任何WSDL文件副本,并且对WSDL文件的访问似乎也是404 error

所以你可能需要尝试一些其他的教程,比如CXF ones。它也很简单。