SP - Advanced API Samples - Mediator, Web Services, and DSP Controls This page last changed on Dec 31, 2008.
| This page collects the following related topics on a single HTML page: Getting Started with Advanced API Samples Understanding the Advanced Static Mediator API Sample Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference This arrangement is designed to facilitate printing of the entire topic. Some duplication of references, link headers, and "Related Topics" information may be observed.
Design and code | Michael Reiche
Documentation | John Jerney
Version(s) supported | Oracle Data Service Integrator 10gR3
# Getting Started with Advanced API Samples
| Prefer all related topics on a single page? Click here.
- This advanced topic supplements existing documentation that describes the invocation of Oracle Data Service Integrator operations from Mediator API, web service, and DSP Control clients. Specifically this topic introduces the sample and provides links to the instructions necessary to download, build, and test the samples. #### Topic Map Getting Started with Advanced API Samples Requirements Useful References Introduction Exploring the Sample Projects Related Topics ## Requirements #### Download the Sample You can install and work with the advanced API samples on any system with Oracle Data Service Integrator 10gR (Oracle WebLogic Server 10gR3) installed, including the Sample Retail Application provided with Oracle Data Service Integrator. The advanced API samples are available as a ZIP file from: http://edocs.bea.com/aldsp/docs30/code/AdvancedAPISamples.zip It is recommended that the ZIP file be extracted into an Oracle Data Service Integrator directory such as: <ALDSP_HOME>/user_projects/workspaces/default/AdvancedAPISamples #### Install Workshop for WebLogic 10.3 In order to run the Oracle Data Service Integrator Control samples you need to install Workshop for WebLogic 10.3 into the BEA_HOME where your Oracle Data Service Integrator server resides. You can download Workshop for WebLogic 10.3 from: http://commerce.bea.com/showproduct.jsp?family=WLW&major=10.2&minor=0 ## Useful References Introducing Data Services for Client Applications Create Your First Data Services Configure the Retail Dataspace Sample Application Configure the Retail Dataspace Sample Application for ALDSP 3.2 Configure the Retail Dataspace Sample Application for ALDSP 3.01 Data Programming Model and Update Framework Invoking Data Services from Java Clients ## Introduction Oracle Data Service Integrator enables you to create client projects that invoke data service operations. These client projects can include the following, among others: Java projects that invoke data service functions and procedures using the Data Services Mediator API (also known as the Mediator API) Java-based web service applications using the Mediator API Workshop for WebLogic projects (such as portals, business processes, and Web applications) using Oracle Data Service Integrator Controls
  | See Choosing a Client Programming Model for more information about deciding how to choose a specific client model for accessing Oracle Data Service Integrator.
## Exploring the Sample Projects Oracle Data Service Integrator includes a set of four sample dataspace projects, based on the Retail Dataspace example provided with Oracle Data Service Integrator, that shows how to call Oracle Data Service Integrator from client applications using the following: The static and dynamic Java Mediator APIs The static and dynamic Web Service Mediator API An Oracle Data Service Integrator Control using the static and dynamic Mediator APIs The sample dataspace projects highlight several aspects of the client development process including calling data service operations with different types of arguments and returning different return types. The sample dataspace projects also demonstrate how to use out-of-band settings (RequestConfig), and show how to perform create, read, update, and delete operations on the data returned.
| You can run the Java and Web Service Mediator samples either as standalone applications, or inside web applications. The DSP Control examples, however, must be run inside a container (WebLogic).
# Related Topics ##### Concepts Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## Understanding the Advanced Static Mediator API Sample This topic describes how to use the static mediator API to call a data service operation with a complex argument.
| You can find the source code for this sample project in the following file: `DSPClientSamplesStatic1/JavaResources/client.java_and_ws.static0/ClientComplexArg.java`
#### Topic Map Understanding the Advanced Static Mediator API Sample Importing Packages Obtaining a Data Access Service Handle Creating the SDO DataFactory Retrieving Data from the Service Obtaining a DataObject from the Result Disposing the dasResult Object ClientComplex.Arg.java Listing Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Importing Packages The first segment of the sample project imports several required packages including the DASResult package which represents the result of invoking an operation on a data service.
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;

    import com.bea.dsp.das.DASResult;

    import weblogic.jndi.Environment;
    import java.io.StringWriter;
Note that you could also choose to import the following classes that appear in the generated mediator client JAR file:
    import das.ws.retailapplication.customermanagement.ProfileServiceDAS
    import das.ejb.retailapplication.customermanagement.ProfileServiceDAS
    import retailer.CASE_SERVICE
- The ProfileServiceDAS classes (for web services and Java respectively) are the generated DataAccessService classes for the data service. These classes contains type-safe methods that map to the actual data service operations. The CASE_SERVICE class provides the SDO interface for manipulating DataObjects returned from the data service. ### Obtaining a Data Access Service Handle You use a DataAccessService object to call methods (operations) on a data service. For the static mediator API, the DataAccessService (DAS) classes have a factory method named getInstance() which return the handle. The getInstance() method requires two parameters to return the handle: A WebLogic JNDI Context object. The context object allows the Java client to connect to the data service running through a instance of WebLogic server. The name of the dataspace project in which the data service is deployed.
  | For more information on the DataAccessService class see: Oracle Data Service Integrator Javadoc For more information on WebLogic JNDI context objects, see Programming WebLogic JNDI: Programming WebLogic JNDI
The Oracle Data Service Integrator web service client identifies the DataAccessService class using the URL of the WSDL file. The Oracle Data Service Integrator Java client, on the other hand, identifies the DataAccessService class using the dataspace name. The sample code parses the WSDL URL to determine the dataspace name for the Java client. Note that in a typical application, you would more likely use strings rather than obtaining this information from the WSDL URL.
    das.ws.retailapplication.customermanagement.ProfileServiceDAS wsDas = null;
    das.ejb.retailapplication.customermanagement.ProfileServiceDAS ejbDas = null;
    DASResult<retailer.CASE_SERVICE> dasResult = null;

    ...

       if(isWebServiceClient()){
          contextCacheKey=locator;
          wsDas=das.ws.retailapplication.customermanagement.ProfileServiceDAS.getInstance(
             new java.util.Hashtable(), contextCacheKey);
       } else {
          splitLocator(locator);
          Context ctx = getInitialContext(uri, username, password);
          ejbDas=das.ejb.retailapplication.customermanagement.ProfileServiceDAS.getInstance(ctx, contextCacheKey);
       }
The sample uses a helper method, getInitialContext(), to get the initial context.
    public static InitialContext getInitialContext(String url, String username, String password) throws NamingException {
       Environment env = new Environment();
       env.setProviderUrl(url);
       env.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
       env.setSecurityPrincipal(username);
       env.setSecurityCredentials(password);
       return new InitialContext(env.getInitialContext().getEnvironment());
    }
### Creating the SDO DataFactory The following code segment shows the use of the HelperContext to create a new DataFactory which you can later use to create new DataObjects.
    commonj.sdo.helper.HelperContext hc=com.bea.dsp.das.HelperContextCache.get(contextCacheKey);
    commonj.sdo.helper.XMLHelper xh = hc.getXMLHelper();
    commonj.sdo.helper.DataFactory factory = hc.getDataFactory();
### Retrieving Data from the Service The generated DataAccessService method getServiceCase(profileService) retrieves the result set from the data service. This method returns all CASE objects corresponding to the specified profile from the data service.
    retailer.PROFILE_SERVICE profileService =(retailer.PROFILE_SERVICE)factory.create(retailer.PROFILE_SERVICE.class );

       com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
       retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
       profile.setCustomerID("CUSTOMER4");
       profile.setFirstName("dummyFirstName");
       profile.setLastName("dummyLastName");
       profile.setCustomerSince( "2001-01-01");
       profile.setEmailAddress( "dummyEmailAddress");
       profile.setTelephoneNumber("8885551212");

       if(isWebServiceClient()){
          dasResult = wsDas.getServiceCase(profileService);
       } else {
          dasResult = ejbDas.getServiceCase(profileService);
       }
