Get External Data for Your Extension Rules

You can use an extension rule to call a web service that's outside of Oracle Fusion Applications.

For example, its probably more efficient to get data from a web service instead of maintaining it in your model, such as to get data about product specifications from your suppliers, or to get data from a large set of government regulations.

Summary of the Setup

  1. Connect the web service.
  2. Create the extension rule.

Connect the Web Service

  1. Sign into Oracle Applications with administrator privileges.
  2. Go to the Setup and Maintenance work area, then click Tasks > Search.
  3. Search for, then open the Manage External Service Details for Extensions task.
  4. On the Manage Connector Details page, click Actions > Add Row, then set the values.

    Attribute Description
    Target System

    Select the application that will provide the data.

    You can select an application that you have registered as a trading community partner, or select an Oracle application.

    Connector Name

    Enter the name that you will use to refer to the service from your extension rule.

    For this example, enter VisionCorp.

    Connector URL

    Enter the URL to the external web service.

    For example, enter http://visioncorp04.com:7011/services/VisionWebServicePort.

    User Name If the service that you're calling requires a user name, then enter it.
    Password If the service that you're calling requires a password, then enter it.
    Invocation Mode Select Synchronous.
  5. Click Save and Close.

Create the Extension Rule

Assume you already created a Groovy script and you now need to call the web service in that script.

  1. Sign into Oracle Applications with the privileges that you need to manage Oracle Configurator.
  2. Go to the Configurator Models work area.
  3. Open the model that has your script.
  4. On the Edit Configurator Model page, click Rules, the open your extension rule for editing.
  5. In the Structure area, select a base node, such as the root node of the model.
  6. In the Rule Text area, enter the Groovy script that will call the web service.
    import oracle.apps.scm.configurator.runtime.core.IRuntimeNode; 
    import oracle.apps.scm.configurator.runtime.core.ServiceException; 
    import oracle.apps.scm.configurator.runtime.core.SoapServiceRequest; 
    import oracle.apps.scm.configurator.runtime.core.SoapServiceRequest.SOAP_PROTOCOL_TYPE; 
    import oracle.apps.scm.configurator.runtime.core.SoapServiceResponse; 
    import javax.xml.soap.SOAPBody; 
    import javax.xml.soap.SOAPMessage; 
    import javax.xml.soap.SOAPElement; 
    import javax.xml.soap.SOAPBodyElement; 
    import javax.xml.namespace.QName; 
    import org.w3c.dom.Document; 
    import org.w3c.dom.Element; 
    
    public class WebCXmin implements Serializable { 
       public WebCXmin() { } 
       
       public String callWebService(IRuntimeNode node) { 
         SoapServiceRequest request = new SoapServiceRequest(node.getConfiguration()); 
         SOAPMessage message  = request.getSoapMessage(); 
    
         // Create the XML payload.
         QName bodyName = new QName("ws", "executeWebCX"); 
         SOAPBodyElement bodyElement = request.getSoapBody().addBodyElement(bodyName); 
         bodyElement.addNamespaceDeclaration("ws", "http://services.vision/"); 
         bodyElement.setPrefix("ws");   
         
         QName className = new QName("className"); 
         SOAPElement classes = bodyElement.addChildElement(className);     
         classes.addTextNode("axel.ce.ws.webcx.DSPrimeTestCX"); 
         
         QName name = new QName("params"); 
         SOAPElement params = bodyElement.addChildElement(name); 
         
         QName entry = new QName("entry"); 
         SOAPElement entries = params.addChildElement(entry);     
         
         QName key = new QName("key"); 
         SOAPElement keys = entries.addChildElement(key);   
         keys.addTextNode("json"); 
         
         QName value = new QName("value"); 
         SOAPElement values = entries.addChildElement(value);   
         values.addTextNode("{\"qty\": 2, \"children\": [], \"type\": \"MI\", \"state\": [\"UTRU\", \"SELD\", \"USLD\"]}");     
         
         message.getMimeHeaders().addHeader("Content-Type", "text/xml; charset=utf-8"); 
         message.getMimeHeaders().addHeader("SOAPAction", "executeWebCX");     
         SoapServiceResponse response; 
         try { 
         // Call the web service that you specified in the Setup and Maintenance work area.
            response = node.getConfiguration().invokeSoapService("VisionWS", request); 
         } catch (ServiceException e1) { 
            throw new Exception(" msg=" + e1.getMessage()); 
         } 
         def base = node; 
         def tf = base.getChildByName("TextFeature");         
         Document doc = response.getSoapBody().extractContentAsDocument(); 
         Element root = doc.getDocumentElement();           
         tf.textValue = "SOAP Body node: "+root.getFirstChild().getTextContent(); 
      } 
    }   
    
  7. Bind the event.
    Attribute Value

    Event

    Select one:

    • postConfigInit. Call the web service when the runtime configuration starts.
    • postValueChange. Call the web service when the user changes a value on the node that the bind references.
    Class ScriptClass
    Method

    getCpuHw(String region)

    Make sure the web service can interpret the value of the region argument.

Guidelines

  • Your script must import the SoapServiceResponse class and the SoapServiceRequest class. You might need to import other classes depending on your needs.
  • This example uses the http://services.vision namespace and the cpuHw method from the web service. It assumes that the web service defines them.
  • You must use the invokeSoapService method from the configuration object to call the web service, and you must send it to the connector name that you register in the payload. In this example, the connector name is VisionWS.

Call SOAP 1.1 or SOAP 1.2

You must use the SOAP 1.1 specification to call some SOAP services. You can't use SOAP 1.2 with them because SOAP 1.2 doesn't support the Web Service Definition Language (WSDL). As a workaround, you can add HTTP headers when you call the web service in your extension rule:

Content-Type: text/xml
SOAPAction: executeWebCX

For example:

SOAPMessage message  = request.getSoapMessage(); 
message.getMimeHeaders().addHeader("Content-Type", "text/xml; charset=utf-8"); 
message.getMimeHeaders().addHeader("SOAPAction", "executeWebCX");

If you don't specify these HTTP headers, then your SOAP 1.1 call will fail.