Sei sulla pagina 1di 98

Oracle PaaS for SaaS Workshop

Developer Workshop
Build Static Proxy Client for Sales Cloud

Page 1 of
9898
Overview
At the end of this exercise, you will be able to:

1. How to create a web service proxy through JDeveloper


2. How to create and use findCriteria object
3. How to import the certificate
4. How to Deploy an Application to JCS

Page 2 of
9898
Instructions

1. Create a new Application and a Project

 Click File -> New

 Select Generic Application and click OK

Page 3 of
9898
 Set Fields below, leave remaining as the default and click Next
o Application Name: PasSSasSWorkshop
o Application Package Prefix: com.oracle.pts

Page 4 of
9898
 Set Fields below, leave remaining as the default and click Finish
o Project Name: SalesPartyServ iceProxy

Page 5 of
9898
Page 6 of
9898
2. Create a Web Service Proxy

 Click File -> New

 Select Web Service Proxy and click OK

Page 7 of
9898
 Click Next

Page 8 of
9898
 Click Next

Page 9 of
9898
 Specify WSDL Document URL and click Next

o WSDL Document URL : https://<Your OSC


host>/crmCommonSalesParties/SalesPartyServ ice?WSDL

Eg.:
https://fap0930-
crm.oracleads.com/crmCommonSalesParties/SalesPartyServ ice?WSDL

Page 10 of
9898
 This next step will take some time

 Set Fields below, leave remaining as the default and click Next
o Package Name: com.oracle.pts.salesparty.wsclient.generated
o Root Package for Generated Types: com.oracle.pts.salesparty.wsclient
o Generate As Async: uncheck

Page 11 of
9898
- This next step will take some time

 Click Next

Page 12 of
9898
Page 13 of
9898
 Select Don’t generate any asynchronous methods and click Next

 Select Policy and click Next


o oracle/wss_username_token_over_ssl_client_policy

Page 14 of
9898
 Click Next

Page 15 of
9898
 Click Finish

Page 16 of
9898
- This will take some time

o View result

- The following project structure has been generated.

Page 17 of
9898
Page 18 of
9898
- Here is the client

Page 19 of
9898
3. Key Setup

In order to authenticate to Fusion, the server side public certificate must be acquired
and added as a trusted cert entry to a keystore used by the client. This keystore stores
a reference to the Fusion public certificate and uses the alias "orakey". The Fusion
public certificate is obtained from any Fusion Application object WSDL. For the
upcoming steps you may need to run your browser with Administrator priv ileges.

 Open IE and type OSC SalesParty web serv ice wsdl URL

o WSDL Document URL : https://<Your OSC


host>/crmCommonSalesParties/SalesPartyServ ice?WSDL
Sample: https://fap0930-
crm.oracleads.com/crmCommonSalesParties/SalesPartyServ ice?WSDL

Page 20 of
9898
 Click key icon

Page 21 of
9898
Page 22 of
9898
 Click View certificates

 Click View certificates

Page 23 of
9898
 Click Next

Page 24 of
9898
 Click Next

Page 25 of
9898
 Click Finish

Page 26 of
9898
Page 27 of
9898
- Now you can export this cert
 Click Tools -> Internet Options

 Click Content -> Certificates

Page 28 of
9898
Page 29 of
9898
 Click Other People, select certificate you just imported and click Export

Page 30 of
9898
 Click Next

Page 31 of
9898
 Click Next

 Browse the location and type file name and click Next
o Sample: D:\software\fusion_app\webserv ice\oraclelead.cer

Page 32 of
9898
Page 33 of
9898
 Click Finish

 Check Trusted Certificate Keystore location by clicking Tools -> Preferences

Page 34 of
9898
 Copy Client Trusted Certificate Keystore location into Notepad. The certificate will
be imported into this key store.
o Sample:
C:\Oracle\MiddlewareJdev111171_20140227\wlserver_10.3\server\lib\
DemoTrust.jks

Page 35 of
9898
Page 36 of
9898
 Import Oracle certificate to a keystore file

1) Open an command prompt


2) Type command
3) Click Enter
4) Type ‘Yes’ for ‘Trust this certicate?’ and click enter

o Command: <JAVA_HOME>\bin\keytool -importcert -file


<Certificate_Location>/oraclelead.cer -keystore
<MIDDLEWARE_HOME>\wlserver_10.3\server\lib\DemoTrust.jks -alias
oraclelead -storepass DemoTrustKeyStorePassPhrase

o Sample: C:\Oracle\MiddlewareJdev111171_20140227\jdk160_24\bin\keytool -
importcert -file D:/software/fusion_app/webserv ice/oraclelead.cer -keystore
C:\Oracle\MiddlewareJdev111171_20140227\wlserver_10.3\server\lib\DemoTrust
.jks -alias oraclelead -storepass DemoTrustKeyStorePassPhrase

Page 37 of
9898
 List the keystore contents

o Command: <JAVA_HOME>\bin\keytool -list -v -keystore


<JDeveloper_Home>\wlserver_10.3\server\lib\DemoTrust.jks -storepass
DemoTrustKeyStorePassPhrase
o

