XML テンプレート:
@(product: models.Product, productComponents: List[models.ProductComponent])
<product>
<name>@product.name</name>
<tomcatLocation>@product.tomcatLocation</tomcatLocation>
<productComponents>
@for(productComponent <- productComponents) {
<component>
<name>@productComponent.name</name>
<packageName>@productComponent.packageName</packageName>
<buildPath>@productComponent.buildPath</buildPath>
<packageFormat>@productComponent.packageFormat</packageFormat>
<versionAction>@productComponent.versionAction</versionAction>
<versionFilePath>@productComponent.versionFilePath</versionFilePath>
<versionCommand>@productComponent.versionCommand</versionCommand>
</component>
}
</productComponents>
</product>
コントローラーのアクション:
public static Result upgradeProduct(String serverId, String productId) throws InterruptedException
{
models.Server server = models.Server.retrieveById(Long.parseLong(serverId));
models.Product product = models.Product.retrieveById(Long.parseLong(productId));
List<models.ProductComponent> productComponents =
models.ProductComponent.retrieveByProductId(Long.parseLong(productId));
Xml renderedXmlPage = upgradeService.render(product, productComponents);
Promise<WS.Response> upgradeStatus =
WS.url("http://" + server.hostIp + ":8085/upgradeProduct").setHeader("Content-Type", "text/xml").post(
renderedXmlPage.toString());
String testMessage = upgradeStatus.get().getBody();
return TODO;
}
ウェブサービス:
public static Result upgradeProduct()
{
return async( WS.url(MAIN_URL).get().map(
new Function<WS.Response, Result>() {
public Result apply(WS.Response response)
{
try
{
Document doc = response.asXml();
return ok("I WORKED");
}
catch(RuntimeException e)
{
return ok("Error" + e.getMessage()+ "\n");
}
}
})
);
}
このアクションを実行すると、次のランタイム例外がスローされます
「Errorjava.lang.RuntimeException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; ファイルの終わりが早すぎます。」.
この例外は、「Document doc = response.asXml();」でスローされています。なぜこれが起こっているのかわかりませんか?どんな助けでも大歓迎ですありがとう!
Stack Trace:
play.libs.WS$Response.asXml(WS.java:332)
controllers.Service$1.apply(Service.java:40)
controllers.Service$1.apply(Service.java:35)
play.libs.F$Promise$2.apply(F.java:111)
play.api.libs.concurrent.STMPromise$$anonfun$map$1$$anonfun$apply$9.apply(Promise.scala:185)
scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:110)
scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:110)
scala.util.control.Exception$Catch.apply(Exception.scala:88)
scala.util.control.Exception$Catch.either(Exception.scala:110)
play.api.libs.concurrent.STMPromise.redeem(Promise.scala:166)
play.api.libs.concurrent.STMPromise$$anonfun$map$1.apply(Promise.scala:185)
play.api.libs.concurrent.STMPromise$$anonfun$map$1.apply(Promise.scala:184)
play.api.libs.concurrent.STMPromise$PromiseInvoker$$anonfun$receive$1.apply(Promise.scala:10 4)
play.api.libs.concurrent.STMPromise$PromiseInvoker$$anonfun$receive$1.apply(Promise.scala:10 3)
akka.actor.Actor$class.apply(Actor.scala:290)
play.api.libs.concurrent.STMPromise$PromiseInvoker.apply(Promise.scala:101)
akka.actor.ActorCell.invoke(ActorCell.scala:617)
akka.dispatch.Mailbox.processMailbox(Mailbox.scala:179)
akka.dispatch.Mailbox.run(Mailbox.scala:161)
akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:505)
akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:997)
akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1495)
akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)