SOAP webservice client in Play Framework 2.5.1

≯℡__Kan透↙ 提交于 2019-12-08 10:14:12

问题


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.


回答1:


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

  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);

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. 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)


来源:https://stackoverflow.com/questions/36519605/soap-webservice-client-in-play-framework-2-5-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!