Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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:
Page 2 of
9898
Instructions
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
Page 7 of
9898
Click Next
Page 8 of
9898
Click Next
Page 9 of
9898
Specify WSDL Document URL and click Next
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
Page 14 of
9898
Click Next
Page 15 of
9898
Click Finish
Page 16 of
9898
- This will take some time
o View result
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
Page 20 of
9898
Click key icon
Page 21 of
9898
Page 22 of
9898
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
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
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
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
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
Page 39 of
9898
Click File -> New
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
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 SalesPartyClient() {
super();
init();
}
public static void main(String[] args){
SalesPartyClient salesPartyClient = new SalesPartyClient();
salesPartyClient.work();
}
System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "youUserName";
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);
}
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;
//
// <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>
// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.
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>
// <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>
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);
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
}
o Sample
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
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
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;
System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "yourUserName";
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);
}
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>
// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.
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);
// <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>
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;
}
o Sample
Page 60 of
9898
6. Code the Client: Using nested ChildFindCriteria
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
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;
System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.Transfo
rmerFactoryImpl");
String username = "yourUserName";
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);
}
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>
// Here is the filter to retrieve all SalesParties that are persons and active.
// Note that PartyType and Status are top level fields.
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);
// <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;
}
o Sample
Page 70 of
9898
7. Create a new Serv let java class
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
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";
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();
}
}
Page 78 of
9898
- Create a deployment profile for SalesPartyProxyProject project
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
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
Page 88 of
9898
Page 89 of
9898
Select Deploy to EAR
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
Page 98 of
9898