Page 38 of
9898
o Sample: C:\Oracle\MiddlewareJdev111171_20140227\jdk160_24\bin\keytool -list
-v -keystore
C:\Oracle\MiddlewareJdev111171_20140227\wlserver_10.3\server\lib\DemoTrust
.jks -storepass DemoTrustKeyStorePassPhrase

4. Code the Client: Using nested criteria in the main findCriteria

Page 39 of
9898
 Click File -> New

 Select Java Class and click OK

Page 40 of
9898
Page 41 of
9898
 Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClient
o Package: com.oracle.pts.client

 Amend SalesPartyClient as follows as follows and save

package com.oracle.pts.client;

import com.oracle.pts.salesparty.wsclient.Conjunction;
import com.oracle.pts.salesparty.wsclient.FindControl;
import com.oracle.pts.salesparty.wsclient.FindCriteria;

Page 42 of
9898
import com.oracle.pts.salesparty.wsclient.FindSalesParty;
import com.oracle.pts.salesparty.wsclient.ObjectFactory;
import com.oracle.pts.salesparty.wsclient.SalesParty;
import com.oracle.pts.salesparty.wsclient.SortAttribute;
import com.oracle.pts.salesparty.wsclient.SortOrder;
import com.oracle.pts.salesparty.wsclient.ViewCriteria;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaItem;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaRow;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService_Service;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;

import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature;

