Example of Sending a Message to an Intermediate Message Event
This example illustrates how to send a message to an intermediate message event using the BPM Messages OData service.
In the example, the following XSD structure is used for the input of the service operation that is defined for the message event trigger:
<complexType name="Customer"> <sequence> <element name="firstName" type="string"></element> <element name="lastName" type="string"></element> <element name="address" type="tns:Address"></element> <element name="currency" type="string" default ="EUR"></element> <element name="phone-numbers" type="string" maxOccurs="unbounded" minOccurs="0"></element> <element name="vcards" type="tns:Vcard "maxOccurs="unbounded" minOccurs="0"></element> </sequence> </complexType> <complexType name="Address"> <sequence> <element name="street" type="string"></element> <element name="city" type="string"></element> <element name="zip" type="integer"></element> <element name="country" type="string"></element> </sequence> </complexType> <complexType name="vCard"> <sequence> <element name="attr1" type="string"></element> <element name="attr2" type="string"></element> <element name="attr3" type="string"></element> </sequence> </complexType>
The BPM Messages OData service provides the following metadata for the aforementioned structure of the message.
<EntityType Name="EventTrigger"> <Key> <PropertyRef Name="vendor"></PropertyRef> <PropertyRef Name="dcName"></PropertyRef> <PropertyRef Name="eventTriggerName"></PropertyRef> </Key> <Property Name="vendor" Type="Edm.String" Nullable="false"></Property> <Property Name="dcName" Type="Edm.String" Nullable="false"></Property> <Property Name="eventTriggerName" Type="Edm.String" Nullable="false"></Property> <NavigationPropertyName="message" Relationship="BPMMessages.EventTrigger_message" FromRole="From_EventTrigger" ToRole="To_Message"></NavigationProperty> </EntityType> <EntityType Name="Message"> <Key> <PropertyRef Name="EDM_Key"></PropertyRef> </Key> <Property Name="EDM_Key" Type="Edm.String" Nullable="false"></Property> <NavigationProperty Name="Customer" Relationship="BPMMessages.Message_Customer" FromRole="From_Message" ToRole="To_Customer"></NavigationProperty> </EntityType><EntityType Name="Customer"> <Key> <PropertyRef Name="EDM_Key"></PropertyRef> </Key> <Property Name="EDM_Key" Type="Edm.String" Nullable="false"></Property> <Property Name="firstName" Type="Edm.String" Nullable="true"></Property> <Property Name="lastName" Type="Edm.String" Nullable="true"></Property> <Property Name="currency" Type="Edm.String" Nullable="true" DefaultValue="EUR"></Property> <NavigationProperty Name="address" Relationship="BPMMessages.Customer_address" FromRole="From_Customer" ToRole="To_Address"></NavigationProperty> <NavigationProperty Name="phone-numbers" Relationship="BPMMessages.Customer_phone-numbers" FromRole="From_Customer" ToRole="To_phone-numbers"></NavigationProperty> <NavigationProperty Name="vcards" Relationship="BPMMessages.Customer_vcards" FromRole="From_Customer" ToRole="To_Vcard"></NavigationProperty> </EntityType> <EntityType Name="Address"> <Key> <PropertyRef Name="EDM_Key"></PropertyRef> </Key> <Property Name="EDM_Key" Type="Edm.String" Nullable="false"></Property> <Property Name="street" Type="Edm.String" Nullable="true"></Property> <Property Name="city" Type="Edm.String" Nullable="true"></Property> <Property Name="zip" Type="Edm.Decimal" Nullable="true"></Property> <Property Name="country" Type="Edm.String" Nullable="true"></Property> </EntityType> <EntityType Name="phone-numbers"> <Key> <PropertyRef Name="EDM_Key"></PropertyRef> </Key> <Property Name="EDM_Key" Type="Edm.String" Nullable="false"></Property> <Property Name="phone-numbers" Type="Edm.String" Nullable="true"></Property> </EntityType> <EntityType Name="Vcard"> <Key> <PropertyRef Name="EDM_Key"></PropertyRef> </Key> <Property Name="EDM_Key" Type="Edm.String" Nullable="false"></Property> <Property Name="attr1" Type="Edm.String" Nullable="true"></Property> <Property Name="attr2" Type="Edm.String" Nullable="true"></Property> <Property Name="attr3" Type="Edm.String" Nullable="true"></Property> </EntityType>
According to the table with the supported URIs for the BPM Messages OData service, one of the possible URIs to send a message needs to be sent to the EventTrigger entity set:
http://<host>:<port>/bpmodata/messages.svc/<vendor>/<dc-name>/<trigger-name>/EventTrigger
In this case, the POST request body contains an entity for the EventTrigger entity type along with the nested entities for the Message entity type and for the entity type that represents the message data. In our example, it is Customer.
Example of a request body:
{
"message": {
"Customer": {
"firstName": "John",
"lastName": "Doe",
"currency": "USD",
"address": {
"street": "Main str.",
"city": "Springfield",
"zip": "12345",
"country": "USA"
},
"phone-numbers": {
"results": [
{
"phone-numbers": "111-111-111"
},
{
"phone-numbers": "222-222-222"
},
{
"phone-numbers": "333-333-333"
}
]
},
"vcards": {
"results": [
{
"attr1": "John Doe",
"attr2": "john.doe_at_provider.com",
"attr3": "john.doe"
},
{
"attr1": "J.D.",
"attr2": "jd_at_provider.com",
"attr3": "jd"
}
]
}
}
}
}