Note that the argument for the setElementName() method must include the namespace URI along with the name of the type of the argument. You can determine the namespace URI by doing the following: Open RetailDataspace/RetailApplication/CustomerManagement/ProfileService.ds In the Design View, right-click the getServiceCase function and choose Edit Signature. Select the PROFILE argument, and click Edit. The Schema file field shows the schema file where the element is defined. Select and copy the contents of the schema file, choose File > OpenFile, paste the file name into the text box (manually changing the forward slashes to backward slashes), and click Open. Click Design View for the open schema file. Locate the PROFILE element and note its type (PROFILE_SERVICE). The namespace URI for the type appears at the top of the Schemas box (urn:retailer). The method getServiceCase() is mapped directly from the original data service operation of the same name. The operation definition as specified in the data service file appears as follows:
    (::pragma  function <f:function kind="navigate" roleName="ServiceCase" visibility="public" xmlns:f="urn:annotations.ld.bea.com"/>::)

    declare function tns:getServiceCase($profile as element(ns5:PROFILE)) as element(ns7:CASE)*{
    for $b in ns8:getServiceCaseByCustID($profile/ns2:PROFILE/CustomerID)
    return $b
    };
### Obtaining a DataObject from the Result The return type of the DataAccessService method is a dasResult object, which operates as an iterator. This means that you can use the DASResult.next() method similar to the way you would use the Java method Iterator.next(). The DASResult.next() method returns the next CASE, which is an SDO DataObject. SDO is a Java-based data programming model (API) and architecture for accessing and updating data. The sample iterates through the dasResult object and outputs the data.
    while( dasResult.hasNext()){
       out("DataObject : " + dataObjectToString(xh,(retailer.CASE_SERVICE)dasResult.next()));
    }
### Disposing the dasResult Object You must call the DASResult.dispose() method whenever you are finished iterating through a result object. The sample project uses the following code segment to dispose the object:
    try {
       if(dasResult!=null) dasResult.dispose();
    } catch(Exception e){e.printStackTrace();}
| Placing the dispose() call in a try/finally block is a recommended best practice.
### ClientComplex.Arg.java Listing The following lists the code for the ClientComplexArg.java sample project. ##### ClientComplex.Arg.java Sample Project Code
    package client.java_and_ws.static0;

    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;

    import com.bea.dsp.das.DASResult;

    import weblogic.jndi.Environment;
    import java.io.StringWriter;

    public class ClientComplexArg {

       String locator="http://localhost:7001/RetailDataspace/RetailApplication/CustomerManagement/ProfileService.ws?WSDL";
       String dsLocator=null;
       String uri=null;
       String username= "weblogic";
       String password="weblogic";

       java.io.Writer out=new java.io.PrintWriter(System.out);

       String className=this.getClass().getName().substring(this.getClass().getName().lastIndexOf('.')+1);
       String runningIn=this.getClass().getClassLoader().equals(com.bea.dsp.das.DASResult.class.getClassLoader()) ? "standalone" : "webapp";
       String contextCacheKey=null;

       enum ClientType {java, webservice, control};
       ClientType clientType=ClientType.java;
       enum ClassloaderType { noclassloader, currentthread, other};
       ClassloaderType classloaderType=ClassloaderType.noclassloader;

       public ClientComplexArg(){
          this((String)null,(String)null,(String)null, (String)null, null, null);
       }

       public ClientComplexArg(java.io.Writer out){
          this((String)null,(String)null,(String)null, (String)null, out, null);
       }

       public ClientComplexArg(String locator){
          this(locator,(String)null,(String)null, (String)null, null, null);
       }

       public ClientComplexArg(String locator, java.io.Writer out, String classloadertypeStr){
          this(locator,(String)null,(String)null, (String)null, out, classloadertypeStr);
       }

       public ClientComplexArg(String cType, String locator, String username, String password, java.io.Writer out, String classloadertypeStr){
          if(cType != null) this.clientType=ClientType.valueOf(cType);
          if(locator!=null) this.locator=locator;
          if(username!=null) this.username=username;
          if(password!=null)this.password=password;
          if(out!=null) this.out=out;
          if(classloadertypeStr != null) this.classloaderType=ClassloaderType.valueOf(classloadertypeStr);
       }

       public static void main(String[] args) {
          String locator=args.length > 0 ? args[0] : null;
          String uri=args.length > 1 ? args[1] : null;
          String username=args.length > 2 ? args[2] : null;
          String password=args.length > 3 ? args[3] : null;
          String classloadertypeStr=args.length > 4 ? args[4] : null;
          ClientComplexArg c=new ClientComplexArg(locator, uri, username, password, null, classloadertypeStr);
          c.run();
       }

       public void run(){

          if (! locator.startsWith("http://") ){
             out("locator must be http://... (wsdl URL)");
             return;
          }

          das.ws.retailapplication.customermanagement.ProfileServiceDAS wsDas = null;
          das.ejb.retailapplication.customermanagement.ProfileServiceDAS ejbDas = null;
          DASResult<retailer.CASE_SERVICE> dasResult = null;

          try {
             if (isWebServiceClient()){
                contextCacheKey=locator;
                wsDas=das.ws.retailapplication.customermanagement.ProfileServiceDAS.getInstance(new java.util.Hashtable(), contextCacheKey);
             } else {
                splitLocator(locator);
                Context ctx = getInitialContext(uri, username,password);
                ejbDas = das.ejb.retailapplication.customermanagement.ProfileServiceDAS.getInstance(ctx, contextCacheKey);
             }

             commonj.sdo.helper.HelperContext hc=com.bea.dsp.das.HelperContextCache.get(contextCacheKey);
             commonj.sdo.helper.XMLHelper xh = hc.getXMLHelper();
             commonj.sdo.helper.DataFactory factory = hc.getDataFactory();

             retailer.PROFILE_SERVICE profileService =(retailer.PROFILE_SERVICE)factory.create(retailer.PROFILE_SERVICE.class );

             com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
             retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
             profile.setCustomerID("CUSTOMER4");
             profile.setFirstName("dummyFirstName");
             profile.setLastName("dummyLastName");
             profile.setCustomerSince( "2001-01-01");
             profile.setEmailAddress( "dummyEmailAddress");
             profile.setTelephoneNumber("8885551212");

             if (isWebServiceClient()){
                dasResult = wsDas.getServiceCase(profileService);
             } else {
                dasResult = ejbDas.getServiceCase(profileService);
             }

             while( dasResult.hasNext()){
                out("DataObject : " + dataObjectToString(xh,(retailer.CASE_SERVICE)dasResult.next()));
             }
          } catch (Exception e) {
             e.printStackTrace();
          } finally {
             try {
                if(dasResult!=null) dasResult.dispose();
             } catch(Exception e){e.printStackTrace();}
          }
       }

       public void out(String s){
          try{
             if(out instanceof javax.servlet.jsp.JspWriter)
                s = s.replace("&","&amp;").replace("<", "&lt;").replace(">", "&gt;");
                out.write(className+"/"+runningIn+"/"+clientType+"/"+classloaderType+" "+s+"\n");
                out.flush();
          }catch (Exception e){
             e.printStackTrace();
          }
       }

       public static InitialContext getInitialContext(String url, String username, String password) throws NamingException {
          Environment env = new Environment();
          env.setProviderUrl(url);
          env.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
          env.setSecurityPrincipal(username);
          env.setSecurityCredentials(password);
          return new InitialContext(env.getInitialContext().getEnvironment());
       }

       static String dataObjectToString(commonj.sdo.helper.XMLHelper xh, commonj.sdo.DataObject dObj) {
          try {
             com.bea.sdo.PropertyXML element = ((com.bea.sdo.DataObjectXML) dObj).getContainmentPropertyXML();
             String elementName = element.getXMLName();
             String elementURI = element.getXMLNamespaceURI();

             commonj.sdo.helper.XMLDocument xmlDocument = xh.createDocument(dObj, elementURI, elementName);
             StringWriter outputWriter = new StringWriter();
             xh.save(xmlDocument, outputWriter, null);
             return outputWriter.toString();
          } catch (Exception e) {
             e.printStackTrace();
          }
             return null;
       }

       boolean isWebServiceClient(){
          return clientType==ClientType.webservice;
       }

       void splitLocator(String locator) throws Exception {
          uri=null;
          contextCacheKey=null;
          dsLocator=null;
          for(int i=0, j=0, last=0;i<locator.length(); i++) {
             if(locator.charAt(i) == '/') {
                j++;
                if(j==2)
                   last=i;
                if(j==3) {
                   uri="t3://"+locator.substring(last+1,i);
                   last=i;
                }
                if(j==4) {
                   contextCacheKey=locator.substring(last+1,i);
                   dsLocator="ld:"+locator.substring(i+1).replace(".ws?WSDL", "");
                   break;
                }
             }
          }
          if(uri==null || contextCacheKey== null || dsLocator==null)
             throw new Exception("locator not valid : "+locator);
          return;
       }
    }
2. ## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## How To Set Up the Advanced API Sample Projects This topic describes how to set up the Oracle Data Service Integrator sample projects which illustrate how to call data service operations from client applications. #### Topic Map How To Set Up the Advanced API Sample Projects Installing the Oracle Data Service Integrator Retail Dataspace Sample Adding Functions to the Dataspace Project Updating the Schema Exporting the Mediator Client JAR Files Creating the Sample Dataspaces Adding the Mediator Client JAR Files Setting the Java Build Paths Setting the Run Configurations Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Installing the Oracle Data Service Integrator Retail Dataspace Sample Launch Workshop for WebLogic. Install the Oracle Data Service Integrator Retail Dataspace Sample. The sample creates a dataspace for retail data services that connects to a relational database and web services.
   | For more information, see Configure the Retail Dataspace Sample Application
3. ### Adding Functions to the Dataspace Project To add the sample functions to the `RetailDataspace` project: Expand the `RetailDataspace` project in the Project Explorer, and locate the `RetailApplication/CustomerManagement/ProfileService.ds` data service. ProfileService Data Service in the Project Explorer Double-click the `ProfileService.ds` data service and click the Source tab. In the `ProfileService.ds` data service, add the following functions to the bottom of the Source view:
       declare namespace ord= "ld:Logical/Order/Order";

       (::pragma  function <f:function kind="library" visibility="public" isPrimary="false" xmlns:f="urn:annotations.ld.bea.com"/>::)
       declare function tns:getOrderCount($arg as xs:string) as xs:integer {
          count( for $b in ord:getOrderByCustID($arg) return $b)
       };

       (::pragma  function <f:function kind="library" visibility="public" isPrimary="false" xmlns:f="urn:annotations.ld.bea.com"/>::)
       declare function tns:getOrderCounts($arg as xs:string) as xs:integer* {
          for $b in ord:getOrderByCustID($arg) return 1
       };

       (::pragma  function <f:function kind="library" visibility="public" isPrimary="false" xmlns:f="urn:annotations.ld.bea.com"/>::)

       declare function tns:getServiceCases($profiles as element(ns5:PROFILES)) as element(ns7:CASE)* {
          for $profile in $profiles/ns2:PROFILE
          for $b in ns8:getServiceCaseByCustID($profile/CustomerID)
          return $b
       };
3. The sample projects call these functions to determine the order count and to retrieve the service cases. Choose File > Save in the main menu. ### Updating the Schema To update the schema file to support the new functions in the `ProfileService.ds` data service follow these steps: Locate the `RetailApplication/CustomerManagement/schemas/ProfileService.xsd` schema file. ProfileService XSD in the Project Explorer Double-click the `ProfileService.xsd` schema file and click the Source tab. In the `ProfileService.xsd` schema file, add the following lines before `</xs:schema>` at the bottom of the Source view:
       <xsd:complexType name="PROFILE_SERVICES">
             <xsd:sequence>
                <xsd:element ref="retailerType:PROFILE" minOccurs="0" maxOccurs="unbounded"/>
             </xsd:sequence>
          </xsd:complexType>
       <xsd:element name="PROFILES" type="retailer:PROFILE_SERVICES"/>
1. This specifies the `PROFILE_SERVICES` complex type, which is used by the new functions you added to the `ProfileService.ds` data service in the previous section. Choose File > Save in the main menu. Redeploy the RetailDataspace. ### Exporting the Mediator Client JAR Files Before exporting the Mediator Client JAR files, you need to create a web service map. To create the web service map: Right-click the `ProfileService.ds` data service and choose Create Web Service Map. Click OK to any information dialogs that may appear. Creating a Web Service Map Redeploy the RetailDataspace. #### Exporting the Java Mediator Client JAR File To export the Java Mediator Client JAR file for the project: Right-click the RetailDataspace and choose Export. Expand Oracle Data Service Integrator, select Mediator Client JAR file, and click Next. Selecting Mediator Client JAR File RetailDataspace should be selected; if not, click the checkbox next to that option. Choose a convenient destination directory for the `RetailDataspace-dsp-client.jar` file. Then click Finish. Workshop for WebLogic creates the Mediator Client JAR file. A message indicating that your have successfully exported the mediator JAR file and its location should appear. #### Exporting the Java Web Services Mediator Client JAR File To export the Java Web Services Mediator Client JAR File: Right-click the RetailDataspace and choose Export. Expand Oracle Data Service Integrator, select Web Services Mediator Client JAR File, and click Next. Notice that the necessary projects and folders are automatically selected. Selecting Mediator Client JAR File Select a destination directory and click Finish. Workshop for WebLogic creates the Web Services Mediator Client JAR file. A message indicating that your have successfully exported the web services mediator JAR file and its location should appear. ### Creating the Sample Dataspaces The sample provides four dataspaces: DSPClientSamplesDynamic1 DSPClientSamplesStatic1 DSPClientSamplesControlDynamic DSPClientSamplesControlStatic The dynamic and static client samples illustrate use of the Java and Web Services Mediator APIs. The control dynamic and static samples, illustrate use of Oracle Data Service Integrator Control APIs. You can create the four sample dataspaces by dowloading and importing the advanced samples ZIP file. Download the ZIP file from the following location: http://edocs.bea.com/aldsp/docs30/code/AdvancedAPISamples.zip Right-click in the Project Explorer and choose Import. Expand General, select Existing Projects into Workspace, and click Next. Importing Existing Projects into the Workspace Click Select archive file, click Browse, and open the `DspClientSamples_All.zip` file. Selecting the Sample Dataspace Archive Click Finish. Workshop for WebLogic imports the sample dataspace projects. ### Adding the Mediator Client JAR Files To add your mediator client JAR files to the projects: In the project explorer copy the mediator client JAR files you generated earlier (`RetailDataspace-dsp-client.jar` and `RetailDataspace-ws-client.jar`) to the following folder:
       DSPClientSamplesStatic1/WebContent/WEB-INF/lib
Click Yes To All when prompted to overwrite the existing files. Right-click the `DSPClientSamplesStatic1` dataspace project, and click Refresh. ### Setting the Java Build Paths You need to set the Java build paths to include the specific JAR files required by the projects.
| You need to specify the Java build path for all four dataspace projects: DSPClientSamplesStatic1 DSPClientSamplesDynamic1 DSPClientSamplesControlStatic DSPClientSamplesControlDynamic
1. To set the Java build path: In Project Explorer right-click the dataspace project you have selected, then choose:
       Build Path > Configure Build Path
A dialog appears displaying the properties for the dataspace project. Click the Libraries tab. ##### Configuring the Build Path Click Add External JARs, then locate and select the indentifed JAR files. Click Open. Click OK. The following table identifies the necessary JAR files and their location for each advanced sample dataspace project. (The `ld-client.jar` file is needed by all four projects.) ##### Project, Required JAR Files, and Location
Dataspace Project | JAR File | Path
DSPClientSamplesControlDynamic | ld-client.jar com.bea.core.sdo.1.0.0.0.jar | <ALDSP_HOME>/lib <BEA_HOME>/modules
DSPClientSamplesControlStatic | ld-client.jar com.bea.core.sdo.1.0.0.0.jar | <ALDSP_HOME>/lib <BEA_HOME>/modules
DSPClientSamplesDynamic1 | ld-client.jar weblogic.jar | <ALDSP_HOME>/lib <BEA_HOME>/wlserver_10.3/server/lib
DSPClientSamplesStatic1 | ld-client.jar api.jar weblogic.jar | <ALDSP_HOME>/lib <BEA_HOME>/wlserver_10.3/server/lib <BEA_HOME>/wlserver_10.3/server/lib
| When configuring the path for the Oracle Data Service Integrator control dataspace projects, you may notice duplicate entries for `ld-client.jar` and `com.bea.sdo.1.0.0.0.jar`. If so, retain only the file associated with the location in the above table.
3. ### Setting the Run Configurations You need to create a run configuration for the following projects: DSPClientSamplesDynamic1 DSPClientSampleStatic1 #### Setting the Run Configuration for DSPClientSamplesDynamic1 To set the run configuration for `DSPClientSamplesDynamic1`: Right-click `DSPClientSamplesDynamic1` in the Project Explorer and choose Run As > Run. The Run dialog appears. Right-click Java Application, choose New, and type `Dynamic` as the name of the new run configuration. Configuring the Run Configuration Main Class Enter the following in the Main class field:
       client.java_and_ws.dynamic.RunClients
