Play Framework 2.5.1中的SOAP Web服务客户端 [英] SOAP webservice client in Play Framework 2.5.1

查看:223
本文介绍了Play Framework 2.5.1中的SOAP Web服务客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Play Webservice API开发SOAP Webservice客户端,但是我不知道该怎么做.我找到了链接: https://www.playframework.com/documentation/2.5.x/JavaWS 但是我没有看到任何示例代码,如何使用WSClient来使用SOAP Web服务. 任何建议,不胜感激,谢谢.

I'm trying to develop SOAP webservice client using Play Webservice API, but I cant figure out how to do this. I found link: https://www.playframework.com/documentation/2.5.x/JavaWS But i don't see any example code, how to use WSClient to consume SOAP webservice. Any advice greatly appreciated, thanks.

推荐答案

基本上有2种通过Play使用SOAP Web服务的方式(为了完整性,我添加了2种方式)

There are basically 2 ways to consume SOAP web services with Play (I have added 2 just for the sake of completeness)

  1. 使用Play WS模块(如您所试)-当您要使用XML时,您可以调用:
  1. Using the Play WS module (as you have tried) - as you are going to be working with XML, you can just call:


CompletionStage<Document> documentPromise = ws.url(url).get().thenApply(WSResponse::asXml);

当然,在获得XML文档之后,您可以按照所需的任何方式进行操作-例如,使用 XPath 或其他一些XML解析机制:

Of course after you get the XML Document you can manipulate it in any way you want - for example with XPath or some other XML parsing mechanism:

String value = XPath.selectText("//value", yourXmlDocument);
Node node = XPath.selectNode("//node", yourXmlDocument);


  1. 使用(您自己的)SOAP库-您可以在build.sbt文件中将库作为依赖项提供,也可以将其放在Play项目的类路径中,然后使用它. 还可以看看 scalaxb (( http://scalaxb.org/sbt-scalaxb)
  1. Using (a / you own) SOAP library - you can provide your library as a dependency in the build.sbt file or you can just put it in the classpath of the Play project and then use it. Also take a look at scalaxb (http://scalaxb.org/sbt-scalaxb)

这篇关于Play Framework 2.5.1中的SOAP Web服务客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