Last active
August 29, 2015 14:11
-
-
Save benwaffle/ac73e649ee945656ae0a to your computer and use it in GitHub Desktop.
complex wsdl types to scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml.XML | |
object Main extends App { | |
def getType(w: String) = w dropWhile ( _ != ':' ) drop(1) capitalize | |
val xml = XML.loadFile("Sample.wsdl") | |
val types = (xml \ "types" \ "schema" \ "complexType") | |
types map { complextype => | |
println("case class %s(".format(complextype.attribute("name").get)) | |
println((complextype \ "sequence" \ "element") map { elem => | |
" val %s: %s = None". | |
format (elem.attribute("name").get, | |
getType(elem.attribute("type").getOrElse("xs:any").toString)) | |
} mkString ",\n") | |
println(" )") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class login( | |
val username: String = None, | |
val password: String = None, | |
val userType: Int = None | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<wsdl:definitions> | |
<wsdl:types> | |
<xs:schema> | |
<xs:complexType name="login"> | |
<xs:sequence> | |
<xs:element minOccurs="0" name="username" nillable="true" type="xs:string"/> | |
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/> | |
<xs:element minOccurs="0" name="userType" type="xs:int"/> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:schema> | |
</wsdl:types> | |
</wsdl:definitions> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment