Valid Format for DataModel

Some service requests allow you to pass business data into the request.

Business data is passed in the form of a dataModel element or another element that is of type dm:DataModel, such as XmlPayLoad.

The business data passed into the request can be either a simple type (simpleSpec) or a complex type (complexSpec, which is a BOM).

For example, the following shows the saveOpenWorkItem request, in which inputs, outputs, or inouts can be passed as either simpleSpec or complexSpec data:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.brm.n2.tibco.com">
  <soapenv:Header/>
  <soapenv:Body>
    <api:saveOpenWorkItem>
      <workItemID id="?" version="?"/>
      <workItemPayload>
        <dataModel>
          <inputs name="?" type="?" optional="?" array="?">
            <simpleSpec length="?" decimal="?">
              <value>?</value>
            </simpleSpec>
            <complexSpec className="?">
              <value>?</value>
            </complexSpec>
          </inputs>
          <outputs name="?" type="?" optional="?" array="?">
            <simpleSpec length="?" decimal="?">
              <value>?</value>
            </simpleSpec>
            <complexSpec className="?">
              <value>?</value>
            </complexSpec>
          </outputs>
          <inouts name="?" type="?" optional="?" array="?">
            <simpleSpec length="?" decimal="?">
              <value>?</value>
            </simpleSpec>
            <complexSpec className="?">
              <value>?</value>
            </complexSpec>
          </inouts>
        </dataModel>
      </workItemPayload>
    </api:saveOpenWorkItem>
  </soapenv:Body>
</soapenv:Envelope>

If you pass ComplexSpec business data into one of the requests, the value can be either element-based or type-based.

Note: There is no API to determine the structure of ComplexSpec business data. However, you can view the structure in TIBCO Business Studio by exporting the XML schema, which shows the structure to which the data must conform. For information, see Obtaining Information from TIBCO Business Studio.

The following shows the valid format for element-based and type-based complexSpec data values:

  • Element-based complexSpec Example
    <value>
      <businessserviceformediation:CustomerElement xsi:type="businessserviceformediation:Customer" 
    xmlns:businessserviceformediation="http://example.com/businessserviceformediation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <age>40</age>
        <name>Fred</name>
        <address xsi:type="businessserviceformediation:Address">
           <firstLine>First Line</firstLine>
           <secondLine>Second Line</secondLine>
        </address>
      </businessserviceformediation:CustomerElement>
    </value>

  • Type-based complexSpec Example
    <value xsi:type="businessserviceformediation:Customer" xmlns:businessserviceformediation=
"http://example.com/businessserviceformediation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <age>40</age>
        <name>Fred</name>
        <address xsi:type="businessserviceformediation:Address">
            <firstLine>First Line</firstLine>
            <secondLine>Second Line</secondLine>
        </address>
    </value>

Format of XmlPayload and serializedPayload in REST Operations

When XmlPayload or serializedPayload is passed in, or returned by, REST operations, you can specify the request/response format of the payload, depending on your needs, as follows:

  • Requests - Use the Content-Type header to specify either "application/xml" or "application/json" for XML- or JSON-formatted payload in the request.
  • Responses - Use the Accept header to specify either "application/xml" or "application/json" for XML- or JSON-formatted payload in the response. You can also use the responsetype query parameter on many REST operations to specify the payloadMode for the response.

For more information, see Data Payloads and Supported Media Types.

The following are various examples of formats for payloads.

Requests

  • Example Request (XML) -- Content-Type: application/xml
    <?xml version="1.0" encoding="UTF-8"?>
    <xml-fragment payloadMode="XML">
        <XmlPayload>
            <inputs array="false" type="String" name="PhoneNumber">
                <simpleSpec>
                    <value>378-887-1200</value>
                </simpleSpec>
            </inputs>
            <inputs array="false" type="String" name="UserName">
                <simpleSpec>
                    <value>John Johnson</value>
                </simpleSpec>
            </inputs>
        </XmlPayload>
    </xml-fragment>

  • Example Request (Badgerfish) -- Content-Type: application/json
    {"formalParams": {
    "@payloadMode":"XML",
    "XmlPayload": {
    "inputs": [
    {"@name":"PhoneNumber", "@type":"string", "@array":"false", "simpleSpec":{"value":887-277-3277} },
    {"@name":"UserName", "@type":"string", "@array":"false", "simpleSpec":{"value":Mary Miller} }
    ]
    }
    }}
    

  • Example Request (JSON in XML) -- Content-Type: application/xml

    Within serializedPayload, the items list members must specify mode. (The mode is implicit in the XML/Badgerfish format: <inputs> <inouts> <outputs>.)

    <?xml version="1.0" encoding="UTF-8"?>
    <xml-fragment payloadMode="JSON">
        <serializedPayload>{"items": [
        {"$param":"PhoneNumber", "type":"string", "mode":"IN", "$value":"348-887-2990"},
        {"$param":"UserName", "type":"string", "mode":"IN", "$value":"Jerry Holland"}
        ]}</serializedPayload>
    </xml-fragment>

  • Example Request (JSON) -- Content-Type: application/json

    The serializedPayload value has escaped quotes, and must not contain linebreaks.

    {"formalParams": {
    "@payloadMode": "JSON",
    "serializedPayload": "{\"items\": [{\"$param\":\"PhoneNumber\", \"$value\":\"667-121-9055\",\"type\":\"string\",\"mode\":\"IN\"},{\"$param\":\"UserName\", \"$value\":\"Billie Bob Brady\",\"type\":\"string\",\"mode\":\"IN\"}]}"
    }}
    

  • Example Request - Complex Data
    Note: All REST services support complex data in XML. However, only the WorkPresentationService supports complex data in JSON.

    When passing complex data, you must pass the $type parameter (which points to the BOM type of the parameter being sent) for the request to be processed properly.

    <payload payloadMode="JSON">
       <serializedPayload>{"items":[{"$param":"Inrequest","$value":[ {"applicationId":"AccountDetails","accountId":"9999999","channel":"SD.WEB","product":"SD","includeCreditEventData":"true","includeEmploymentInfo":"false","includeContactInfo":"false","includePersonalInfo":"false","includeBeneficiaryInfo":"true","includeAll":"true","$type":"com.tibco.AccountLookup.accountDetailsRequest"} ],"mode":"IN"}]}</serializedPayload>
    </payload>

Responses

  • responsetype=JSON (or unspecified) -- Accept: application/xml (or unspecified)
    <?xml version="1.0" encoding="UTF-8"?>
    <xml-fragment payloadMode="JSON"><serializedPayload>{"items":[{"$param":"PhoneNumber","$value":["378-887-1200"],"type":"String","mode":"IN"},{"$param":"UserName","$value":["John Johnson"],"type":"String","mode":"IN"}]}</serializedPayload></xml-fragment>

  • responsetype=JSON (or unspecified) -- Accept: application/json
    {
      "xml-fragment": {
        "@payloadMode": "JSON",
        "serializedPayload": "{\"items\":[{\"$param\":\"PhoneNumber\",\"$value\":[\"889-455-9002\"],\"type\":\"String\",\"mode\":\"IN\"},{\"$param\":\"UserName\",\"$value\":[\"Dave Henderson\"],\"type\":\"String\",\"mode\":\"IN\"}]}"
      }
    }

  • responsetype=XML -- Accept: application/xml (or unspecified)
    <?xml version="1.0" encoding="UTF-8"?>
        <xml-fragment payloadMode="XML">
          <XmlPayload>
            <inputs array="false" type="String" name="PhoneNumber">
              <simpleSpec>
                <value>889-455-9002</value>
              </simpleSpec>
            </inputs>
            <inputs array="false" type="String" name="UserName">
              <simpleSpec>
                <value>Dave Henderson</value>
              </simpleSpec>
            </inputs>
          </XmlPayload>
        </xml-fragment>
    

  • responsetype=XML -- Accept: application/json
    {
            "xml-fragment":
            {
                "@payloadMode": "XML",
                "XmlPayload":
                {
                    "inputs":
                    [
                        {
                            "@array": "false",
                            "@type": "String",
                            "@name": "PhoneNumber",
                            "simpleSpec":
                            {
                                "value": "889-455-9002"
                            }
                        },
                        {
                            "@array": "false",
                            "@type": "String",
                            "@name": "UserName",
                            "simpleSpec":
                            {
                                "value": "Dave Henderson"
                            }
                        }
                    ]
                }
            }
        }