4. Click Apply. Click the Classpath tab. ##### Configuring the Run Configuration Classpath Select Bootstrap Entries > WebLogic System Libraries, and click Remove (if the WebLogic System Libraries entry is present). Select User Entries Click Add External JARs Navigate to:
       <BEA_HOME>/wlserver_10.3/server/lib
3. select the `api.jar` file, and click Open. Click Apply. Click Close. #### Setting the Run Configuration for DSPClientSamplesStatic1 To set the run configuration for `DSPClientSamplesStatic1`: Right-click `DSPClientSamplesStatic1` in the Project Explorer and choose Run As > Run. The Run dialog appears. Right-click Java Application, choose New, and type Static as the name of the new run configuration. Configuring the Run Configuration Main Class Enter the following in the Main class field:
       client.java_and_ws.static0.RunClients
- Click Apply. Click Close. ## Related Topics ##### How Tos Call ALDSP Using the Java Mediator API, Web Services, and DSP Controls Running the Mediator API Sample Projects ##### Reference Understanding the Advanced Static Mediator API Sample Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## How To Run the Mediator API Sample Projects This topic describes how to run the Mediator API sample projects. ##### Topic Map How To Run the Mediator API Sample Projects Running the Standalone Samples Using the Custom Run Configuration Running the Sample Controls Using "Run on Server" Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Running the Standalone Samples Using the Custom Run Configuration You can run the following standalone Mediator API sample projects using a custom configuration: `DSPClientSamplesStatic1` `DSPClientSamplesDynamic1`
  | How to Set Up the Sample Applications
2. Here are the instructions for running the static ALDSP client API sample: Launch Workshop for WebLogic. Verify that the server is started and the RetailDataspace sample project is deployed.
   | If an unexpected problem is flagged in the Project Explorer, try the Clean project option
       Project > Clean
3. Make sure the Console window is open:
       Window > Show View > Other > Console
Right-click on DSPClientSamplesStatic1 and choose Run As > Run. Expand Java Application and select the Static run configuration. Click Run. You can run the DSPClientSamplesDynamic1 sample using the steps shown above. ##### Selecting the Run Configuration The sample project includes an optional parameter enabling you to choose the following client types: Use `java` or do not set the parameter to have the sample project use the Mediator API. Use `webservice` to have the sample project use the Web Service Mediator API. The parameter can be specified in the Arguments tab as a program argument such as:
    webservice
##### Specifying an Argument The results appear in the Console Window. ##### Console After Running Static Mediator Sample with webservice Parameter #### Running the Sample Controls Using "Run on Server" You can run the Mediator API sample controls using the "Run on Server" option.
| If you see "Missing Struts Module Configuration" when trying to run the Mediator API sample controls, it is likely because you need to install Workshop for WebLogic 10.3 (in addition to what comes with the Oracle Data Service Integrator installer). You can download Workshop for WebLogic 10.3 at http://commerce.bea.com/showproduct.jsp?family=WLW&major=10.2&minor=0
To run the sample projects: Launch Workshop for WebLogic. Verify that the server is started and the RetailDataspace sample project is deployed. Right-click the dataspace project and choose Run As > Run on Server. ##### Selecting the Server Select the server and click Next. ##### Adding the Project Add the required project, and click Finish. You can specify an optional parameter to use the Mediator API or Web Services Mediator API. ## Related Topics ##### How Tos Advanced API Samples - Mediator, Web Services, and DSP Controls Setting Up the Advanced API Sample Projects ##### Reference Understanding the Advanced Static Mediator API Sample Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## Static Mediator API Code Reference This topic describes the advanced sample project that uses the Static Mediator API to call data service operations from client applications using a variety of argument and return types.
| Source: DSPClientSamplesStatic1/JavaResources/client.java_and_ws.static0
#### Topic Map Static Mediator API Code Reference Using a Complex Argument Using a Complex Argument List Using a Complex Argument with Create-Read-Update-Delete Operations Returning a Simple Element Including Auditing Using Filters Related Topics ### Using a Complex Argument You can call data service operations using a complex argument type. The example in this section creates a `profileService` object and populates the object with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the complex argument, which retrieves the CASE information through the identically-named Oracle Data Service Integrator operation.
| Source: `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientComplexArg.java`
##### Calling an Operation Using a Complex Argument
    retailer.PROFILE_SERVICE profileService =(retailer.PROFILE_SERVICE)factory.create(retailer.PROFILE_SERVICE.class );

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    if(isWebServiceClient()){
       dasResult = wsDas.getServiceCase(profileService);
    } else {
       dasResult = ejbDas.getServiceCase(profileService);
    }
### Using a Complex Argument List You can call data service operations using an argument consisting of a list of complex types. The example in this section creates two `profileService` objects and populates the objects with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the argument consisting of the list of complex objects, retrieving the CASE information through the identically-named Oracle Data Service Integrator operation.
| Source: `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientComplexArgList.java`
##### Calling an Operation Using a List of Complex Arguments
    retailer.PROFILE_SERVICES profileService =(retailer.PROFILE_SERVICES)factory.create("urn:retailer", "PROFILE_SERVICES");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILES");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER6");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    if(isWebServiceClient()){
       dasResult = wsDas.getServiceCases(profileService);
    } else {
       dasResult = ejbDas.getServiceCases(profileService);
    }
### Using a Complex Argument with Create-Read-Update-Delete Operations You can call multiple Oracle Data Service Integrator data service operations, each with a complex argument type, to perform a series of tasks including invoking create, read, update, and delete operations in the data service. The example in this section creates two `profileService` objects and populates the objects with "dummy" customer information using type-safe setter methods. The sample then calls the `getCustomerByCustID` method using a complex argument and checks whether the customer information is already stored. If not, the sample calls the `createPROFILE` method to create the customer profile. If a record already exists for the customer, the sample calls the `updatePROFILE` method to store the new information in the `profileService` object. If an existing record does not match, the sample calls the `deletePROFILE` method to remove the customer profile.
| Source: `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientComplexArgs_andCRUD.java`
##### Calling Multiple Operations Using Complex Arguments
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService1,	"urn:retailer", "PROFILE");

    profileServices[0]=profileService1;

    retailertype.PROFILE_TYPE profile1 = profileService1.createPROFILE();
    profile1.setCustomerID("CUSTOMER44");
    profile1.setFirstName("dummyFirstName");
    profile1.setLastName("dummyLastName44");
    profile1.setCustomerSince( "2001-01-01");
    profile1.setEmailAddress( "dummyEmailAddress");
    profile1.setTelephoneNumber("8885551212");

    retailer.PROFILE_SERVICE profileService2 =(retailer.PROFILE_SERVICE)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService2, "urn:retailer", "PROFILE");

    profileServices[1]=profileService2;
    retailertype.PROFILE_TYPE profile2 = profileService2.createPROFILE();
    profile2.setCustomerID("CUSTOMER55");
    profile2.setFirstName("dummyFirstName");
    profile2.setLastName("dummyLastName55");
    profile2.setCustomerSince( "2001-01-01");
    profile2.setEmailAddress( "dummyEmailAddress");
    profile2.setTelephoneNumber("8885551212");

    if(isWebServiceClient()){
       dasResult = wsDas.getCustomerByCustID("CUSTOMER44");
    } else {
       dasResult = ejbDas.getCustomerByCustID("CUSTOMER44");
    }

    if(!dasResult.hasNext()) {
       out("ADDING: ");

       if(isWebServiceClient()) {
          dasKey = wsDas.createPROFILE(profileServices);
       } else {
          dasKey = ejbDas.createPROFILE(profileServices);
       }

       while( dasKey.hasNext()){
          out("DataObject : " + dataObjectToString(xh, dasKey.next()));
       }

    } else {
       retailer.PROFILE_SERVICE dObj= dasResult.next();

       if("dummyLastName44".equals(dObj.get("PROFILE/LastName"))){
          out("UPDATING: ");
          out("DataObject : " + dataObjectToString(xh,dObj));
          com.bea.dsp.sdo.SDOUtil.enableChanges(dObj);
          dObj.set("PROFILE/LastName", "Smith");
          if(isWebServiceClient()){
             wsDas.updatePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          } else {
             ejbDas.updatePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          }
       } else {
          out("DELETING: ");
          out("DataObject : " + dataObjectToString(xh,dObj));

          if(isWebServiceClient()){
             wsDas.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          } else {
             ejbDas.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          }

          if(isWebServiceClient()){
             dasResult = wsDas.getCustomerByCustID("CUSTOMER55");
          } else {
             dasResult = ejbDas.getCustomerByCustID("CUSTOMER55");
          }

          if(dasResult.hasNext()){
             dObj=dasResult.next();
             out("DataObject : " + dataObjectToString(xh,dObj));
             if(isWebServiceClient()){
                wsDas.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
             } else {
             ejbDas.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
             }
          }
       }
    }