public class SalesPartyClient {


protected static SalesPartyService_Service salesPartyService_Service;
protected SalesPartyService salesPartyService;
protected ObjectFactory objectFactory;
private Logger logger = Logger.getLogger("CRM");

public SalesPartyClient() {
super();
init();
}
public static void main(String[] args){
SalesPartyClient salesPartyClient = new SalesPartyClient();
salesPartyClient.work();
}

protected void init() {

System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "youUserName";

String password = "YourPassword";

salesPartyService_Service =
new SalesPartyService_Service();

Page 43 of
9898
SecurityPoliciesFeature securityFeatures =
new SecurityPoliciesFeature(new String[] { "oracle/wss_username_token_over_ssl_client_policy" });

salesPartyService =
salesPartyService_Service.getSalesPartyServiceSoapHttpPort(securityFeatures);
Map<String, Object> reqContext =
((BindingProvider)salesPartyService).getRequestContext();

reqContext.put(BindingProvider.USERNAME_PROPERTY, username);
reqContext.put(BindingProvider.PASSWORD_PROPERTY, password);

objectFactory = new ObjectFactory();

}
public void work(){
List<String> nameList = getSalesPartyList();
for(String name:nameList){
logger.info("Name = " + name);
}
}
public List<String> getSalesPartyList(){
List<String> returnList = new ArrayList<String>();
ViewCriteria vc;
ViewCriteriaRow vcr;
ViewCriteriaItem vci;
ViewCriteriaRow vcr1;
ViewCriteriaItem vci1;
ViewCriteria vc1;
ViewCriteriaRow vcr2;
ViewCriteriaItem vci2;
ViewCriteria vc2;

// Following is how to create a FindCriteria on SalesParty Service to retrieve External users


// in this example , they are retrieved by :
// • PartyType = “PERSON”
// • PartyUsageCode = “CUSTOMER_CONTACT”

//
// <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/types/"
xmlns:ns2="http://xmlns.oracle.com/adf/svc/types/">
// <env:Header/>
// <env:Body>
// <ns1:findSalesParty>
// <ns1:findCriteria>
// <ns2:fetchStart>0</ns2:fetchStart>
// <ns2:fetchSize>-1</ns2:fetchSize>
// <ns2:filter>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare/><ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyType</ns2:attribute>
// <ns2:operator>=</ns2:operator>

Page 44 of
9898
// <ns2:value>PERSON</ns2:value>
// </ns2:item>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PersonParty</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:nested>
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageAssignment</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:nested>
// <ns2:group>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageCode</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:value>CUSTOMER_CONTACT</ns2:value>
// </ns2:item>
// </ns2:group>
// </ns2:nested>
// </ns2:item>
// </ns2:group>
// </ns2:nested>
// </ns2:item>
// </ns2:group>
// </ns2:filter>
// <ns2:sortOrder>
// <ns2:sortAttribute>
// <ns2:name>PartyName</ns2:name>
// <ns2:descending>false</ns2:descending>
// </ns2:sortAttribute>
// </ns2:sortOrder>
// <ns2:findAttribute>PartyName</ns2:findAttribute><ns2:excludeAttribute/>
// </ns1:findCriteria>
// <ns1:findControl>
// <ns2:retrieveAllTranslations>false</ns2:retrieveAllTranslations>
// </ns1:findControl>
// </ns1:findSalesParty>
// </env:Body>
// </env:Envelope>

FindCriteria fc = new FindCriteria();


fc.setFetchStart(0);
fc.setFetchSize(-1);

// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.

// a Filter is a Group including ViewCriteria


// <ns2:filter>
// <ns2:conjunction>And</ns2:conjunction>

Page 45 of
9898
vc = new ViewCriteria();
vc.setConjunction(Conjunction.fromValue("And"));
// a ViewCriteria is made of ViewCriteriaRow(s)
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
vcr = new ViewCriteriaRow();
vcr.setConjunction(Conjunction.fromValue("And"));
vcr.setUpperCaseCompare(false);
// a ViewCriteriaRow is made of ViewCriteriaItem(s)
//
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyType</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:value>PERSON</ns2:value>
// </ns2:item>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PartyType");
vci.setOperator("=");
vci.getValue().add("PERSON");
vcr.getItem().add(vci);

// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PersonParty</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:nested>
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageAssignment</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:nested>
// <ns2:group>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageCode</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:value>CUSTOMER_CONTACT</ns2:value>
// </ns2:item>
// </ns2:group>
// </ns2:nested>
// </ns2:item>
// </ns2:group>
// </ns2:nested>
// </ns2:item>

// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>

Page 46 of
9898
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PersonParty</ns2:attribute>
// <ns2:operator>=</ns2:operator>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PersonParty");
vci.setOperator("=");

// <ns2:nested>
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageAssignment</ns2:attribute>
// <ns2:operator>=</ns2:operator>

// What is inside <ns2:nested> is a ViewCriteria with VIewCriteriaRow and ViewCriteriaItem


vc1 = new ViewCriteria();
vcr1 = new ViewCriteriaRow();
vcr1.setConjunction(Conjunction.fromValue("And"));
vcr1.setUpperCaseCompare(false);
vci1 = new ViewCriteriaItem();
vci1.setConjunction(Conjunction.fromValue("And"));
vci1.setUpperCaseCompare(false);
vci1.setAttribute("PartyUsageAssignment");
vci1.setOperator("=");
// ViewCriteriaItem added to the ViewCriteriaRow
vcr1.getItem().add(vci1);
// ViewCriteriaRow added to the ViewCriteria Group
vc1.getGroup().add(vcr1);

// <ns2:nested>
// <ns2:group>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyUsageCode</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:value>CUSTOMER_CONTACT</ns2:value>
// </ns2:item>
// </ns2:group>
// </ns2:nested>

// What is inside <ns2:nested> is a ViewCriteria with VIewCriteriaRow and ViewCriteriaItem


vc2 = new ViewCriteria();
vcr2 = new ViewCriteriaRow();
vcr2.setConjunction(Conjunction.fromValue("And"));
vcr2.setUpperCaseCompare(false);
vci2 = new ViewCriteriaItem();
vci2.setConjunction(Conjunction.fromValue("And"));
vci2.setUpperCaseCompare(false);
vci2.setAttribute("PartyUsageCode");
vci2.setOperator("=");

Page 47 of
9898
vci2.getValue().add("CUSTOMER_CONTACT");
// ViewCriteriaItem added to the ViewCriteriaRow
vcr2.getItem().add(vci2);
// ViewCriteriaRow added to the ViewCriteria Group
vc2.getGroup().add(vcr2);
// ViewCriteria group (PartyUsageCode) added as nested of previous ViewCriteria
(PartyUsageAssignment)
vci1.setNested(vc2);
// ViewCriteria group (PartyUsageAssignment) added as nested of previous ViewCriteria (PersonParty)
vci.setNested(vc1);
// ViewCriteriaItem (started with PersonParty and including the 2 <nested> added to the initial
ViewCriteriaRow)
vcr.getItem().add(vci);
// Initial ViewCriteriaRow added to the top ViewCriteria Group
vc.getGroup().add(vcr);
// Top ViewCriteria Group added as the Filter of the FindCriteria
fc.setFilter(vc);
// <ns2:sortOrder>
// <ns2:sortAttribute>
// <ns2:name>PartyName</ns2:name>
// <ns2:descending>false</ns2:descending>
// </ns2:sortAttribute>
// </ns2:sortOrder>
SortOrder so = new SortOrder();
SortAttribute soa = new SortAttribute();
soa.setName("PartyName");
soa.setDescending(false);
// Adding SortAttribute to SortOrder
so.getSortAttribute().add(soa);
// Applying SortOrder to the FindCriteria
fc.setSortOrder(so);

// Limit which attributes are retrieved for SalesParty


fc.getFindAttribute().add("PartyName");

try {
FindControl findControl = objectFactory.createFindControl();
findControl.setRetrieveAllTranslations(false);
FindSalesParty findSalesParty = objectFactory.createFindSalesParty();
findSalesParty.setFindControl(findControl);
findSalesParty.setFindCriteria(fc);
// Calling findSalesParty method on the service, passing the FindCriteria
List<SalesParty> sales = salesPartyService.findSalesParty(findSalesParty).getResult();
// Iterating through SalesParty List
for (int i = 0; i < sales.size(); i++) {
SalesParty sp = sales.get(i);
// Only PartyName attribute has been retrieved
// fc.getFindAttribute().add("PartyName");
returnList.add(sp.getPartyName().getValue());
}
} catch (Exception ex) {
ex.printStackTrace();
}

return returnList;
}

Page 48 of
9898
}

 Change username and password to your OSC credential and save

o Sample

