Skip to main content
Skip table of contents

Initializing IPM Data Elements

Sometimes it is desirable to initialize IPM data elements without making them Web service method parameters. SOAPam Server provides "initializers" that can be used to set the value of IPM data elements that are not passed as method parameters. The initializers are setup on a per method basis in the Service Definition File. Initializers may be used to initialize any element data type.

The following SDF fragments illustrate the use of initializers. In this example, an initializer is used to set the value of the request_code element of the ipm_get_balance_request IPM, while the account_number element is mapped from the accountNumber parameter.

XML
<types>
  <type size="14" name="ipm_get_balance_request">
    <element size="2" offset="0" type="short" name="request_code">
    <element size="12" offset="2" type="unsignedNumeric" name="account_number">
  </type>
  <type size="10" name="ipm_get_balance_reply">
    <element size="2" offset="0" type="short" name="reply_code">
    <element scale="4" size="8" offset="2" type="long" name="account_balance">
  </type>
</types> 
...
<method server="getAccountBalanceServer" name="getAccountBalance2">
  <parameters>
    <parameter direction="out" type="integer" name="result">
    <parameter direction="in" type="unsignedNumeric" name="accountNumber">
    <parameter direction="out" type="decimal" name="balance">
  </parameter>
  <request type="ipm_get_balance_request">
    <!-- Initialize the request code value -->
    <initializers>
      <initializer value="1" element="request_code"/>
    </initializers>
    <mappings>
      <mapping element="account_number" name="accountNumber"/>
    </mappings>
  </request>
  ....
</method>

 

You may also use the value attribute on element definitions to set the default value of an element. The following SDF fragment shows how to set the value of the request_code element using the value attribute:

 

XML
<types>
  <type size="14" name="ipm_get_balance_request">
    <element size="2" offset="0" type="short" name="request_code" value="1">
    <element size="12" offset="2" type="unsignedNumeric" name="account_number">
  </type>
</types> 
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.