### Returning a Simple Element You can call Oracle Data Service Integrator data service operations that return simple types. The example in this section determines the number of orders by calling the `getOrderCount` and `getOrderCounts` methods and assigning the results to variables of type `java.math.BigInteger`.
| Source: `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientSimpleReturn.java`
##### Calling an Operation that Returns a Simple Type
    java.math.BigInteger count;
    if(isWebServiceClient()){
       count = wsDas.getOrderCount("CUSTOMER4");
    } else {
       count = ejbDas.getOrderCount("CUSTOMER4");
    }

    out("DataObject : " + count);

    if(isWebServiceClient()){
       dasResult = wsDas.getOrderCounts("CUSTOMER4");
    } else {
       dasResult = ejbDas.getOrderCounts("CUSTOMER4");
    }

    while( dasResult.hasNext()){
       java.math.BigInteger theCount = (java.math.BigInteger) dasResult.next();
       out("DataObject : " + theCount);
    }
### Including Auditing You can audit calls to Oracle Data Service Integrator data service operations and later retrieve the audit information for further processing. The example in this section creates a RequestConfig object and enables the data service audit feature (RETURN_DATA_SERVICE_AUDIT). After enabling audit, the example includes the instance of the RequestConfig object as an argument when calling methods corresponding to data service operations. The example then retrieves the audit records and iterates through the results to output for display.
| Source: `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientWithAudit.java`
##### Auditing Operations
    com.bea.dsp.RequestConfig reqConfig = new com.bea.dsp.RequestConfig();
    reqConfig.enableFeature(com.bea.dsp.RequestConfig.RETURN_DATA_SERVICE_AUDIT);
    reqConfig.setStringArrayAttribute(com.bea.dsp.RequestConfig.RETURN_AUDIT_PROPERTIES, attributes);

    if(isWebServiceClient()){
       dasResult = wsDas.getCustomerByLoginID("Steve", reqConfig);
    } else {
       dasResult = ejbDas.getCustomerByLoginID("Steve", reqConfig);
    }

    com.bea.ld.DataServiceAudit dsAudit = reqConfig.retrieveDataServiceAudit();
    if (dsAudit != null) {
       List l = dsAudit.getAllRecords();
       for (Iterator it = l.iterator(); it.hasNext();) {
          com.bea.ld.DSPAuditRecord auditRec = (com.bea.ld.DSPAuditRecord) it.next();
          Map propMap = auditRec.getAuditProperties();
          for (Iterator pit = propMap.keySet().iterator(); pit.hasNext();) {
             String key = (String) pit.next();
             out("Audit Information: " + key + " = " + propMap.get(key));
          }
       }
    }

    while( dasResult.hasNext()){
       out("DataObject : " + dataObjectToString(xh,(retailer.PROFILE_SERVICE)dasResult.next()));
    }
### Using Filters You can filter the results of calls to data service operations using the Oracle Data Service Integrator RequestConfig. The example in this section creates an instance of the `RequestConfig` object and then defines a filter based on the customer ID. After defining the filter, the example sets the filter on the `RequestConfig` object and passes the instance of `RequestConfig` as an argument when calling the method corresponding to data service operation.
| You can find the source code for this sample project in the `DSPClientSamplesStatic1/Java Resources/src/client.java_and_ws.static0/ClientWithAudit.java` file.
##### Filtering Based on an Identifier
    reqConfig = new com.bea.dsp.RequestConfig();
    com.bea.ld.filter.FilterXQuery filter=new com.bea.ld.filter.FilterXQuery();

    filter.addFilter("PROFILE","PROFILE/PROFILE/CustomerID","=","$customerID");
    com.bea.ld.ExternalVariables externalVariables=new com.bea.ld.ExternalVariables();
    externalVariables.setString(new javax.xml.namespace.QName("customerID"), "CUSTOMER5");
    filter.setExternalVariables(externalVariables);

    /* Alteratively, filter with a hard-coded value */

    // filter.addFilter("PROFILE", "PROFILE/PROFILE/CustomerID","=","CUSTOMER5");

    reqConfig.setFilter(filter);
    try {
       if(isWebServiceClient()){
          dasResult = wsDas.getProfile(reqConfig);
       } else {
          dasResult = ejbDas.getProfile(reqConfig);
       }
    }
## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## Dynamic Mediator API Code Reference This topic describes the advanced sample project that uses the Dynamic Mediator API to call Oracle Data Service Integrator data service operations from client applications using a variety of argument and return types.
| You can find the Java source code for this sample dataspace project in the `DSPClientSamplesDynamic1/JavaResources/client.java_and_ws.dynamic` folder.
#### Topic Map Dynamic Mediator API Code Reference Using a Complex Argument Using a Complex Argument List Using a Complex Argument with Create-Read-Update-Delete Operations Returning a Simple Element Including Auditing Using Filters Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Using a Complex Argument You can invoke Oracle Data Service Integrator data service operations using a complex argument type. The example in this section creates a `profileService` object and populates the object with customer information using the `set` method. The sample then invokes the `getServiceCase` method using the complex argument, which retrieves the CASE information through the identically-named Oracle Data Service Integrator operation.
| Source: `DSPClientSamplesDynamic1/Java Resources/src/client.java_and_ws.dynamic/ClientComplexArg.java`
##### Invoking an Operation Using a Complex Argument
    commonj.sdo.DataObject profileService = factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    commonj.sdo.DataObject profile = profileService.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER4");

    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getServiceCase", new Object[] { profileService });
### Using a Complex Argument List You can invoke Oracle Data Service Integrator data service operations using an argument consisting of a list of complex types. The example in this section creates two `profileService` objects and populates the objects with customer information using the `set` method. The sample then invokes the `getServiceCase` method using the argument consisting of the list of complex objects, retrieving the CASE information through the identically-named Oracle Data Service Integrator operation.
| Source: `DSPClientSamplesDynamic1/Java Resources/``src/``client.java_and_ws.dynamic/ClientComplexArgList.java`
##### Invoking an Operation Using a List of Complex Arguments
    profileServices = factory.create("urn:retailer", "PROFILE_SERVICES");

    com.bea.dsp.sdo.SDOUtil.setElementName(profileServices, "urn:retailer", "PROFILES");
    profile = profileServices.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER4");
    profile.set("FirstName", "dummyFirstName4");
    profile.set("LastName", "dummyLastName4");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    profile = profileServices.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER6");
    profile.set("FirstName", "dummyFirstName6");
    profile.set("LastName", "dummyLastName6");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getServiceCases", new Object[] { profileServices });