String username = "Matt.Hooper";


String password = "Password12345";

 Make sure HTTP Proxy Server is ‘Uncheck’


o Open Tools -> Preferences

o Uncheck HTTP Proxy Server and click OK

Page 49 of
9898
 Test (right-click SalesPartyClient and select Run)
o Result is displayed in the JDeveloper Log window

Page 50 of
9898
5. Code the Client: Using nested criteria in a ChildFindCriteria

 Click File -> New

 Select Java Class and click OK

Page 51 of
9898
Page 52 of
9898
 Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClientTwo
o Package: com.oracle.pts.client

 Amend SalesPartyClientTwo as follows as follows and save

package com.oracle.pts.client;

import com.oracle.pts.salesparty.wsclient.ChildFindCriteria;
import com.oracle.pts.salesparty.wsclient.Conjunction;
import com.oracle.pts.salesparty.wsclient.FindControl;
import com.oracle.pts.salesparty.wsclient.FindCriteria;

Page 53 of
9898
import com.oracle.pts.salesparty.wsclient.FindSalesParty;
import com.oracle.pts.salesparty.wsclient.ObjectFactory;
import com.oracle.pts.salesparty.wsclient.Person;
import com.oracle.pts.salesparty.wsclient.SalesParty;
import com.oracle.pts.salesparty.wsclient.SortAttribute;
import com.oracle.pts.salesparty.wsclient.SortOrder;
import com.oracle.pts.salesparty.wsclient.ViewCriteria;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaItem;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaRow;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService_Service;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;

import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature;

