首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Scalaxb生成代码时出错

使用Scalaxb生成代码时出错
EN

Stack Overflow用户
提问于 2015-11-11 14:14:47
回答 1查看 922关注 0票数 1

为了其中一个实现,我不得不篡改WSDL文档,我遇到了Scalaxb!我现在正试图从我所拥有的WSDL文件中生成一些scala类,正如我所预期的那样,我遇到了一些问题:

下面是WSDL文件的一个片段:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:tns="http://www.myservice.com/MyServices/2012/06/18/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:s="http://www.w3.org/2001/XMLSchema"
 name="MyServices"
 targetNamespace="http://www.myservice.com/MyServices/2012/06/18/">
<wsdl:types>
 <s:schema elementFormDefault="qualified" targetNamespace="http://www.myservice.com/MyServices/2012/06/18/">
  <s:complexType name="UserCredentials">
   <s:sequence>
    <s:element name="UserName" type="s:string" />
    <s:element name="Password" type="s:string" />
   </s:sequence>
  </s:complexType>
  <s:element name="UserCredentials" type="tns:UserCredentials" />
  <s:complexType name="AnotherComplexType" >
   <s:sequence>
    <s:element name="Index" type="s:int" />
    <s:element name="Name" type="s:string" />
    <s:element name="Status" type="s:boolean" />
   </s:sequence>
  </s:complexType>
  ....

假设WSDL文件的其余部分完全没有问题,当我试图编译项目时,我遇到了以下错误:

代码语言:javascript
复制
[error] /Users/joe/Desktop/scalaxb-soap-example/target/scala-2.11/src_managed/main/sbt-scalaxb/myservice/xmlprotocol.scala:1542: not found: value userCredentials
[error]             scalaxb.toXML(userCredentials, Some("http://www.myservice.com/MyServices/2012/06/18/"), "UserCredentials", defaultScope), defaultScope, baseAddress, "POST", Some(new java.net.URI("http://1.1.1.1/cgi-bin/cgi.cgi?WebService=SetGPTimerChannel"))).transform({ case (header, body) => 
[error]                           ^
[error] /Users/joe/Desktop/scalaxb-soap-example/target/scala-2.11/src_managed/main/sbt-scalaxb/myservice/xmlprotocol.scala:1544: value toSeq is not a member of Any
[error]               scala.xml.Elem(null, "Body", scala.xml.Null, defaultScope, true, body.toSeq: _*)
[error]                                                                                     ^
[error] /Users/joe/Desktop/scalaxb-soap-example/target/scala-2.11/src_managed/main/sbt-scalaxb/myservice/xmlprotocol.scala:1551: not found: value userCredentials
[error]             scalaxb.toXML(userCredentials, Some("http://www.myservice.com/MyServices/2012/06/18/"), "UserCredentials", defaultScope), defaultScope, baseAddress, "POST", Some(new java.net.URI("http://1.1.1.1/cgi-bin/cgi.cgi?WebService=SomeServiceCall"))).transform({ case (header, body) => 
[error]                           ^
[error] /Users/joe/Desktop/scalaxb-soap-example/target/scala-2.11/src_managed/main/sbt-scalaxb/myservice/xmlprotocol.scala:1553: value toSeq is not a member of Any
[error]               scala.xml.Elem(null, "Body", scala.xml.Null, defaultScope, true, body.toSeq: _*)
[error]                                                                                     ^

知道我为什么要面对这个问题吗?这是我的build.sbt:

代码语言:javascript
复制
import ScalaxbKeys._

val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.2"
val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1"
val dispatchV = "0.11.1" // change this to appropriate dispatch version
val dispatch = "net.databinder.dispatch" %% "dispatch-core" % dispatchV

organization := "com.eon"

name := "scalaxb-myservice-sample"

scalaVersion := "2.11.6"

scalaxbSettings

packageName in (Compile, scalaxb) := "rdmservice"

dispatchVersion in (Compile, scalaxb) := dispatchV

async in (Compile, scalaxb) := true

sourceGenerators in Compile <+= scalaxb in Compile

libraryDependencies ++= Seq(scalaXml, scalaParser, dispatch)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-10 20:03:09

如果您只需要生成WSDL代码,那么使用scalaxb可能有点过了。作为一种选择,您可以将wsimport包装为一个简单的SBT任务,在主代码编译之前执行。除了一个更少的依赖之外,它还保持了存储库的原始状态,并使其免于提交生成的样板Java代码。如果有人感兴趣,这里有一个示例模板项目:https://github.com/sainnr/sbt-scala-wsdl-template

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33652411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档