### Using a Complex Argument with Create-Read-Update-Delete Operations You can invoke multiple Oracle Data Service Integrator data service operations, each with a complex argument type, to perform a series of tasks including invoking create, read, update, and delete operations in the data service. The example in this section creates two `profileService` objects and populates the objects with "dummy" customer information using the `setElementName` method. The sample then invokes the `getCustomerByCustID` method using a complex argument and checks whether the customer information is already stored. If not, the sample calls the `createPROFILE` method to create the customer profile. If a record already exists for the customer, the sample calls the `updatePROFILE` method to store the new information in the `profileService` object. If an existing record does not match, the sample calls the `deletePROFILE` method to remove the customer profile.
| Source: `DSPClientSamplesDynamic1/Java Resources/``src/``client.java_and_ws.dynamic/ClientComplexArgs_andCRUD.java`
##### Invoking Multiple Operations Using Complex Arguments
    profileService = factory.create("urn:retailer", "PROFILE_SERVICE");
    profileServices.add(profileService);
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    profile1 = profileService.createDataObject("PROFILE");
    profile1.set("CustomerID", "CUSTOMER44");
    profile1.set("FirstName", "dummyFirstName44");
    profile1.set("LastName", "dummyLastName44");
    profile1.set("CustomerSince", "2001-01-01");
    profile1.set("EmailAddress", "dummyEmailAddress");
    profile1.set("TelephoneNumber", "8885551212");

    profileService = factory.create("urn:retailer", "PROFILE_SERVICE");
    profileServices.add(profileService);
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    profile2 = profileService.createDataObject("PROFILE");
    profile2.set("CustomerID", "CUSTOMER55");
    profile2.set("FirstName", "dummyFirstName55");
    profile2.set("LastName", "dummyLastName55");
    profile2.set("CustomerSince", "2001-01-01");
    profile2.set("EmailAddress", "dummyEmailAddress");
    profile2.set("TelephoneNumber", "8885551212");

    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getCustomerByCustID", new Object[] { "CUSTOMER44" });

    if(!dasResult.hasNext()) {
       out("ADDING: ");

       dasResult = (com.bea.dsp.das.DASResult) das.invoke("createPROFILE", new Object[] { profileServices.toArray() });

       while( dasResult.hasNext()) {
          out("DataObject : " + dataObjectToString(xh,(commonj.sdo.DataObject)dasResult.next()));
       }

    } else {
       commonj.sdo.DataObject dObj=(commonj.sdo.DataObject)dasResult.next();
       if("dummyLastName44".equals(dObj.get("PROFILE/LastName"))) {
          out("UPDATING: ");
          out("DataObject : " + dataObjectToString(xh,dObj));
          com.bea.dsp.sdo.SDOUtil.enableChanges(dObj);
          dObj.set("PROFILE/LastName", "Smith");
          dasResult = (com.bea.dsp.das.DASResult) das.invoke("updatePROFILE", new Object[] { dObj });
       } else {
          out("DELETING: ");
          out("DataObject : " + dataObjectToString(xh,dObj));
          dasResult = (com.bea.dsp.das.DASResult) das.invoke("deletePROFILE", new Object[] { dObj });
          dasResult = (com.bea.dsp.das.DASResult) das.invoke("getCustomerByCustID", new Object[] { "CUSTOMER55" });

          if(dasResult.hasNext()) {
             dObj=(commonj.sdo.DataObject)dasResult.next();
             out("DataObject : " + dataObjectToString(xh,dObj));
             dasResult = (com.bea.dsp.das.DASResult) das.invoke("deletePROFILE", new Object[] { dObj });
          }
       }
    }
### Returning a Simple Element You can invoke Oracle Data Service Integrator data service operations that return simple types. The example in this section determines the number of orders by invoking the `getOrderCount` and `getOrderCounts` methods and assigning the results to variables of type `java.math.BigInteger`.
| Source: `DSPClientSamplesDynamic1/Java Resources/``src/``client.java_and_ws.dynamic/ClientSimpleReturn.java`
##### Invoking an Operation that Returns a Simple Type
    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getOrderCount", new Object[] {"CUSTOMER4"});

    while( dasResult.hasNext()) {
       java.math.BigInteger count = (java.math.BigInteger) dasResult.next();
       out("DataObject : " + count);
    }

    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getOrderCounts", new Object[] {"CUSTOMER4"});

    while( dasResult.hasNext()) {
       java.math.BigInteger count = (java.math.BigInteger) dasResult.next();
       out("DataObject : " + count);
    }
### Including Auditing You can audit calls to Oracle Data Service Integrator data service operations and later retrieve the audit information for further processing. The example in this section creates a RequestConfig object and enables the data service audit feature (RETURN_DATA_SERVICE_AUDIT). After enabling audit, the example includes the instance of the RequestConfig object as an argument when invoking methods corresponding to data service operations. The example then retrieves the audit records and iterates through the results to output for display.
| Source: `DSPClientSamplesDynamic1/Java Resources/``src/``client.java_and_ws.dynamic/ClientWithAudit.java`
##### Auditing Operations
    com.bea.dsp.RequestConfig reqConfig = new com.bea.dsp.RequestConfig();
    reqConfig.enableFeature(com.bea.dsp.RequestConfig.RETURN_DATA_SERVICE_AUDIT);
    reqConfig.setStringArrayAttribute(com.bea.dsp.RequestConfig.RETURN_AUDIT_PROPERTIES, attributes);

    dasResult = (com.bea.dsp.das.DASResult) das.invoke("getCustomerByLoginID", new Object[] { "Steve" }, reqConfig);

    com.bea.ld.DataServiceAudit dsAudit = reqConfig.retrieveDataServiceAudit();
    if (dsAudit != null) {
       List l = dsAudit.getAllRecords();
       for (Iterator it = l.iterator(); it.hasNext();) {
          com.bea.ld.DSPAuditRecord auditRec = (com.bea.ld.DSPAuditRecord) it.next();
          Map propMap = auditRec.getAuditProperties();
          for (Iterator pit = propMap.keySet().iterator(); pit.hasNext();) {
             String key = (String) pit.next();
             out("Audit Information: " + key + " = " + propMap.get(key));
          }
       }
    }

    while( dasResult.hasNext()) {
       out("DataObject : " + dataObjectToString(xh,(commonj.sdo.DataObject)dasResult.next()));
    }
### Using Filters You can filter the results of calls to data service operations using the Oracle Data Service Integrator RequestConfig. The example in this section creates an instance of the `RequestConfig` object and then defines a filter based on the customer ID. After defining the filter, the example sets the filter on the `RequestConfig` object and passes the instance of `RequestConfig` as an argument when invoking the method corresponding to data service operation.
| Source: `DSPClientSamplesDynamic1/Java Resources/``src/``client.java_and_ws.dynamic/ClientWithAudit.java`
##### Filtering Based on an Identifier
    reqConfig = new com.bea.dsp.RequestConfig();
    com.bea.ld.filter.FilterXQuery filter=new com.bea.ld.filter.FilterXQuery() ;

    filter.addFilter("PROFILE","PROFILE/PROFILE/CustomerID","=","$customerID");
    com.bea.ld.ExternalVariables externalVariables=new com.bea.ld.ExternalVariables();
    externalVariables.setString(new javax.xml.namespace.QName("customerID"), "CUSTOMER5");
    filter.setExternalVariables(externalVariables);

    /* Or filter with hard-coded value */

    // filter.addFilter("PROFILE","PROFILE/PROFILE/CustomerID","=","CUSTOMER5");

    reqConfig.setFilter(filter);
    try {
       dasResult = das.invoke("getProfile", new Object[] {}, reqConfig);
    }
## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## Oracle Data Service Integrator Control Static Mediator API Code Reference This topic describes the advanced sample project that uses the Static Mediator API to call data service operations from Oracle Data Service Integrator Controls using a variety of argument and return types.
| Source: `DSPClientSamplesControlStatic/Java Resources/src/dspControl/DspControlController.java`
#### Topic Map Oracle Data Service Integrator Control Static Mediator API Code Reference Using a Complex Argument Using a Complex Argument List Using a Complex Argument with Create-Read-Update-Delete Operations Returning a Simple Element Including Auditing Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Using a Complex Argument You can call Oracle Data Service Integrator data service operations using a complex argument type. The example in this section creates a `profileService` object and populates the object with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the complex argument, which retrieves the CASE information through the identically-named Oracle Data Service Integrator operation. ##### Calling an Operation Using a Complex Argument
    retailer.PROFILE_SERVICE profileService = (retailer.PROFILE_SERVICE)factory.create(retailer.PROFILE_SERVICE.class );

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    retailer.CASE_SERVICE[] cases=DSPControlFile.getServiceCase(profileService);
### Using a Complex Argument List You can call Oracle Data Service Integrator data service operations using an argument consisting of a list of complex types. The example in this section creates two `profileService` objects and populates the objects with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the argument consisting of the list of complex objects, retrieving the CASE information through the identically-named Oracle Data Service Integrator operation. ##### Calling an Operation Using a List of Complex Arguments
    retailer.PROFILE_SERVICES profileService =(retailer.PROFILE_SERVICES)factory.create("urn:retailer", "PROFILE_SERVICES");

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILES");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER6");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    retailer.CASE_SERVICE[] cases = DSPControlFile.getServiceCases(profileService);
### Using a Complex Argument with Create-Read-Update-Delete Operations You can call multiple Oracle Data Service Integrator data service operations, each with a complex argument type, to perform a series of tasks including calling create, read, update, and delete operations in the data service. The example in this section creates two `profileService` objects and populates the objects with "dummy" customer information using type-safe setter methods. The sample then calls the `getCustomerByCustID` method using a complex argument and checks whether the customer information is already stored. If not, the sample calls the `createPROFILE` method to create the customer profile. If a record already exists for the customer, the sample calls the `updatePROFILE` method to store the new information in the `profileService` object. If an existing record does not match, the sample calls the `deletePROFILE` method to remove the customer profile. ##### Calling Multiple Operations Using Complex Argument
    retailer.PROFILE_SERVICE[] profileServices = new retailer.PROFILE_SERVICE[2];

    retailer.PROFILE_SERVICE profileService1 =(retailer.PROFILE_SERVICE)factory.create("urn:retailer", "PROFILE_SERVICE");

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService1, "urn:retailer", "PROFILE");

    profileServices[0]=profileService1;

    retailertype.PROFILE_TYPE profile1 = profileService1.createPROFILE();
    profile1.setCustomerID("CUSTOMER44");
    profile1.setFirstName("dummyFirstName");
    profile1.setLastName("dummyLastName44");
    profile1.setCustomerSince( "2001-01-01");
    profile1.setEmailAddress( "dummyEmailAddress");
    profile1.setTelephoneNumber("8885551212");

    retailer.PROFILE_SERVICE profileService2 =(retailer.PROFILE_SERVICE)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService2, "urn:retailer", "PROFILE");

    profileServices[1]=profileService2;
    retailertype.PROFILE_TYPE profile2 = profileService2.createPROFILE();
    profile2.setCustomerID("CUSTOMER55");
    profile2.setFirstName("dummyFirstName");
    profile2.setLastName("dummyLastName55");
    profile2.setCustomerSince( "2001-01-01");
    profile2.setEmailAddress( "dummyEmailAddress");
    profile2.setTelephoneNumber("8885551212");

    retailer.PROFILE_SERVICE[] returnedProfileServices=DSPControlFile.getCustomerByCustID("CUSTOMER44");

    outputString="";
    if(returnedProfileServices.length==0) {
       outputString=outputString +"ADDING: \n";
       DSPControlFile.createPROFILE(profileServices);
       outputString=outputString + dataObjectsToString(profileServices);
    } else {
       retailer.PROFILE_SERVICE dObj= returnedProfileServices[0];
       if("dummyLastName44".equals(dObj.get("PROFILE/LastName"))) {
          outputString=outputString +"UPDATING: \n";
          outputString=outputString + dataObjectsToString(profileServices);
          com.bea.dsp.sdo.SDOUtil.enableChanges(dObj);
          dObj.set("PROFILE/LastName", "Smith");
          DSPControlFile.updatePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
       } else {
          outputString=outputString +"DELETING: \n";
          outputString=outputString + dataObjectsToString(returnedProfileServices);

          DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          returnedProfileServices=DSPControlFile.getCustomerByCustID("CUSTOMER55");

          if(returnedProfileServices.length>0) {
             dObj = returnedProfileServices[0];
             outputString=outputString + dataObjectsToString(returnedProfileServices);
             DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          }
       }
    }
### Returning a Simple Element You can call Oracle Data Service Integrator data service operations that return simple types. The example in this section determines the number of orders by calling the `getOrderCount` and `getOrderCounts` methods and assigning the results to variables of type `java.math.BigInteger`. ##### Calling an Operation that Returns a Simple Type
    java.math.BigInteger count = DSPControlFile.getOrderCount("CUSTOMER4");
    outputString=outputString + dataObjectsToString(new Object[]{count});
    java.math.BigInteger[] counts = DSPControlFile.getOrderCounts("CUSTOMER4");
    outputString=outputString + dataObjectsToString(counts);
### Including Auditing You can audit calls to Oracle Data Service Integrator data service operations and later retrieve the audit information for further processing. The example in this section creates a `RequestConfig` object and enables the data service audit feature (RETURN_DATA_SERVICE_AUDIT). After enabling audit, the example includes the instance of the `RequestConfig` object as an argument when calling methods corresponding to data service operations. The example then retrieves the audit records and iterates through the results to output for display. ##### Auditing Operations
    com.bea.dsp.RequestConfig reqConfig = new com.bea.dsp.RequestConfig();
    reqConfig.enableFeature(com.bea.dsp.RequestConfig.RETURN_DATA_SERVICE_AUDIT);
    reqConfig.setStringArrayAttribute(com.bea.dsp.RequestConfig.RETURN_AUDIT_PROPERTIES, attributes);

    retailer.PROFILE_SERVICE profileService[] = DSPControlFile.getCustomerByLoginID("Steve", reqConfig);
    outputString=dataObjectsToString(profileService);

    com.bea.ld.DataServiceAudit dsAudit = reqConfig.retrieveDataServiceAudit();
    if (dsAudit != null) {
       List l = dsAudit.getAllRecords();
       for (Iterator it = l.iterator(); it.hasNext();) {
          com.bea.ld.DSPAuditRecord auditRec = (com.bea.ld.DSPAuditRecord) it.next();
          Map propMap = auditRec.getAuditProperties();
          for (Iterator pit = propMap.keySet().iterator(); pit.hasNext();) {
             String key = (String) pit.next();
             outputString=outputString + "Audit Information: " + key + " = " + propMap.get(key)+"\n";
          }
       }
    }
## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Dynamic Mediator API Code Reference ## Oracle Data Service Integrator Control Dynamic Mediator API Code Reference This topic the advanced sample project that uses the Dynamic Mediator API to invoke data service operations from Oracle Data Service Integrator Controls using a variety of argument and return types.
| Source: `DSPClientSamplesControlDynamic/Java Resources/src/dspControl/DspControlController.java`
#### Topic Map Oracle Data Service Integrator Control Dynamic Mediator API Code Reference Using a Complex Argument Using a Complex Argument List Using a Complex Argument with Create-Read-Update-Delete Operations Returning a Simple Element Including Auditing Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Using a Complex Argument You can invoke Oracle Data Service Integrator data service operations using a complex argument type. The example in this section creates a `profileService` object and populates the object with customer information using the `set` method. The sample then creates a query to call the `getServiceCase` operation, using the complex argument, to retrieve the CASE information. ##### Calling an Operation Using a Complex Argument
    commonj.sdo.DataObject profileService =(commonj.sdo.DataObject)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    commonj.sdo.DataObject profile = profileService.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER4");
    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    com.bea.ld.ExternalVariables extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("profile"), dataObject2String(xh,profileService), true);
    StringBuffer query=new StringBuffer();
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("declare namespace retailer='urn:retailer';\n");
    query.append("declare variable $profile as element(retailer:PROFILE) external;\n");
    query.append("tns:getServiceCase($profile)");
    Object[] cases=DSPControlFile.executeQuery(query.toString(), extVariables);
### Using a Complex Argument List You can invoke Oracle Data Service Integrator data service operations using an argument consisting of a list of complex types. The example in this section creates two `profileService` objects and populates the objects with customer information using the `set` method. The sample then creates a query to call the `getServiceCase` operation, using the argument consisting of the list of complex objects, to retrieve the CASE information. ##### Invoking an Operation Using a List of Complex Arguments
    commonj.sdo.DataObject profileService =(commonj.sdo.DataObject)factory.create("urn:retailer", "PROFILE_SERVICES");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILES");
    commonj.sdo.DataObject profile = profileService.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER4");
    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    profile = profileService.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER6");
    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    com.bea.ld.ExternalVariables extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("profiles"), dataObject2String(xh,profileService), true);
    StringBuffer query=new StringBuffer();
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("declare namespace retailer='urn:retailer';\n");
    query.append("declare variable $profiles as element(retailer:PROFILES) external;\n");
    query.append("tns:getServiceCases($profiles)");
    Object[] cases=DSPControlFile.executeQuery(query.toString(), extVariables);
