Skip Headers
Oracle® Communications Service Broker Service Controller Implementation Guide
Release 6.1

Part Number E29460-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

6 Manipulating Headers and Body of Messages

This chapter describes how to manipulate headers and the body of a message before Service Broker sends it to an application.

About Manipulating Headers and the Body of the Message

Applications might impose various requirements on the structure and contents of headers and the body of messages that these applications receive from Service Broker.

For example, the phone number prefix of a mobile operator changed. However, you want to allow mobile subscribers to use the old prefix and replace it with the new one before forwarding the call to the SIP application. In this case, you need to modify the contents of the To header.

Similarly, a SIP application might support only CAP phase 3 while Service Broker received the message in CAP phase 4. In this case, you might want to remove all CAP phase 4-specific headers and leaving only those headers that the SIP application can recognize.

To manipulate headers and the body of a message before sending it to the application, you add an SM-PME supplementary module to your orchestration logic.

Figure 6-1 shows an example of a session when SM-PME receives the session, modifies the value of the To header, and forwards the session to the SIP application.

Figure 6-1 SM-PME in the Orchestration Logic

SM-PME in the Orchestration Logic

The SM-PME modifies the headers and body according to the rules that you define in a file, known as mapping file.

About the Mapping File

The mapping file is an XML file. It contains an XSL transform that the SM-PME applies to the SIP headers and body. You create the mapping file outside of Service Broker (for example, using an XML editor) and then specify the location of the mapping file when you configure the SM-PME.

If you added the SM-PME to your Service Broker deployment, but do not specify the location of the mapping file, the SM-PME forwards the session to the application without any modifications.

Converting Headers and SDP Body to the XML Representation

XSL transforms can be applied to XML-based structures only. However, headers and the body of a message are not stored in an XML. To apply the XSL transform defined in the mapping file to the headers and body, the SM-PME performs the following steps:

  1. First, the SM-PME converts the headers and the body to an XML representation. This is an automatic process that does not require your involvement.

  2. Then the SM-PME modifies headers and the body by applying the mapping file to the XML representation.

  3. After the headers and body are modified, the SM-PME converts the headers and body from the XML representation back to their original format.

About the Structure of the Mapping File

The mapping file consists of the following sections:

  • Header manipulation: This section is wrapped in the <header> element. A mapping file can contain only one <header> element.

  • Body manipulation: This section is wrapped in the <body> element. A mapping file can contain multiple <body> elements. Each <body> element contains the <Content-Type> element that specifies the protocol of the body, such as SDP or CAP.

Both the header manipulation section and each body manipulation section contain an XSL transform. Example 6-1 shows how a typical mapping file is structured.

Example 6-1 Mapping File Structure

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
   <header>
      <xsl><![CDATA[
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <!-- XSL transform for headers -->
         </xsl:stylesheet>
      ]]></xsl>
   </header>

   <body>
      <Content-Type>application/sdp</Content-Type>
      <xsl><![CDATA[
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <!-- XSL transform for the SDP body -->
         </xsl:stylesheet>
      ]]></xsl>
   </body>

   <body>
      <Content-Type>application/cap-phase4+xml</Content-Type>
      <xsl><![CDATA[
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
               <!-- XSL transform for the CAP4 body -->
         </xsl:stylesheet>
      ]]></xsl>
   </body>
</mapping>

Manipulating SIP Headers

You might need to manipulate headers of a SIP message to make the message to conform to the requirements that the SIP application imposes.

Note:

The SM-PME can modify headers of SIP requests only.

Converting the Headers to XML

When the SM-PME converts a message to the XML, it represents each header as follows:

<SALHeader>
      <Header>Header_Name</Header>
      <Content>Header_Content</Content>
   </SALHeader>

Example 6-2 shows the original format of the message headers.

Example 6-2 Original Format of SIP Message Headers

INVITE sip:bob@biloxi.com SIP/2.0
Via: SIP/2.0/UDP 
bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1
Via: SIP/2.0/UDP tzach.com
Max-Forwards: 69
To: sip:+12121235553322@biloxy.com
From: sip:+12125551212@biloxy.com;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:alice@pc33.atlanta.com>
Content-Type: application/sdp

