Internal XQuery Sender

The Automated Task editor internal XQuery automator receives task data from OSM and sends data to an external system. You can send a message to an external system using whatever protocol that system requires, such as Telnet, HTTP, CORBA, SOAP, or web services.

The XQuery has the following characteristics:

  • XQuery context in prolog: The input document for any automated task automation plug-in is the order data defined in the Automation Task editor Task Data tab. You can access this data by declaring the TaskContext OSM Java class. Always declare this class along with the $context java binding. For example:

    declare namespace context = "java:com.mslv.oms.automation.TaskContext";
    ...
    declare variable $context external; 
    
  • Prolog: You must declare ScriptSenderContextInvocation in any internal XQuery automator which extends ScriptReceiverContextInvocation. Always declare this class along with the $automator java binding. For example:

    declare namespace automator = "java:oracle.communications.ordermanagement.automation.plugin.ScriptSenderContextInvocation";
    ...
    declare variable $automator external; 
    

    Oracle recommends that you use the standard Apache log class. Always declare this class along with the $log java binding.

    declare namespace log = "java:org.apache.commons.logging.Log";
    ...
    declare variable $log external; 
    

    You must use the TextMessage class for sending JMS based messages. Always declare this class along with the $outboundMessage Java binding. You can use JMS text based messages to send OSM Web Service messages to other OSM systems, such as a service order from an OSM COM system to an OSM SOM system.

    declare namespace outboundMessage = "java:javax.jms.TextMessage";
    ...
    declare variable $outboundMessage external;
    

    Note:

    If you need to support any other protocol for sending messages, you can implement a custom Java automation plug-in for the protocol or import a helper function implementation that supports the protocol.

  • Body: The body for an internal XQuery sender can contain the following elements:

    • Use outboundMessage to set up the standard WebLogic JMS message properties for web services:

      outboundMessage:setStringProperty($outboundMessage, '_wls_mimehdrContent_Type', 'text/xml; charset="utf-8"'),
      
    • Use outboundMessage to set up the OSM Web Service URI JMS message property:

      outboundMessage:setStringProperty($outboundMessage, 'URI', '/osm/wsapi'),
      
    • You can optionally use outboundMessage with the XML API to populate a JMS property value from order data. For example this code sets up an Ora_OSM_COM_OrderId parameter that is populated with the OSM order ID:

      outboundMessage:setStringProperty($outboundMessage, 'Ora_OSM_COM_OrderId', /oms:GetOrder.Response/oms:OrderID),
      
    • You can optionally use outboundMessage to set the JMS Correlation ID for the automation task before sending the message. This allows OSM to route a return message with the same corresponding JMS property value to an external XQuery automator on the same automation task as the original sender automation plug-in. For example, the following code sets the JMS correlation ID using the original OSM COM order:

      outboundMessage:setJMSCorrelationID($outboundMessage, concat($order/oms:_root/oms:messageXmlData/ebo:ProcessSalesOrderFulfillmentEBM/ebo:DataArea/ebo:ProcessSalesOrderFulfillment/corecom:Identification/corecom:ID/text(),'-COM')),
      

      If this code were applied to "Message Example," the return value would be a concatenation of ScenarioA2 and -COM: ScenarioA2-COM.

      Note:

      Other correlation scenarios are possible. For example, you may send a message from an automation task without expecting any response to the same automation task. In this scenario, another automation task further down in the process may be dedicated to receiving the response message, in which case an automation plug-in would be required that would set the correlation ID expected from the return message for that automated task. See the chapter about using automation in OSM Developer's Guide for more information about asynchronous communication scenarios.

    • Access to the task level order data (the task view) using the XML API GetOrder.Response function call. For example, the following code provides access to all order data passed into the task as a variable that is then used in other variables to access different parts of the data:

      let $order := /oms:GetOrder.Response
      let $othervariable := $order/oms:_root/oms:orderid
      
    • Any XQuery logic your plug-in requires, such as if-then or if-then-else statements that evaluate based on one or more parameters within the response message. For example, there could be a choice of two or more messages that could be sent depending on the order data values, or you might log a message.

    • A completeTaskOnExit method statement that completes the plug-in and transitions the task to the next task based on the status selected if the plug-in is intended to end the task. Typically, an automated task would contain an internal XQuery sender plug-in for sending a message and an external XQuery receiver plug-in for receiving a message, but you can also create an automation that only sends an order with another automation that receives the order. This can be useful if the response message takes a long time to return. If you are expecting the system to respond that you sent the message to, you must configure the internal XQuery sender with a reply to queue that listens for a message acknowledgement, whether the response is returned to an external automator on the same automation task or on another automation task.