public class SalesPartyClientTwo {


protected static SalesPartyService_Service salesPartyService_Service;
protected SalesPartyService salesPartyService;
protected ObjectFactory objectFactory;
private Logger logger = Logger.getLogger("CRM");
public SalesPartyClientTwo() {
super();
init();
}
public static void main(String[] args){
SalesPartyClientTwo salesPartyClient = new SalesPartyClientTwo();
salesPartyClient.work();
}
protected void init() {

System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "yourUserName";

String password = "yourPassword";

salesPartyService_Service =
new SalesPartyService_Service();
SecurityPoliciesFeature securityFeatures =
new SecurityPoliciesFeature(new String[] { "oracle/wss_username_token_over_ssl_client_policy" });

salesPartyService =
salesPartyService_Service.getSalesPartyServiceSoapHttpPort(securityFeatures);

Page 54 of
9898
Map<String, Object> reqContext =
((BindingProvider)salesPartyService).getRequestContext();

reqContext.put(BindingProvider.USERNAME_PROPERTY, username);
reqContext.put(BindingProvider.PASSWORD_PROPERTY, password);

objectFactory = new ObjectFactory();

}
public void work(){
List<String> nameList = getSalesPartyList();
for(String name:nameList){
logger.info("Name = " + name);
}
}
public List<String> getSalesPartyList(){
List<String> returnList = new ArrayList<String>();
ViewCriteria vc;
ViewCriteriaRow vcr;
ViewCriteriaItem vci;
ViewCriteriaRow vcr1;
ViewCriteriaItem vci1;
ViewCriteria vc1;
// Following is how to create a FindCriteria on SalesParty Service to retrieve External users
// in this example , they are retrieved by :
// • PartyType = “PERSON”
// • PartyUsageCode = “CUSTOMER_CONTACT”

//
// <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/types/"
xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">
// <soapenv:Header/>
// <soapenv:Body>
// <typ:findSalesParty>
// <typ:findCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare/>
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyType</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>PERSON</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:sortOrder>
// <typ1:sortAttribute>
// <typ1:name>PartyName</typ1:name>
// <typ1:descending>false</typ1:descending>
// </typ1:sortAttribute>

Page 55 of
9898
// </typ1:sortOrder>
// <typ1:findAttribute>PersonParty</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageAssignment</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:nested>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:nested>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:findAttribute>PartyName</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
// </typ1:childFindCriteria>
// </typ:findCriteria>
// <typ:findControl>
// <typ1:retrieveAllTranslations>false</typ1:retrieveAllTranslations>
// </typ:findControl>
// </typ:findSalesParty>
// </soapenv:Body>
// </soapenv:Envelope>

FindCriteria fc = new FindCriteria();


fc.setFetchStart(0);
fc.setFetchSize(-1);

// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.

// a Filter is a Group including ViewCriteria


// <ns2:filter>
// <ns2:conjunction>And</ns2:conjunction>
vc = new ViewCriteria();
vc.setConjunction(Conjunction.fromValue("And"));
// a ViewCriteria is made of ViewCriteriaRow(s)
// <ns2:group>
// <ns2:conjunction>And</ns2:conjunction>

Page 56 of
9898
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
vcr = new ViewCriteriaRow();
vcr.setConjunction(Conjunction.fromValue("And"));
vcr.setUpperCaseCompare(false);
// a ViewCriteriaRow is made of ViewCriteriaItem(s)
//
// <ns2:item>
// <ns2:conjunction>And</ns2:conjunction>
// <ns2:upperCaseCompare>false</ns2:upperCaseCompare>
// <ns2:attribute>PartyType</ns2:attribute>
// <ns2:operator>=</ns2:operator>
// <ns2:value>PERSON</ns2:value>
// </ns2:item>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PartyType");
vci.setOperator("=");
vci.getValue().add("PERSON");
vcr.getItem().add(vci);

// ViewCriteriaRow added to the ViewCriteria Group


vc.getGroup().add(vcr);
// Applying Filter to the FindCriteria
fc.setFilter(vc);

// Building the SortOrder clause


// <typ1:sortOrder>
// <typ1:sortAttribute>
// <typ1:name>PartyName</typ1:name>
// <typ1:descending>false</typ1:descending>
// </typ1:sortAttribute>
// </typ1:sortOrder>
SortOrder so = new SortOrder();
SortAttribute soa = new SortAttribute();
soa.setName("PartyName");
soa.setDescending(false);
// Adding SortAttribute to SortOrder
so.getSortAttribute().add(soa);
// Applying SortOrder to the FindCriteria
fc.setSortOrder(so);

// Limit which attributes are retrieved for SalesParty


fc.getFindAttribute().add("PersonParty");
// Is the previous attribute excluded from the result output
fc.setExcludeAttribute(false);

// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageAssignment</typ1:attribute>

Page 57 of
9898
// <typ1:operator>=</typ1:operator>
// <typ1:nested>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:nested>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:findAttribute>PartyName</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
// </typ1:childFindCriteria>

// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
ChildFindCriteria cfc = new ChildFindCriteria();
cfc.setFetchStart(0);
cfc.setFetchSize(-1);
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
vc = new ViewCriteria();
vc.setConjunction(Conjunction.fromValue("And"));
vcr = new ViewCriteriaRow();
vcr.setConjunction(Conjunction.fromValue("And"));
vcr.setUpperCaseCompare(false);
// <typ1:item>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageAssignment</typ1:attribute>
// <typ1:operator>=</typ1:operator>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PartyUsageAssignment");
vci.setOperator("=");

// <typ1:nested>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>

Page 58 of
9898
// </typ1:item>
// </typ1:group>
// </typ1:nested>

// What is inside <typ1:nested> is a ViewCriteria with VIewCriteriaRow and ViewCriteriaItem


vc1 = new ViewCriteria();
vcr1 = new ViewCriteriaRow();
vcr1.setConjunction(Conjunction.fromValue("And"));
vcr1.setUpperCaseCompare(false);
vci1 = new ViewCriteriaItem();
vci1.setConjunction(Conjunction.fromValue("And"));
vci1.setUpperCaseCompare(false);
vci1.setAttribute("PartyUsageCode");
vci1.setOperator("=");
vci1.getValue().add("CUSTOMER_CONTACT");
// ViewCriteriaItem added to the ViewCriteriaRow
vcr1.getItem().add(vci1);
// ViewCriteriaRow added to the ViewCriteria Group
vc1.getGroup().add(vcr1);
// ViewCriteria group (PartyUsageCode) added as nested of previous ViewCriteria (PartyUsageAssignment)
vci.setNested(vc1);
// ViewCriteriaItem (started with PersonParty and including the 2 <nested> added to the initial
ViewCriteriaRow)
vcr.getItem().add(vci);
// Initial ViewCriteriaRow added to the top ViewCriteria Group
vc.getGroup().add(vcr);
// ViewCriteria Group added as the Filter of the ChildFindCriteria
cfc.setFilter(vc);
// Which attributes to retrieve
// <typ1:findAttribute>PartyName</typ1:findAttribute>
cfc.getFindAttribute().add("PartyName");
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
cfc.setExcludeAttribute(false);
// Which attribute of the master (SalesParty) the Child is working with
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
cfc.setChildAttrName("PersonParty");
// Adding the ChildFindCriteria to the main FindCriteria
fc.getChildFindCriteria().add(cfc);

try {
FindControl findControl = objectFactory.createFindControl();
findControl.setRetrieveAllTranslations(false);
FindSalesParty findSalesParty = objectFactory.createFindSalesParty();
findSalesParty.setFindControl(findControl);
findSalesParty.setFindCriteria(fc);
// Calling findSalesParty method on the service, passing the FindCriteria
List<SalesParty> sales = salesPartyService.findSalesParty(findSalesParty).getResult();
// Iterating through SalesParty List
for (int i = 0; i < sales.size(); i++) {
SalesParty sp = sales.get(i);
List<Person> persons = sp.getPersonParty();
for(int j=0; j < persons.size(); j++){
Person p = persons.get(j);
// Only PartyName attribute has been retrieved in the Child
// cfc.getFindAttribute().add("PartyName");

returnList.add(p.getPartyName());
}

Page 59 of
9898
}
} catch (Exception ex) {
ex.printStackTrace();
}
return returnList;
}

 Change username and password to your OSC credential and save

o Sample

String username = "Matt.Hooper";


String password = "Password12345";

 Test (right-click SalesPartyClientTwo and select Run)


o Result is displayed in the JDeveloper Log window