Example 6-3 shows the XML representation to which the SM-PME converts the headers.

Example 6-3 XML Representation of SIP Message Headers

<?xml version="1.0" encoding="UTF-8"?>
<SALMsgHeader>
   <Request-Line>INVITE sip:bob@biloxi.com SIP/2.0</Request-Line>
   <SALHeader>
      <Header>From</Header>
    <Content>sip:+12125551212@biloxy.com;tag=1928301774</Content>
   </SALHeader>

   <SALHeader>
      <Header>To</Header>
      <Content>sip:+12121235553322@biloxy.com</Content>
   </SALHeader>

   <SALHeader>
      <Header>Via</Header>
      <Content>"SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1"</Content>
   </SALHeader>

   <SALHeader>
      <Header>Via</Header>
      <Content>"SIP/2.0/UDP Tzach.com"</Content>
   </SALHeader>

   <SALHeader>
      <Header>Max-Forwards</Header>
      <Content>"69"</Content>
   </SALHeader>

   <SALHeader>
      <Header>Call-ID</Header>
      <Content>a84b4c76e66710</Content>
   </SALHeader>

   <SALHeader>
      <Header>CSeq</Header>
      <Content>314159 INVITE</Content>
   </SALHeader>

   <SALHeader>
      <Header>Contact</Header>
      <Content>"&lt;sip:alice @ pc33.atlanta.com&lt;"</Content>
   </SALHeader>

</SALMsgHeader>

Changing the Contents of the Header

Example 6-4 shows how you can code an XSL transform that changes the phone number in the To header from sip:+12121235553322@biloxy.com to sip:+12123335553322@biloxy.com.