### Using a Complex Argument with Create-Read-Update-Delete Operations You can invoke multiple Oracle Data Service Integrator data service operations, each with a complex argument type, to perform a series of tasks including invoking create, read, update, and delete operations in the data service. The example in this section creates two `profileService` objects and populates the objects with "dummy" customer information using the `set` method. The sample then creates a query to call the `getCustomerByCustID` operation using a complex argument and checks whether the customer information is already stored. If not, the sample creates a query to call the `createPROFILE` operation to create the customer profile. If a record already exists for the customer, the sample creates a query to call the `updatePROFILE` operation to store the new information in the `profileService` object. If an existing record does not match, the sample creates a query to call the `deletePROFILE` operation to remove the customer profile. ##### Invoking Multiple Operations Using Complex Arguments
    retailer.PROFILE_SERVICE[] profileServices = new retailer.PROFILE_SERVICE[2];
    commonj.sdo.DataObject profileService1 =(commonj.sdo.DataObject)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService1, "urn:retailer", "PROFILE");
    profileServices[0]=(retailer.PROFILE_SERVICE)profileService1;

    commonj.sdo.DataObject profile = profileService1.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER44");
    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName44");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    commonj.sdo.DataObject profileService2 =(commonj.sdo.DataObject)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService2, "urn:retailer", "PROFILE");

    profileServices[1]=(retailer.PROFILE_SERVICE)profileService2;

    profile = profileService2.createDataObject("PROFILE");
    profile.set("CustomerID", "CUSTOMER55");
    profile.set("FirstName", "dummyFirstName");
    profile.set("LastName", "dummyLastName55");
    profile.set("CustomerSince", "2001-01-01");
    profile.set("EmailAddress", "dummyEmailAddress");
    profile.set("TelephoneNumber", "8885551212");

    StringBuffer query=new StringBuffer();
    query.append("declare variable $customerId as xs:string external;\n");
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("tns:getCustomerByCustID($customerId)");
    com.bea.ld.ExternalVariables extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("customerId"), "CUSTOMER44", true);
    Object[] returnedProfileServices=DSPControlFile.executeQuery(query.toString(), extVariables );

    outputString="";
    if(returnedProfileServices.length==0) {
       outputString=outputString +"ADDING: \n";

       /*
       extVariables=new com.bea.ld.ExternalVariables();
       extVariables.setElement(new javax.xml.namespace.QName("profile"), dataObject2String(xh,profileServices), true);
       query=new StringBuffer();
       query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
       query.append("declare namespace retailer='urn:retailer';\n");
       query.append("declare variable $profile as element(retailer:PROFILE)* external;\n");
       query.append("tns:createPROFILE($profile)");
       returnedProfileServices=DSPControlFile.executeProcedure(query.toString(), extVariables);
       */

       returnedProfileServices=DSPControlFile.createPROFILE(profileServices);
       outputString=outputString + dataObjectsToString(returnedProfileServices);
    } else {
       commonj.sdo.DataObject dObj= (commonj.sdo.DataObject)returnedProfileServices[0];
       if("dummyLastName44".equals(dObj.get("PROFILE/LastName"))){
          outputString=outputString +"UPDATING: \n";
          outputString=outputString + dataObjectsToString(profileServices);
          com.bea.dsp.sdo.SDOUtil.enableChanges(dObj);
          dObj.set("PROFILE/LastName", "Smith");
          DSPControlFile.updatePROFILE(new retailer.PROFILE_SERVICE[]{(retailer.PROFILE_SERVICE)dObj});

          /*
          extVariables=new com.bea.ld.ExternalVariables();
          extVariables.setElement(new javax.xml.namespace.QName("profile"), dataObject2String(xh,dObj), true);
          query=new StringBuffer();
          query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
          query.append("declare namespace retailer='urn:retailer';\n");
          query.append("declare variable $profile as changed-element(retailer:PROFILE)* external;\n");
          query.append("tns:updatePROFILE($profile)");
          DSPControlFile.executeProcedure(query.toString(), extVariables);
          */

       } else {
          outputString=outputString +"DELETING: \n";
          outputString=outputString + dataObjectsToString(returnedProfileServices);
          DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{(retailer.PROFILE_SERVICE)dObj});

          /*
          extVariables=new com.bea.ld.ExternalVariables();
          extVariables.setElement(new javax.xml.namespace.QName("profile"), dataObject2String(xh,returnedProfileServices), true);
          query=new StringBuffer();
          query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
          query.append("declare namespace retailer='urn:retailer';\n");
          query.append("declare variable $profile as element(retailer:PROFILE)* external;\n");
          query.append("tns:deletePROFILE($profile)");
          DSPControlFile.executeProcedure(query.toString(), extVariables);
          */

          query=new StringBuffer();
          query.append("declare variable $customerId as xs:string external;\n");
          query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
          query.append("tns:getCustomerByCustID($customerId)");
          extVariables=new com.bea.ld.ExternalVariables();
          extVariables.setElement(new javax.xml.namespace.QName("customerId"), "CUSTOMER55", true);
          returnedProfileServices=DSPControlFile.executeQuery(query.toString(), extVariables );

          if(returnedProfileServices.length>0) {
             dObj= (commonj.sdo.DataObject)returnedProfileServices[0];
             outputString=outputString + dataObjectsToString(returnedProfileServices);
             DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{(retailer.PROFILE_SERVICE)dObj});

             /*
             extVariables=new com.bea.ld.ExternalVariables();
             extVariables.setElement(new javax.xml.namespace.QName("profile"), dataObject2String(xh,returnedProfileServices), true);
             query=new StringBuffer();
             query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
             query.append("declare namespace retailer='urn:retailer';\n");
             query.append("declare variable $profile as element(retailer:PROFILE)* external;\n");
             query.append("tns:deletePROFILE($profile)");
             DSPControlFile.executeProcedure(query.toString(), extVariables);
             */
          }
       }
    }
### Returning a Simple Element You can invoke Oracle Data Service Integrator data service operations that return simple types. The example in this section determines the number of orders by creating a query to call the `getOrderCount` and `getOrderCounts` operations and assigning the results to variables of type `java.math.BigInteger`. ##### Invoking an Operation that Returns a Simple Type
    outputString="";
    StringBuffer query=new StringBuffer();
    query.append("declare variable $customerId as xs:string external;\n");
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("tns:getOrderCount($customerId)");
    com.bea.ld.ExternalVariables extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("customerId"), "CUSTOMER4", true);
    Object[] returnedProfileServices=DSPControlFile.executeQuery(query.toString(), extVariables);
    outputString=outputString + dataObjectsToString(new Object[]{returnedProfileServices});

    query=new StringBuffer();
    query.append("declare variable $customerId as xs:string external;\n");
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("tns:getOrderCounts($customerId)");
    extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("customerId"), "CUSTOMER4", true);
    returnedProfileServices=DSPControlFile.executeQuery(query.toString(), extVariables );
    outputString=outputString + dataObjectsToString(returnedProfileServices);
### Including Auditing You can audit calls to Oracle Data Service Integrator data service operations and later retrieve the audit information for further processing. The example in this section creates a `RequestConfig` object and enables the data service audit feature (RETURN_DATA_SERVICE_AUDIT). After enabling audit, the example includes the instance of the `RequestConfig` object as an argument when invoking operations. The example then retrieves the audit records and iterates through the results to output for display. ##### Auditing Operations
    com.bea.dsp.RequestConfig reqConfig = new com.bea.dsp.RequestConfig();
    reqConfig.enableFeature(com.bea.dsp.RequestConfig.RETURN_DATA_SERVICE_AUDIT);
    reqConfig.setStringArrayAttribute(com.bea.dsp.RequestConfig.RETURN_AUDIT_PROPERTIES, attributes);

    StringBuffer query=new StringBuffer();
    query.append("declare variable $customerId as xs:string external;\n");
    query.append("declare namespace tns='ld:RetailApplication/CustomerManagement/ProfileService';\n");
    query.append("tns:getCustomerByCustID($customerId)");
    com.bea.ld.ExternalVariables extVariables=new com.bea.ld.ExternalVariables();
    extVariables.setElement(new javax.xml.namespace.QName("customerId"), "CUSTOMER4", true);
    Object[] o=DSPControlFile.executeQuery(query.toString(), extVariables, reqConfig );
    outputString=dataObjectsToString(o);
    /** Dump out the audit information **/
    com.bea.ld.DataServiceAudit dsAudit = reqConfig.retrieveDataServiceAudit();

    if (dsAudit != null) {
       List l = dsAudit.getAllRecords();
       for (Iterator it = l.iterator(); it.hasNext();) {
          com.bea.ld.DSPAuditRecord auditRec = (com.bea.ld.DSPAuditRecord) it.next();
          Map propMap = auditRec.getAuditProperties();
          for (Iterator pit = propMap.keySet().iterator(); pit.hasNext();) {
             String key = (String) pit.next();
             outputString=outputString + "Audit Information: " + key + " = " + propMap.get(key)+"\n";
          }
       }
    }
## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Dynamic Mediator API Code Reference Oracle Data Service Integrator Control Static Mediator API Code Reference

Document generated by Confluence on Jan 13, 2009 15:15