Page 60 of
9898
6. Code the Client: Using nested ChildFindCriteria

 Click File -> New

 Select Java Class and click OK

Page 61 of
9898
Page 62 of
9898
 Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClientThree
o Package: com.oracle.pts.client

 Amend SalesPartyClientThree as follows as follows and save

package com.oracle.pts.client;

Page 63 of
9898
import com.oracle.pts.salesparty.wsclient.ChildFindCriteria;
import com.oracle.pts.salesparty.wsclient.Conjunction;
import com.oracle.pts.salesparty.wsclient.FindControl;
import com.oracle.pts.salesparty.wsclient.FindCriteria;
import com.oracle.pts.salesparty.wsclient.FindSalesParty;
import com.oracle.pts.salesparty.wsclient.ObjectFactory;
import com.oracle.pts.salesparty.wsclient.PartyUsageAssignment;
import com.oracle.pts.salesparty.wsclient.Person;
import com.oracle.pts.salesparty.wsclient.SalesParty;
import com.oracle.pts.salesparty.wsclient.SortAttribute;
import com.oracle.pts.salesparty.wsclient.SortOrder;
import com.oracle.pts.salesparty.wsclient.ViewCriteria;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaItem;
import com.oracle.pts.salesparty.wsclient.ViewCriteriaRow;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService;
import com.oracle.pts.salesparty.wsclient.generated.SalesPartyService_Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import java.util.logging.Logger;

import javax.xml.ws.BindingProvider;

import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature;

