Default Message Usage

This page is intended to be used as a reference. For more information regarding how abstract and runtime message components are used, please see the the user guide.

Definitions

To define runtime instances of the abstract message definitions defined here, using this provider, would require the following provider entries. Note this is an optional step. If a provider definition is undefined, one will be automatically generated by alakai (without any content.) Also, you can override a runtime definition which may be defined within deployment within which the abstract message is defined, i.e. by definining a provider within your application deployment (using the provider type of your choosing.)

<deployment xmlns="http://bluestemsoftware.org/specification/eoa/1.0/deployment">
  <providers>
    <eoa:message xmlns:eoa="http://bluestemsoftware.org/specification/eoa/ext/message/default/1.0" xmlns:tns="http://mycompany.com" name="tns:A">
      <payload xmlns="">
        <A xmlns="http://mycompany.com">
          <B>
            <C>
              <D>
                <E>10</E>
              </D>
            </C>
          </B>
        </A>
      </payload>
    </eoa:message>
    <eoa:message xmlns:eoa="http://bluestemsoftware.org/specification/eoa/ext/message/default/1.0" xmlns:tns="http://com.mycompany/eoa/1.0" name="tns:myMultipartMessage">
      <partA xmlns="">
        <A xmlns="http://mycompany.com">
          <B>
            <C>
              <D>
                <E>10</E>
              </D>
            </C>
          </B>
        </A>
      </partA>
      <partB xmlns="">
        <F xmlns="http://mycompany.com">
          <G>
            <H>
              <I>
                <J>20</J>
              </I>
            </H>
          </G>
        </F>
      </partB>
      <partC xmlns="">
        <K xmlns="http://mycompany.com">
          <L>
            <M>
              <N>
                <O>30</O>
              </N>
            </M>
          </L>
        </K>
      </partC>
    </eoa:message>
    <eoa:message xmlns:eoa="http://bluestemsoftware.org/specification/eoa/ext/message/default/1.0" xmlns:tns="http://com.mycompany/eoa/1.0" name="tns:myWSDL20StyleMessage">
      <parameters xmlns="">
        <A xmlns="http://mycompany.com">
          <B>
            <C>
              <D>
                <E>10</E>
              </D>
            </C>
          </B>
        </A>
      </parameters>
    </eoa:message>
  </providers>
</deployment>

Using a Single Part, WSDL 20 Style Message

The example above defines three runtime message definitions. The first definition defines a runtime message for abstract message {http://mycompany.com}A . The message would be retrieved and used within your application as follows:

...

  // retrieve runtime message definition defined above and extract
  // a schema property instance from content

  QName messageName = new QName("http://mycompany.com", "A");
  InterfaceMessage abstractMsg = SystemContext.getContext().getSystem().getMessage(messageName);
  Message runtimeMessage = (Message)abstractMsg.getRuntimeProvider();
  QName propertyE = new QName("http://mycompany.com", "eValue")
  Double value = (Double)runtimeMessage.evaluateNumber(propertyE);
  assert(value == 10);
  
  // clone the runtime message and overwrite the value
  // with a new value
  
  Message clone = runtimeMessage.cloneDefinition();
  Element elementE = (Element)clone.evaluateNode(propertyE);
  elementE.removeChild(elementE.getFirstChild());
  elementE.appendChild(clone.createTextNode("5"));
  
  // validate the runtime message against the abstract definition.
  // a message validation exception is thrown if it's not schema
  // valid
  
  clone.validate()
  
  // extract schema property instance again and assert that the
  // value was set
  
  value = (Double)clone.evaluateNumber(propertyE);
  assert(value == 5);
      
...  

Using a Multi-part Message

The second definition defines a runtime message for the multi-part abstract message {http://mycompany.com}myMultipartMessage . The message would be retrieved and used within your application as follows:

...

  // retrieve runtime message definition defined above and verify
  // that content is defined for each abstract part

  QName messageName = new QName("http://mycompany.com", "myMultipartMessage");
  InterfaceMessage abstractMsg = SystemContext.getContext().getSystem().getMessage(messageName);
  Message runtimeMessage = (Message)abstractMsg.getRuntimeProvider();
  assert(runtimeMessage.getContent("partA") != null);
  assert(runtimeMessage.getContent("partB") != null);
  assert(runtimeMessage.getContent("partC") != null);
  
  // extract a schema property instance. note that message part
  // name is implied as name of part whose associated content
  // contains the definition for fragment expression used to
  // extract the schema property instance
  
  QName propertyE = new QName("http://mycompany.com", "eValue")
  double value = (Double)runtimeMessage.evaluateNumber(propertyE);
  assert(value == 10);
  
  // clone the runtime message and set content for partB to
  // something new (which overwrites the existing content)
  
  Message clone = runtimeMessage.cloneDefinition();
  Element foo = clone.createContent("http://anyuri", "foo");
  clone.setContent("partB", foo);
  
  // validate the runtime message against the abstract definition,
  // which will fail, i.e. because "foo" content is not schema valid
  
  clone.validate()
      
...