Building Static Proxy Client for Sales Cloud
Overview
By the end of this tutorial you will be able to:
1. Create a web service proxy through JDeveloper
2. Create and use the findCriteria object
3. Import the certificate
4. Deploy an Application to JCS
Instructions
1. Create a new Application and a Project
Click File -> New
Select Generic Application and click OK
Set Fields as shown below, and leave the remaining as default. Then click Next
o Application Name: PasSSasSWorkshopA2f
o Application Package Prefix: com.apps2fusion.pts
Set Fields as shown below, leave the remaining as default and click Finish
o Project Name: SalesPartyServiceProxyA2f
2. Create a Web Service Proxy
Click File -> New
Select Web Service Proxy and click OK
Click Next
Click Next
Specify the WSDL Document URL and click Next
o WSDL Document URL : https://<Your OSC
host>/crmCommonSalesParties/SalesPartyService?WSDL
Sample: https://rws-fap1088-crm.oracledemos.com/crmCommonSalesParties/SalesPartyService?WSDL
The next step will take some time
Set Fields as shown below, leave the remaining as default and click Next
o Package Name: com.a2f.pts.salesparty.wsclient.generated
o Root Package for Generated Types: com.a2f.pts.salesparty.wsclient
o Generate As Async: uncheck
The next step will take some time
Click Next
Select Don’t generate any asynchronous methods and click Next
Select Policy and click Next
o oracle/wss_username_token_over_ssl_client_policy
Click Next
Click Finish
The next step will take some time
o View result
The following project structure will be generated:
Here is the client
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.
Open IE and type OSC SalesParty web service wsdl URL
o WSDL Document URL : https://<Your OSC
host>/crmCommonSalesParties/SalesPartyService?WSDL
Sample:
https://rws-fap1088-crm.oracledemos.com/crmCommonSalesParties/SalesPartyService?WSDL
Click on the key icon
Select View certificates
Click Install certificates
Click Next
Click Next
Click Finish
- Now you can export this cert
Click Tools -> Internet Options
Click Content -> Certificates
Click Other People, select certificate you just imported and click Export
Click Next
Click Next
Browser the location and type file name and click Next
o Sample: D:\software\fusion_app\webservice\oraclelead.cer
Click Finish
Check Trusted Certificate Keystore location by clicking Tools -> Preferences
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
In the Notepad
c:\oracle\MiddlewareJdev111171_20140227\wlserver_10.3\server\lib\DemoTrust.jks
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
<JDeveloper_Location>\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/webservice/oraclelead.cer -keystore
C:\Oracle\MiddlewareJdev111171_20140227\wlserver_10.3\server\lib\DemoTrust
.jks -alias oraclelead -storepass DemoTrustKeyStorePassPhrase
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
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
Click File -> New
Select Java Class and click OK
Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClient
o Package: com.oracle.pts.client
Amend SalesPartyClien 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;
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 44 of 99
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>
// <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>
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>
// <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("=");
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;
}
}
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
Test (right-click SalesPartyClient and select Run)
o Result is displayed in the JDeveloper Log window
5. Code the Client: Using nested criteria in a ChildFindCriteria
Click File -> New
Select Java Class and click OK
Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClientTwo
o Package: com.oracle.pts.client
Amend SalesPartyClientTwo 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;
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 55 of 99
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>
// </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>
// <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>
// <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>
// </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());
}
}
} 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
6. Code the Client: Using nested ChildFindCriteria
Click File -> New
Select Java Class and click OK
Set Fields below, leave remaining as the default and click OK
o Name: SalesPartyClientThree
o Package: com.oracle.pts.client
Amend SalesPartyClientThree 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;
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 65 of 99
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>
// <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)
// <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>
// <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>
// </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) {
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
7. Create a new Servlet java class
Click File -> New
Select HTTP Servlet and click OK
Click Next
Set Fields below, leave remaining as the default and click Next
o Name: SalesPartyServlet
o Package: com.oracle.pts
Click Next
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.*;
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
- Create a deployment profile for SalesPartyProxyProject project
Right click SalesPartyServiceProxy project and click Project Properties
Select Deployment and click New
Set Fields below, leave remaining as the default and click OK
o Archive File: War File
o Name: salesParty
Set Fields below, leave remaining as the default and click OK
o Specify Java EE Web Context Root and provide name: SalesParty
- Create a deployment profile for PasSSasSWorkshop application
Right click PasSSasSWorkshop application and click Application Properties
Click New
Set Fields below, leave remaining as the default and click OK
o Name: salesParty
Select Application Assembly, check salesParty and click OK
Click OK
9. Deploy salesParty application
Right click PasSSasSWorkshop application and click salesParty
Select Deploy to EAR
Remember salesParty.ear output file location and click Finish
10. Deploy the salesParty.ear into JCS
Login to JCS
Click Deploy New
Click Refresh until Deploy SalesParty application is complete
Test
o URL: https://<Your JCS host:port>/SalesParty/salespartyservlet
o Sample: https://java2->
jcs.java.us1.oraclecloudapps.com/SalesParty/salespartyservlet