The transform copies the rest of the headers without any modification. (See http://www.w3.org/TR/xslt for more information about XSLT.)

The code related to the headers manipulation is emphasized with bold.

Example 6-4 SIP Headers Manipulation

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
   <header>
      <xsl><![CDATA[
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:template match="/SALMsgHeader">
               <SALMsgHeader>
                  <xsl:copy-of select="node()[(name()='Request-Line')]"/>
                  <xsl:copy-of select="node()[(name()='Status-Line')]"/>
                  <xsl:for-each select="SALHeader">
                        <SALHeader>
                           <xsl:choose>
                              <xsl:when test="Header='To'">
                                 <xsl:copy-of select="Header"/>
                                 <Content>sip:+12123335553322@biloxy.com</Content>
                             </xsl:when>
                             <xsl:otherwise>
                                <xsl:copy-of select="Header"/>
                                <xsl:copy-of select="Content"/>
                             </xsl:otherwise>
                           </xsl:choose>
                        </SALHeader>
                     </xsl:for-each>
                  </SALMsgHeader>
               </xsl:template>
            </xsl:stylesheet>
        ]]></xsl>
   </header>

   <body>
      <!-- XSL transform for the SDP body -->
   </body>
</mapping>

Manipulating an SDP Body

The SM-PME can modify the body of both SIP requests and responses.

After you changed the SDP body, you might need to change the Content-Type header of the SDP body. This can be required when you converted a message from one protocol to another.

For example, the original message is in CAP phase 4. Therefore, the Content-Type header is set to application/cap-phase4+xml. However, the SIP application supports CAP phase 3 only. Therefore, you need to remove some headers and left only those headers which are supported in CAP phase 3. Then in the resulted message, you should change the Content-Type to application/cap-phase3+xml.

Converting the SDP Body

When the SM-PME converts an SDP body of the message to the XML, it represents each field in the SDP body as follows:

<Field>
      <Type>Field_Name</Type>
      <Value>Field_Value</Value>
   </Field>

The SM-PME converts the body to the XML representation only if there is at least one non-empty <body> element.

Example 6-5 shows the original format of the SDP body.

Example 6-5 Original SDP Body

v=0
o=user1 53655765 2353687777 IN IP4 10.162.34.115
c=IN IP4 10.162.34.115
t=0 0
m=audio 6001 RTP/AVP 0
a=rtpmap:0 PCMU/8000 

Example 6-6 shows the XML representation to which the SM-PME converts the SDP body.

Example 6-6 XML Representation of the SDP Body

<?xml version="1.0" ?>
<SDPSessionDescription>
   <Field>
      <Type>v</Type>
      <Value>0</Value>
   </Field>

   <Field>
      <Type>o</Type>
      <Value>user1 53655765 2353687777 IN IP4 10.162.34.115</Value> 
   </Field>

   <Field>
      <Type>c</Type>
      <Value>IN IP4 10.162.34.115</Value> 
   </Field>

   <Field>
      <Type>t</Type>
      <Value>0 0</Value>
   </Field>

   <Field>
      <Type>m</Type>
      <Value>audio 6001 RTP/AVP 0</Value>
   </Field>

   <Field>
      <Type>a</Type>
      <Value>rtpmap:0 PCMU/8000</Value> 
   </Field>
</SDPSessionDescription>

Manipulating the SDP Body

Example 6-7 shows how you can create an XSL transform that sets the value of the <Type> element to 1 0. (See http://www.w3.org/TR/xslt for more information about XSLT.) The code related to the SDP body manipulation is emphasized with bold. The <Content-Type> element specifies that the transform is designed for SDP messages.

Example 6-7 Manipulating the SDP Body

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
   <header>
      <xsl><![CDATA[
         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <!-- XSL transform for headers -->
         </xsl:stylesheet>
      ]]></xsl>
   </header>

   <body>
      <Content-Type>application/sdp</Content-Type>
      <xsl><![CDATA[         <xsl:stylesheet version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:template match="/SDPSessionDescription">
               <SDPSessionDescription>
                  <xsl:for-each select="Field">
                     <Field>
                        <xsl:choose>
                           <xsl:when test="Type='t'">
                              <xsl:copy-of select="Type"/>
                              <Value>1 0</Value>
                           </xsl:when>
                           <xsl:otherwise>
                              <xsl:copy-of select="Type"/>
                              <xsl:copy-of select="Value"/>
                           </xsl:otherwise>
                        </xsl:choose>
                     </Field>
                  </xsl:for-each>
               </SDPSessionDescription>
            </xsl:template>
         </xsl:stylesheet>
      ]]></xsl>
   </body>
</mapping>

Changing the Content Type in the Transformation Result

You can change the content type of a body in the transformation result using the <Content-Type-Result> element. If you do not specify this element, then the content type of the body in the transformation result is the same as in the original message.

Example 6-8 shows how you can create an XSL transform that changes the content body from application/cap-phase4+xml (see the value of the <Content-Type> element) to application/cap-phase3+xml (see the value of the <Content-Type-Result> element).

Example 6-8 Changing the Content Type

<?xml version="1.0" encoding="UTF-8"?>
<mapping>
   <header>
      <!-- XSL transform for the SDP body -->.
</header>

<body>
   <Content-Type>application/cap-phase4+xml</Content-Type>
   <Content-Type-Result>application/cap-phase3+xml</Content-Type-Result>
   <xsl><![CDATA[
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="text()" />
            <xsl:template match="Cap4">
               <xsl:apply-templates />
            </xsl:template>
            <xsl:template match="initialDP">
               <Cap3>
                  <initialDP>
                     <xsl:copy-of select="serviceKey"/>
                     <xsl:copy-of select="bearerCapability"/>
                     <xsl:copy-of select="timeAndTimezone"/>
                  </initialDP>
               </Cap3>
            </xsl:template>
      </xsl:stylesheet>
   ]]></xsl>
</body> 
</mapping>

Setting Up Manipulation of Message Headers and Body

To set up manipulation of message headers and body:

  1. Create a mapping file.

  2. Add an instance of SM-PME to your Service Deployment. See the discussion on adding an SM-PME to the Service Broker deployment in Oracle Communications Service Broker Modules Configuration Guide for more information.

  3. Specify the location of the mapping file and define other parameters in the configuration of the SM-PME. See the discussion on setting up an SM-PME in Oracle Communications Service Broker Modules Configuration Guide for more information.

  4. Add the SM-PME to the orchestration logic. See the discussion on building an orchestration logic in Oracle Communications Service Broker Orchestration User's Guide.