public class SalesPartyClientThree {


protected static SalesPartyService_Service salesPartyService_Service;
protected SalesPartyService salesPartyService;
protected ObjectFactory objectFactory;
private Logger logger = Logger.getLogger("CRM");
public SalesPartyClientThree() {
super();
init();
}
public static void main(String[] args){
SalesPartyClientThree salesPartyClient = new SalesPartyClientThree();
salesPartyClient.work();
}
protected void init() {

System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "yourUserName";

String password = "yourPassword";

salesPartyService_Service =
new SalesPartyService_Service();
SecurityPoliciesFeature securityFeatures =
new SecurityPoliciesFeature(new String[] { "oracle/wss_username_token_over_ssl_client_policy" });

salesPartyService =
salesPartyService_Service.getSalesPartyServiceSoapHttpPort(securityFeatures);

Page 64 of
9898
Map<String, Object> reqContext =
((BindingProvider)salesPartyService).getRequestContext();

reqContext.put(BindingProvider.USERNAME_PROPERTY, username);
reqContext.put(BindingProvider.PASSWORD_PROPERTY, password);

objectFactory = new ObjectFactory();

}
public void work(){
List<String> valueList = getResultList();
for(String value:valueList){
logger.info(value);
}
}
public List<String> getResultList(){
List<String> returnList = new ArrayList<String>();
ViewCriteria vc;
ViewCriteriaRow vcr;
ViewCriteriaItem vci;
ViewCriteriaRow vcr1;
ViewCriteriaItem vci1;
ChildFindCriteria cfc1;
ViewCriteriaRow vcr2;
ViewCriteriaItem vci2;
ViewCriteria vc2;
// Following is how to create a FindCriteria on SalesParty Service to retrieve External users
// in this example , they are retrieved by :
// • PartyType = “PERSON”
// • PartyUsageCode = “CUSTOMER_CONTACT”

//
// <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/types/"
xmlns:typ1="http://xmlns.oracle.com/adf/svc/types/">
// <soapenv:Header/>
// <soapenv:Body>
// <typ:findSalesParty>
// <typ:findCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare/>
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyType</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>PERSON</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:sortOrder>
// <typ1:sortAttribute>

Page 65 of
9898
// <typ1:name>PartyName</typ1:name>
// <typ1:descending>false</typ1:descending>
// </typ1:sortAttribute>
// </typ1:sortOrder>
// <typ1:findAttribute>PersonParty</typ1:findAttribute>
// <typ1:excludeAttribute>true</typ1:excludeAttribute>
// <typ1:findAttribute>PartyName</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>

// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:findAttribute>PartyUsageAssignment</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:findAttribute>PartyUsageCode</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childAttrName>PartyUsageAssignment</typ1:childAttrName>
// </typ1:childFindCriteria>
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
// </typ1:childFindCriteria>
// </typ:findCriteria>
// <typ:findControl>
// <typ1:retrieveAllTranslations>false</typ1:retrieveAllTranslations>
// </typ:findControl>
// </typ:findSalesParty>
// </soapenv:Body>
// </soapenv:Envelope>

FindCriteria fc = new FindCriteria();


fc.setFetchStart(0);
fc.setFetchSize(-1);

// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.

// a Filter is a Group including ViewCriteria


// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
vc = new ViewCriteria();
vc.setConjunction(Conjunction.fromValue("And"));
// a ViewCriteria is made of ViewCriteriaRow(s)

Page 66 of
9898
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
vcr = new ViewCriteriaRow();
vcr.setConjunction(Conjunction.fromValue("And"));
vcr.setUpperCaseCompare(false);
// a ViewCriteriaRow is made of ViewCriteriaItem(s)
//
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyType</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>PERSON</typ1:value>
// </typ1:item>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PartyType");
vci.setOperator("=");
vci.getValue().add("PERSON");
vcr.getItem().add(vci);

// ViewCriteriaRow added to the ViewCriteria Group


vc.getGroup().add(vcr);
// Applying Filter to the FindCriteria
fc.setFilter(vc);

// Building the SortOrder clause


// <typ1:sortOrder>
// <typ1:sortAttribute>
// <typ1:name>PartyName</typ1:name>
// <typ1:descending>false</typ1:descending>
// </typ1:sortAttribute>
// </typ1:sortOrder>
SortOrder so = new SortOrder();
SortAttribute soa = new SortAttribute();
soa.setName("PartyName");
soa.setDescending(false);
// Adding SortAttribute to SortOrder
so.getSortAttribute().add(soa);
// Applying SortOrder to the FindCriteria
fc.setSortOrder(so);

// Limit which attributes are retrieved for SalesParty


fc.getFindAttribute().add("PersonParty");
// Is the previous attribute excluded from the result output => true
fc.setExcludeAttribute(true);
// Limit which attributes are retrieved for SalesParty
fc.getFindAttribute().add("PartyName");
// Is the previous attribute excluded from the result output
fc.setExcludeAttribute(false);

// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:findAttribute>PartyUsageAssignment</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>

Page 67 of
9898
// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:item>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>
// </typ1:item>
// </typ1:group>
// </typ1:filter>
// <typ1:findAttribute>PartyUsageCode</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
// <typ1:childAttrName>PartyUsageAssignment</typ1:childAttrName>
// </typ1:childFindCriteria>
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
// </typ1:childFindCriteria>

// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
ChildFindCriteria cfc = new ChildFindCriteria();
cfc.setFetchStart(0);
cfc.setFetchSize(-1);
// Which attribute retrieved from PersonParty and Is it exluded from output
// <typ1:findAttribute>PartyUsageAssignment</typ1:findAttribute>
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
cfc.getFindAttribute().add("PartyUsageAssignment");
cfc.setExcludeAttribute(false);
// Nested ChildFindCriteria
// <typ1:childFindCriteria>
// <typ1:fetchStart>0</typ1:fetchStart>
// <typ1:fetchSize>-1</typ1:fetchSize>
cfc1 = new ChildFindCriteria();
cfc1.setFetchStart(0);
cfc1.setFetchSize(-1);
// <typ1:filter>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:group>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
vc = new ViewCriteria();
vc.setConjunction(Conjunction.fromValue("And"));
vcr = new ViewCriteriaRow();
vcr.setConjunction(Conjunction.fromValue("And"));
vcr.setUpperCaseCompare(false);
// <typ1:item>
// <typ1:conjunction>And</typ1:conjunction>
// <typ1:upperCaseCompare>false</typ1:upperCaseCompare>
// <typ1:attribute>PartyUsageCode</typ1:attribute>
// <typ1:operator>=</typ1:operator>
// <typ1:value>CUSTOMER_CONTACT</typ1:value>

Page 68 of
9898
// </typ1:item>
vci = new ViewCriteriaItem();
vci.setConjunction(Conjunction.fromValue("And"));
vci.setUpperCaseCompare(false);
vci.setAttribute("PartyUsageCode");
vci.setOperator("=");
vci.getValue().add("CUSTOMER_CONTACT");
// ViewCriteriaItem added to the ViewCriteriaRow
vcr.getItem().add(vci);
// ViewCriteriaRow added to the ViewCriteria Group
vc.getGroup().add(vcr);
// ViewCriteria Group added as the Filter of the nested ChildFindCriteria
cfc1.setFilter(vc);
// Which attributes to retrieve from nested ChildFindCriteria
// <typ1:findAttribute>PartyUsageCode</typ1:findAttribute>
cfc1.getFindAttribute().add("PartyUsageCode");
// <typ1:excludeAttribute>false</typ1:excludeAttribute>
cfc1.setExcludeAttribute(false);
// Which attribute of the main ChildFindCriteria is the nested ChildFindCriteria working with
// <typ1:childAttrName>PartyUsageAssignment</typ1:childAttrName>
cfc1.setChildAttrName("PartyUsageAssignment");
// Adding nested ChildFindCriteria to the main one
cfc.getChildFindCriteria().add(cfc1);
// Which attribute of the SalesParty is the main ChildFindCriteria working with
// <typ1:childAttrName>PersonParty</typ1:childAttrName>
cfc.setChildAttrName("PersonParty");
// Adding the main ChildFindCriteria to the main FindCriteria
fc.getChildFindCriteria().add(cfc);

try {
FindControl findControl = objectFactory.createFindControl();
findControl.setRetrieveAllTranslations(false);
FindSalesParty findSalesParty = objectFactory.createFindSalesParty();
findSalesParty.setFindControl(findControl);
findSalesParty.setFindCriteria(fc);
// Calling findSalesParty method on the service, passing the FindCriteria
List<SalesParty> sales = salesPartyService.findSalesParty(findSalesParty).getResult();
// Iterating through SalesParty List
for (int i = 0; i < sales.size(); i++) {
SalesParty sp = sales.get(i);
List<Person> persons = sp.getPersonParty();
for(int j=0; j < persons.size(); j++){
Person p = persons.get(j);
// Only PartyName attribute has been retrieved in the main FindCriteria
// fc.getFindAttribute().add("PartyName");
String partyName = sp.getPartyName().getValue();
// Only PartyUsageCode has been retrieved from the nested ChildFindCriteria
// cfc1.getFindAttribute().add("PartyUsageCode");
List<PartyUsageAssignment> usages = p.getPartyUsageAssignment();
for(int k=0; k < usages.size(); k++){
PartyUsageAssignment pua = usages.get(k);
//System.out.println("Name = " + partyName + " ** PartyUsageCode = " +
pua.getPartyUsageCode());
returnList.add("Name = " + partyName + " ** PartyUsageCode = " + pua.getPartyUsageCode());
}
}
}
} catch (Exception ex) {

Page 69 of
9898
ex.printStackTrace();
}

return returnList;
}

 Change username and password to your OSC credential and save