The following example provides the code for an XQuery that sends a message from an OSM system in the COM role to an OSM system in the SOM role using the OSM Web Service interface and assumes JMS communication over T3S.

declare namespace automator = "java:oracle.communications.ordermanagement.automation.plugin.ScriptSenderContextInvocation";
declare namespace context = "java:com.mslv.oms.automation.TaskContext";
declare namespace log = "java:org.apache.commons.logging.Log";
declare namespace outboundMessage = "java:javax.jms.TextMessage";
declare namespace oms="urn:com:metasolv:oms:xmlapi:1";
declare namespace to="http://TechnicalOrder";
declare namespace provord="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1";
declare namespace corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2";
declare namespace env="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace cord="http://oracle.communications.c2a.model/internal/order";
declare namespace ebo="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/SalesOrder/V2";
 
declare variable $automator external; 
declare variable $context external;
declare variable $log external;  
declare variable $outboundMessage external;
 
let $order := /oms:GetOrder.Response
let $technicalActions := $order/oms:_root/oms:TechnicalActions
let $ebm := $order/oms:_root/oms:messageXmlData
let $bi := $order/oms:_root/oms:CaptureInteractionResponse
 
return(
outboundMessage:setStringProperty($outboundMessage, '_wls_mimehdrContent_Type', 'text/xml; charset="utf-8"'),
outboundMessage:setStringProperty($outboundMessage, 'URI', '/osm/wsapi'),
outboundMessage:setStringProperty($outboundMessage, 'Ora_OSM_COM_OrderId', /oms:GetOrder.Response/oms:OrderID),
outboundMessage:setJMSCorrelationID($outboundMessage, concat($order/oms:_root/oms:messageXmlData/ebo:ProcessSalesOrderFulfillmentEBM/ebo:DataArea/ebo:ProcessSalesOrderFulfillment/corecom:Identification/corecom:ID/text(),'-COM')),
log:info($log,concat('Sending Service Order for COM order: ', $order/oms:OrderID)),
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
        <soapenv:Header>
        <wsse:Security xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
        <wsse:UsernameToken xmlns:wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-4799946">
        <wsse:Username>demo</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">passw0rd</wsse:Password>
        </wsse:UsernameToken>
        </wsse:Security>
        </soapenv:Header>
   <soapenv:Body>
      <ord:CreateOrder>
                <ebo:ProcessProvisioningOrderEBM xmlns:ebo="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1">
<ebo:DataArea>
                             <corecom:Process xmlns="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1" xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2" xmlns:aia="http://www.oracle.com/XSL/Transform/java/oracle.apps.aia.core.xpath.AIAFunctions" xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions" xmlns:oms="urn:com:metasolv:oms:xmlapi:1" xmlns:provord="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1"/>
                             <provord:ProcessProvisioningOrder xmlns="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1" xmlns:aia="http://www.oracle.com/XSL/Transform/java/oracle.apps.aia.core.xpath.AIAFunctions" xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions" xmlns:oms="urn:com:metasolv:oms:xmlapi:1" xmlns:provord="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ProvisioningOrder/V1">
                             <corecom:SalesOrderReference>
                                  <corecom:SalesOrderIdentification>
                                      {$order/oms:_root/oms:ServiceOrder/cord:Order/cord:CustomerDetails/cord:OrderNumber/corecom:Identification/*}
                                  </corecom:SalesOrderIdentification>
                             </corecom:SalesOrderReference>
                             <provord:RequestedDeliveryDateTime>2010-07-16T08:24:38Z </provord:RequestedDeliveryDateTime>
                             <provord:TypeCode>SALES ORDER</provord:TypeCode>
                             <provord:FulfillmentPriorityCode>5</provord:FulfillmentPriorityCode>
                             <provord:FulfillmentSuccessCode>DEFAULT </provord:FulfillmentSuccessCode>
                             <provord:FulfillmentModeCode>DELIVER</provord:FulfillmentModeCode>
                             <provord:ProcessingNumber/>
                             <provord:ProcessingTypeCode/>
                             <corecom:Status xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                 <corecom:Code>IN PROGRESS</corecom:Code>
                             </corecom:Status>
                             <corecom:BusinessUnitReference xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                 <corecom:BusinessUnitIdentification>
                                     <corecom:ID schemeID="ORGANIZATION_ID" schemeAgencyID="SEBL_01">0-R9NH</corecom:ID>
                                 </corecom:BusinessUnitIdentification>
                             </corecom:BusinessUnitReference>
                             {$order/oms:_root/oms:ServiceOrder/cord:Order/cord:CustomerDetails/cord:CustomerParty/corecom:CustomerPartyReference}
                             <corecom:ParentProvisioningOrderReference xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                 <corecom:ProvisioningOrderIdentification>
                                     <corecom:BusinessComponentID schemeID="SALESORDER_ID" schemeAgencyID="COMMON"/>
                                 </corecom:ProvisioningOrderIdentification>
                             </corecom:ParentProvisioningOrderReference>
                             {
                                 for $x in $order/oms:_root/oms:ServiceOrder/cord:Order/cord:ServiceOrderLine
                                 return
                                 <provord:ProvisioningOrderLine>
                                 <corecom:Identification xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                      <corecom:BusinessComponentID>{concat($x/@id,'')} </corecom:BusinessComponentID>
                                      <corecom:ID schemeID="SALESORDER_LINEID" schemeAgencyID="SEBL_01">{concat($x/@id,'')}</corecom:ID>
                                      <corecom:ApplicationObjectKey>
                                           <corecom:ID schemeID="SALESORDER_LINEID" schemeAgencyID="SEBL_01">{concat($x/@id,'')}</corecom:ID>
                                      </corecom:ApplicationObjectKey>
                                 </corecom:Identification>
                                 <provord:OrderQuantity>1</provord:OrderQuantity>
                                 <provord:ServiceActionCode>{$x/cord:Action/text()} </provord:ServiceActionCode>
                                 <provord:ServicePointCode/>
                                 <corecom:Status xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                     <corecom:Code>IN PROGRESS</corecom:Code>
                                 </corecom:Status>
                                 <corecom:ServiceAddress xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                      <corecom:Identification>
                                          <corecom:BusinessComponentID schemeAgencyID="COMMON" schemeID="CUSTOMERPARTY_ADDRESSID">2d323733323231313531313836313331</corecom:BusinessComponentID>
                                          <corecom:ApplicationObjectKey>
                                               <corecom:ID schemeAgencyID="SEBL_01" schemeID="CUSTOMERPARTY_ADDRESSID">88-2KKNH</corecom:ID>
                                          </corecom:ApplicationObjectKey>
                                      </corecom:Identification>
                                      <corecom:LineOne>{$x/cord:Address/cord:LineOne/text()} </corecom:LineOne>
                                      <corecom:CityName>{$x/cord:Address/cord:CityName/text()} </corecom:CityName>
                                      <corecom:StateName>{$x/cord:Address/cord:StateName/text()} </corecom:StateName>
                                      <corecom:ProvinceName>{$x/cord:Address/cord:ProvinceName/ text()}</corecom:ProvinceName>
                                      <corecom:CountryCode>{$x/cord:Address/cord:CountryCode /text()}</corecom:CountryCode>
                                      <corecom:PostalCode>{$x/cord:Address/cord:PostalCode /text()}</corecom:PostalCode>
                                 </corecom:ServiceAddress>
                                 <corecom:ItemReference xmlns:corecom="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
                                 <corecom:ItemIdentification>
                                      <corecom:BusinessComponentID schemeAgencyID="COMMON" schemeID="ITEM_ITEMID"/>
                                      <corecom:ApplicationObjectKey>
                                          <corecom:ID schemeID="ITEM_ITEMID" schemeAgencyID="SEBL_01">{concat($x/cord:InstanceID/text(),'')}</corecom:ID>
                                      </corecom:ApplicationObjectKey>
                                      <corecom:AlternateObjectKey>
                                          <corecom:ContextID/>
                                      </corecom:AlternateObjectKey>
                                      <corecom:SupplierItemID/>
                                 </corecom:ItemIdentification>
                                 <corecom:Name>{concat($x/@name,'')}</corecom:Name>
                                     <corecom:ClassificationCode listID="PermittedTypeCode"></corecom:ClassificationCode>
                                     <corecom:ClassificationCode listID="BillingProductTypeCode"/>
                                     <corecom:ClassificationCode listID="FulfillmentItemCode">{concat($x/@name,'')}</corecom:ClassificationCode>
                                     <corecom:ServiceIndicator>false</corecom:ServiceIndicator>
                                     <corecom:TypeCode>SERVICE</corecom:TypeCode>
                                     <corecom:Description/>
                                     <corecom:SpecificationGroup>
                                         <corecom:Name>ExtensibleAttributes</corecom:Name>
                                         {
                                              for $y in $x/cord:Attribute
                                              return
                                              <corecom:Specification>
                                                  <corecom:ServiceActionCode> </corecom:ServiceActionCode>
                                                  <corecom:Name>{concat($y/@name,'')} </corecom:Name>
                                                  <corecom:DataTypeCode>Text</corecom:DataTypeCode>
                                                  <corecom:Value>{$y/cord:Value/cord:value/text()} </corecom:Value>
                                              </corecom:Specification>
                                         }
                                     </corecom:SpecificationGroup>
                                     <corecom:PrimaryClassificationCode>{concat($x/@name,'')} </corecom:PrimaryClassificationCode>
                                     <corecom:ServiceInstanceIndicator>true </corecom:ServiceInstanceIndicator>
                                 </corecom:ItemReference>
                                 <provord:ProvisioningOrderLineSpecificationGroup>
                                     <corecom:SpecificationGroup>
                                          <corecom:Name>ExtensibleAttributes</corecom:Name>
                                          <corecom:Specification>
                                               <corecom:Name>ParentSalesOrderLine</corecom:Name>
                                               <corecom:Value>{$x/cord:primaryMapping/text()} </corecom:Value>
                                          </corecom:Specification>
                                         {
                                              for $z in $x/cord:secondaryMapping
                                              return
                                              <corecom:Specification>
                                                  <corecom:Name>ParentSalesOrderLine</corecom:Name>
                                              <corecom:Value>{$z/text()}</corecom:Value>
                                              </corecom:Specification>
                                         }
                                     </corecom:SpecificationGroup>
                                 </provord:ProvisioningOrderLineSpecificationGroup>
                                 </provord:ProvisioningOrderLine>
                             }
                          </provord:ProcessProvisioningOrder>
                      </ebo:DataArea>
                 </ebo:ProcessProvisioningOrderEBM>
      </ord:CreateOrder>
   </soapenv:Body>
</soapenv:Envelope>