In my previous post (Part-1) I explained how to send email from OSB. But in that case we can send email only to one address and it does not have Email subject populated. In this post I will explain how to send email to different users with different contents and subject.
1.) Start by creating a simple schema, you can create this schema in Jdeveloper.
3.) Now we have business and proxy service ready. We need to pass Email subject, Email content and Email to address dynamically to business service. Navigate to Message flow of proxy service.
In this post we will create one proxy service which sets the email address, email subject and email content dynamically and in message flow of proxy we will use "Transport Header" activity to set all these values dynamically. We also need one schema that we will use in proxy service.
1.) Start by creating a simple schema, you can create this schema in Jdeveloper.
- Use below schema for this sample.
<?xml version="1.0"encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/DynamicEmail" xmlns:tns="http://www.example.org/DynamicEmail" elementFormDefault="qualified">
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/DynamicEmail" xmlns:tns="http://www.example.org/DynamicEmail" elementFormDefault="qualified">
<elementname="Email" type="tns:EmailType"></element>
<complexType name="EmailType">
<sequence>
<elementname="Emailto" type="string"></element>
<elementname="Emailsubject" type="string"></element>
<elementname="Emailcontent" type="string"></element>
</sequence>
</complexType>
</schema>
<complexType name="EmailType">
<sequence>
<elementname="Emailto" type="string"></element>
<elementname="Emailsubject" type="string"></element>
<elementname="Emailcontent" type="string"></element>
</sequence>
</complexType>
</schema>
2.) Now create proxy service. Navigate to your project, click on Create Resource drop down. Choose Proxy Service.
- Choose Message Service as Service type.
- In Message Type Configuration choose XML as "Request Message Type" as we are using schema to create proxy service. Then click on Browse button and select the schema that we added above.
- Select request element "Email" of the browse schema.
- Now accept default values and create proxy service.
- We link proxy service to business service by using route node.
- Right click on EmailBuinessService and choose Edit Route. Add an action in Route node to invoke business service. Select Business Service in Route to option.
- Add Transport Header activity. By Default it shows only one header but we can add headers as per our requirement. In our case we need only two headers one for Email To and other for Email subject. For Email content we will use Replace activity.Choose email->To from drop down and in action assign value from request message ($body/dyn:Email/dyn:Emailto/text())
- Add header for Email subject. Click Add Header and choose email -> Subject from drop down list and in action assign the value from request message ($body/dyn:Email/dyn:Emailsubject/text( ))
0 comments :
Post a Comment