Sample Code for an Online Application
The following example shows how an online application uses ADF to call the SAD_SAVEAPPL service operation:
1. Create the web service proxy using the WSDL URL. It will generate the proxy code (methods) to invoke the service operations.
Sample code of generated proxy:
@WebServiceClient(wsdlLocation="http://<hostname>/PSIGW/
PeopleSoftServiceListeningConnector/SAD_ADMISSIONS.1.wsdl",
targetNamespace="http://xmlns.oracle.com/Enterprise/HCM/services/SAD_ADMISSIONS.1",
name="SAD_ADMISSIONS")
public class SAD_ADMISSIONS
extends Service
{ private static URL wsdlLocationURL;
private static Logger logger;
static
{ try { logger = Logger.getLogger("sadAdmissions.SAD_ADMISSIONS");
URL baseUrl = SAD_ADMISSIONS.class.getResource(".");
if (baseUrl == null) {
wsdlLocationURL = SAD_ADMISSIONS.class.getResource("http://<hostname>/PSIGW/PeopleSoftServiceListeningConnector/SAD_ADMISSIONS.1.wsdl");
if (wsdlLocationURL == null) {
baseUrl = new File(".").toURL();
wsdlLocationURL =
new URL(baseUrl, "http://<hostname>/PSIGW/PeopleSoftServiceListeningConnector/SAD_ADMISSIONS.1.wsdl");
}
} else {
if (!baseUrl.getPath().endsWith("/")) {
baseUrl = new URL(baseUrl, baseUrl.getPath() + "/");
} wsdlLocationURL =
new URL(baseUrl, "http://<hostname>/PSIGW/PeopleSoftServiceListeningConnector/SAD_ADMISSIONS.1.wsdl");
}
} catch (MalformedURLException e)
{ logger.log(Level.ALL,
"Failed to create wsdlLocationURL using http://<hostname>/PSIGW/PeopleSoftServiceListeningConnector/SAD_ADMISSIONS.1.wsdl",
e);
}
}
//...
//...
//...
@WebEndpoint(name="SAD_ADMISSIONS_Port")
public SAD_ADMISSIONS_PortType getSAD_ADMISSIONS_Port()
{ return (SAD_ADMISSIONS_PortType) super.getPort(new QName("http://xmlns.oracle.com/Enterprise/HCM/services/SAD_ADMISSIONS.1", "SAD_ADMISSIONS_Port"),
SAD_ADMISSIONS_PortType.class);
}
//...
}
@WebMethod(operationName="SAD_SAVEAPPL", action="SAD_SAVEAPPL.v1")
@SOAPBinding(parameterStyle=ParameterStyle.BARE)
@Action(input="SAD_SAVEAPPL.v1", fault =
{ @FaultAction(value="http://xmlns.oracle.com/Enterprise/HCM/services/SAD_ADMISSIONS.1/SAD_ADMISSIONS_PortType/SAD_SAVEAPPL/Fault/SAD_FAULT_RESP.V1",
className=sadAdmissions.SAD_FAULT_RESPV1.class) }, output="http://xmlns.oracle.com/Enterprise/HCM/services/SAD_ADMISSIONS.1/SAD_ADMISSIONS_PortType/SAD_SAVEAPPL_RESP.V1")
@WebResult(targetNamespace="http://xmlns.oracle.com/Enterprise/HCM/services",
partName="parameter", name="SAD_SAVEAPPL_RESP")
public SADSAVEAPPLRESP sadSAVEAPPL(@WebParam(targetNamespace="http://xmlns.oracle.com/Enterprise/HCM/services",
partName="parameter", name="SAD_SAVEAPPL_REQ")
SADSAVEAPPLREQ parameter)
throws sadAdmissions.SAD_FAULT_RESPV1;
2. Use the proxy methods to invoke the service operation:
//Create the Application request
SADSAVEAPPLREQ reqSaveAppl = new SADSAVEAPPLREQ();
//Construct the Application request by setter methods created by web service proxy
//Create the Application response
SADSAVEAPPLRESP respSaveAppl = new SADSAVEAPPLRESP();
try {
SecurityPolicyFeature[] securityFeatures =
new SecurityPolicyFeature[] { new SecurityPolicyFeature("oracle/wss_username_token_client_policy") };
sAD_ADMISSIONS = new SAD_ADMISSIONS();
SAD_ADMISSIONS_PortType sAD_ADMISSIONS_PortType = sAD_ADMISSIONS.getSAD_ADMISSIONS_Port(securityFeatures);
Map<String, Object> requestContext = ((BindingProvider) sAD_ADMISSIONS_PortType).getRequestContext();
SAD_ADMISSIONS_PortClient.setPortCredentialProviderList(requestContext);
// Add WS-Security header username & password if we currently
authenticate (logged on)
requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
// invoke the sadSAVEAPPL method created by we service proxy
respSaveAppl = sAD_ADMISSIONS_PortType.sadSAVEAPPL(reqSaveAppl);
// pass the response (respSaveAppl) to the response handler
}
catch (SOAPFaultException sfe) {
//handle SOAP Fault
}
catch (Exception e) {
//handle any other exception
}