当前位置: 首页>>代码示例>>Scala>>正文


Scala StreamResult类代码示例

本文整理汇总了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()
    }
  }

} 
开发者ID:srowen,项目名称:cdsw-simple-serving,代码行数:37,代码来源:ExportModel.scala

示例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)
  }
} 
开发者ID:springml,项目名称:spark-workday,代码行数:44,代码来源:WWSClient.scala


注:本文中的javax.xml.transform.stream.StreamResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。