Skip to content

Instantly share code, notes, and snippets.

@maxaf
Created March 3, 2011 06:29
Show Gist options
  • Save maxaf/852430 to your computer and use it in GitHub Desktop.
Save maxaf/852430 to your computer and use it in GitHub Desktop.
1. Dump contents of http://www.w3.org/2003/05/soap-envelope/ to soap12.xsd
and put that somewhere alongside the other schemas.
2. Run scalaxb, you'll end up with a soap12.scala & company.
3. See sample code. Call envXml and get back XML representation of envelope,
header, and body all in one.
def messageID = <wsaddr:MessageID>{ "messageID:%d".format((System.currentTimeMillis / 1000 - scala.util.Random.nextInt.abs).abs.intValue) }</wsaddr:MessageID>
def header = Header(Seq(DataRecord(<wsaddr:To>...</wsaddr:To>),
DataRecord(messageID),
DataRecord(<wsaddr:Action>...</wsaddr:Action>)), Map.empty)
def envelope = Envelope(Some(header), Body(Seq(DataRecord(bodyXml)), Map.empty), Map.empty)
def envXml = toXML[Envelope](envelope, Some("http://www.w3.org/2003/05/soap-envelope"), Some("Envelope"), defaultScope)
def bodyXml: NodeSeq = /* some way to return actual domain-specific XML that goes under <Body> */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment