本文整理汇总了Scala中javax.xml.transform.stream.StreamResult类的典型用法代码示例。如果您正苦于以下问题:Scala StreamResult类的具体用法?Scala StreamResult怎么用?Scala StreamResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StreamResult类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ExportModel
//设置package包名称以及导入依赖的类
package com.cloudera.datascience.cdsw.acme
import java.nio.charset.StandardCharsets
import java.nio.file.StandardOpenOption._
import java.nio.file.{Files, Paths}
import javax.xml.transform.stream.StreamResult
import org.dmg.pmml.Application
import org.jpmml.model.JAXBUtil
import org.jpmml.sparkml.ConverterUtil
import acme.ACMEModel
object ExportModel {
def main(args: Array[String]): Unit = {
val training = ACMEData.readData()
val pipeline = ACMEModel.buildModel()
val pmml = ConverterUtil.toPMML(training.schema, pipeline)
pmml.getHeader.setApplication(new Application("ACME Occupancy Detection"))
val modelPath = Paths.get("src", "main", "resources")
if (!Files.exists(modelPath)) {
Files.createDirectory(modelPath)
}
val pmmlFile = modelPath.resolve("model.pmml")
val writer = Files.newBufferedWriter(pmmlFile, StandardCharsets.UTF_8, WRITE, CREATE, TRUNCATE_EXISTING)
try {
JAXBUtil.marshalPMML(pmml, new StreamResult(writer))
} finally {
writer.close()
}
}
}
示例2: WWSClient
//设置package包名称以及导入依赖的类
package com.springml.spark.workday.ws
import java.io.{StringReader, StringWriter}
import javax.xml.transform.stream.{StreamResult, StreamSource}
import com.springml.spark.workday.model.WWSInput
import org.apache.log4j.Logger
import org.springframework.ws.client.core.WebServiceTemplate
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory
class WWSClient(
val wwsInput : WWSInput
) {
@transient val logger = Logger.getLogger(classOf[WWSClient])
private val webServiceTemplate = createWebServiceTemplate;
def execute() : String = {
logger.debug("Request : " + wwsInput.request)
val source = new StreamSource(new StringReader(wwsInput.request))
val writer = new StringWriter
val streamResult = new StreamResult(writer)
webServiceTemplate.sendSourceAndReceiveToResult(source, usernameTokenHandler, streamResult)
val response = writer.toString
logger.debug("Response : " + response)
return response
}
private def createWebServiceTemplate : WebServiceTemplate = {
val wsTemplate = new WebServiceTemplate(new AxiomSoapMessageFactory)
wsTemplate.setDefaultUri(wwsInput.wssEndpoint)
wsTemplate
}
private def usernameTokenHandler : UsernameTokenHandler = {
new UsernameTokenHandler(wwsInput.username, wwsInput.password)
}
}