Import Related Value Sets Using Web Services

You can use the FndManageImportExportFiles web service to import related value sets into the application. This web service internally uses the processRelatedSetValueData method to import the related value sets, and stores them in a metadata table.

Here are a few things you need to keep in mind while importing the related value sets.

  • The related value sets and related value set values must be existing independent value sets.

  • There must be an existing relationship between both the value sets in the FND_VS_RELATED_SETS table.

  • If the relationship between these two value sets don't exist, then a new relationship is created in the FND_VS_RELATED_VALUES table or the ENABLED_FLAG column is updated.

Prerequisite

Make sure that the web service FndManageImportExportFilesService is added to the Manage Application Flexfield Value Set entitlement. Use the Security Console to complete this configuration on the Oracle Fusion Cloud Entitlements Server. Provide these details to configure the web service:

  • Resource type: WebserviceResourceType

  • Display name: ImportExport

  • Name: http://xmlns.oracle.com/oracle/apps/fnd/applcore/webservices/FndManageImportExportFilesService#*

  • Entitlement (In Default Policy Domain): Manage Application Flexfield Value Set

  • Security policy: oracle/wss11_saml_or_username_token_with_message_protection_service_policy

Import Related Value Sets

Do these steps to import related value sets.

  1. Do these to generate the keystore for the security policy "oracle/wss11_saml_or_username_token_with_message_protection_service_policy".

    1. Generate the keystore using the command keytool -genkeypair -keyalg RSA -alias mycompkey -keypass <password> -keystore mycompclient-keystore.jks -storepass <password> -validity 3600.

    2. Access the WSDL using this URL on a web browser: http://<host>:<port>/fndAppCoreServices/FndManageImportExportFilesService?wsdl, and get the public key <wsdl:service>/<wsdl:port>/<wsa:EndpointReference>/<wsid:Identity>/<dsig:keyInfo>/<dsig:X509Data>/<dsig:X509Certificate>.

    3. Enclose the public key within ---- BEGIN CERTIFICATE ---- and ---- END CERTIFICATE ---- and save it to a file by name cdrmpk.cer.

    4. Store the key information in the truststore using the command keytool -importcert -alias cdrmkey -file cdrmpk.cer -keystore mycompclient-keystore.jks -storepass <password>.

  2. Access the WSDL page using the browser of your choice.

  3. Export and save the associated security certificates:

    • Verisign Class 3 Public Primary Certification Authority - G5

    • Verisign Secure Server CA - G3

  4. Use this command to import the saved certificates into the trust store of the client computer.

    keytool -importcert -keystore <truststore> -storepass <truststorepassword> -file <file location where the mentioned certificate is stored> -alias <alias for certificate>
  5. Run this command to generate the JAX-WS proxy for the FndManageImportExportFilesService web service.

    C:\Program Files\Java\jdk1.7.0_04\bin>wsimport
               -s "d:\wsimport\FndManageImportExport"
               -d "d:\wsimport\FndManageImportExport" http://<host>:<port>/fndAppCoreServices/FndManageImportExportFilesService?wsdl
    
       parsing WSDL... 
    
       Generating code... 
    
       Compiling code...
    
  6. Save the generated code as a JAR file and name it FndManageImportExportProxy.jar.

  7. Use the following code to create another JAR file to initiate the web service.

    package com.oracle.xmlns.oracle.apps.fnd.applcore.webservices;
    import com.sun.xml.ws.developer.WSBindingProvider;
    import java.io.File;
    import java.io.IOException;
    import java.util.List;
    import java.util.Map;
    import javax.xml.ws.BindingProvider;
    import javax.xml.ws.WebServiceRef;
    import javax.xml.ws.handler.Handler;
    import oracle.webservices.ClientConstants;
    import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature;
    // !THE CHANGES MADE TO THIS FILE WILL BE DESTROYED IF REGENERATED!
    // This source file is generated by Oracle tools
    // Contents may be subject to change
    // For reporting problems, use the following
    // Version = Oracle WebServices (11.1.1.0.0, build 130224.1947.04102)
    public class FndManageImportExportFilesServiceSoapHttpPortClient
    {
      @WebServiceRef
      private static FndManageImportExportFilesService_Service fndManageImportExportFilesService_Service;
      public static void main(String [] args)
      {
    			System.setProperty("javax.net.ssl.trustStore","<location of truststore which is used in II) to import the certificates>");
           System.setProperty("javax.net.ssl.trustStorePassword", "<truststore password>");
        fndManageImportExportFilesService_Service = new FndManageImportExportFilesService_Service();
            SecurityPoliciesFeature securityFeatures =
                new SecurityPoliciesFeature(new String[] { "oracle/wss11_username_token_with_message_protection_client_policy",
                                                           });
    			
            FndManageImportExportFilesService
     fndManageImportExportFilesService =
    fndManageImportExportFilesService_Service.getFndManageImportExportFilesServiceSoapHttpPort
     (securityFeatures);
            // Add your code to call the desired methods.
            WSBindingProvider wsbp = (WSBindingProvider) fndManageImportExportFilesService;
               Map<String, Object> requestContext = wsbp.getRequestContext();
            requestContext.put(ClientConstants.WSSEC_KEYSTORE_TYPE,"jks");
            // Provide location of 'mycompclient-keystore.jks' which was created during Step I)
            requestContext.put(ClientConstants.WSSEC_KEYSTORE_LOCATION,"/home/user1/mycompclient-keystore.jks");
    				 requestContext.put(ClientConstants.WSSEC_KEYSTORE_PASSWORD,"<password>");
            requestContext.put(ClientConstants.WSSEC_RECIPIENT_KEY_ALIAS,"cdrmkey");
            //Provide user who is having permission to initiate the service
            requestContext.put(WSBindingProvider.USERNAME_PROPERTY,"<username>");
            requestContext.put(WSBindingProvider.PASSWORD_PROPERTY, "<password>");
    				String relatedvaluesetfileID =          invokeUploadFiletoUCMMethod(fndManageImportExportFilesService, "relatedvaluesetfilename");
    				String relatedvaluefileID =          invokeUploadFiletoUCMMethod(fndManageImportExportFilesService, "relatedvaluefilename");
    
    				if (relatedvaluesetfileID != null) {
                invokeRelatedValueSetValuesDataLoader(fndManageImportExportFilesService,  new Long(relatedvaluesetfileID), new Long(relatedvaluefileID));
            }
      }
    			static String invokeUploadFiletoUCMMethod(FndManageImportExportFilesService fndManageImportExportFilesService, String fileName) {
            String response = null;
            DocumentDetails document = new DocumentDetails();
            ObjectFactory objfactory = new ObjectFactory();
            document.setFileName(objfactory.createDocumentDetailsFileName("import_data.txt"));
            // Provide UCM repository - if repository is fin/tax/import then suffix each value with $ as mentioned here
            document.setDocumentAccount(objfactory.createDocumentDetailsDocumentAccount("fin$/tax$/import$"));
            document.setDocumentTitle(objfactory.createDocumentDetailsDocumentTitle("VS"));
            document.setContentType(objfactory.createDocumentDetailsContentType("plain/text"));
            try {
                // Provide location of 'relatedvaluesetfile.txt' which contains ValueSet values data in prescribed format
                byte[] content =
                org.apache.commons.io.FileUtils.readFileToByteArray(new File("/home/user1/" + fileName));
                //System.out.println("File content:" + new String(content, "UTF-8"));
                document.setContent(objfactory.createDocumentDetailsContent(content));
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
            catch(Exception e) {
                System.out.println("Exception: "+e.getMessage());
            }
            try {
                response = fndManageImportExportFilesService.uploadFiletoUCM(document);
                System.out.println("Response: " + response);
            } catch (ServiceException e) {
                System.out.println(e.getMessage());
            }
            return response;
        }	
    			static void invokeRelatedValueSetValuesDataLoader(FndManageImportExportFilesService fndManageImportExportFilesService,
    																					Long relatedvaluesetfileID, Long relatedvaluefileID) {
            String response;
    				try {
    						response = fndManageImportExportFilesService.processRelatedSetValueData(relatedvaluesetfileID, relatedvaluefileID);
    																	System.out.println("Response: " + response);
    				} catch (ServiceException e) {
                System.out.println(e.getMessage());
            }
  8. Save the generated output as a JAVA file and name it FndManageImportExportFilesServiceSoapHttpPortClient.java.

  9. Use the JAVA file to build a JAR file, and name it FndManageImportExportClient.jar.

  10. Use this command to run the web service.

    java -cp ./FndManageImportExportProxy.jar:./ws.api_1.1.0.0.jar:./FndManageImportExportClient.jar FndManageImportExportFilesServiceSoapHttpPortClient