o Sample

String username = "Matt.Hooper";


String password = "Password12345";

 Test (right-click SalesPartyClientThree and select Run)


o Result is displayed in the JDeveloper Log window

Page 70 of
9898
7. Create a new Serv let java class

 Click File -> New

 Select HTTP Servlet and click OK

Page 71 of
9898
Page 72 of
9898
 Click Next

Page 73 of
9898
Page 74 of
9898
 Set Fields below, leave remaining as the default and click Next
o Name: SalesPartyServ let
o Package: com.oracle.pts

Page 75 of
9898
 Click Next

Page 76 of
9898
 Click Finish

 Amend SalesPartyServlet as follows and Save

package com.oracle.pts;

import com.oracle.pts.client.SalesPartyClient;

import java.io.IOException;
import java.io.PrintWriter;

import java.util.List;

import javax.servlet.*;
import javax.servlet.http.*;

Page 77 of
9898
public class SalesPartyServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows -1252";

public void init(ServletConfig config) throws ServletException {


super.init(config);
}

public void doGet(HttpServletRequest request,


HttpServletResponse response) throws ServletException,
IOException {

SalesPartyClient salesPartyClient = new SalesPartyClient();


List<String> nameList = salesPartyClient.getSalesPartyList();

response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>SalesPartyServlet</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
for(String name:nameList){
out.println("<p>Name = " + name + "</>");
}
out.println("</body></html>");
out.close();
}
}

8. Create a Deploy profiles

Page 78 of
9898
- Create a deployment profile for SalesPartyProxyProject project

 Right click SalesPartyServ iceProxy project and click Project Properties

Page 79 of
9898
 Select Deployment and click New

Page 80 of
9898
 Set Fields below, leave remaining as the default and click OK
o Archive File: War File
o Name: salesParty

Page 81 of
9898
 Set Fields below, leave remaining as the default and click OK
o Specify Java EE Web Context Root and prov ide name: SalesParty

Page 82 of
9898
Page 83 of
9898
- Create a deployment profile for PasSSasSWorkshop application

 Right click PasSSasSWorkshop application and click Application Properties

Page 84 of
9898
 Click New

Page 85 of
9898
 Set Fields below, leave remaining as the default and click OK
o Name: salesParty

Page 86 of
9898
 Select Application Assembly, check salesParty and click OK

Page 87 of
9898
 Click OK

9. Deploy salesParty application

 Right click PasSSasSWorkshop application and click salesParty

Page 88 of
9898
Page 89 of
9898
 Select Deploy to EAR

 Remember salesParty.ear output file location and click Finish

Page 90 of
9898
10. Deploy the salesParty.ear into JCS

 Login to JCS

Page 91 of
9898
Page 92 of
9898
 Click Deploy New

Page 93 of
9898
Page 94 of
9898
 Click Refresh until Deploy SalesParty application is complete

Page 95 of
9898
 Test

Page 96 of
9898
o URL: https://<Your JCS host:port>/SalesParty/salespartyserv let
o Sample: https://java2-
jcs.java.us1.oraclecloudapps.com/SalesParty/salespartyserv let

Page 97 of
9898
Oracle PaaS Extending SaaS Workshop
April 2015

Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.

Worldwide Inquiries:
Phone: +1.650.506.7000
Fax: +1.650.506.7200
oracle.com

Copyright © 2015, Oracle. All rights reserved.


This document is provided for information purposes only and the
contents hereof are subject to change without notice.
This document is not warranted to be error-free, nor subject to any
other warranties or conditions, whether expressed orally or implied
in law, including implied warranties and conditions of merchantability
or fitness for a particular purpose. We specifically disclaim an y
liability with respect to this document and no contractual obligations
are formed either directly or indirectly by this document. This document
may not be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without our prior written permission.
Oracle, JD Edwards, PeopleSoft, Fatwire and Siebel are registered trademarks of Oracle
Corporation and/or its affiliates. Other names may be trademarks
of their respective owners.

Page 98 of
9898

Potrebbero piacerti anche