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