In the previous post, we discussed about configuring certificates and keystore for Oracle Sales Cloud Fusion Services, in this article, we will discuss about generating JAX-WS proxy of Fusion services in a Java application using JDeveloper.
- Create Java Application
- In JDeveloper Studio, create new application and select Custom Application
- Enter Application name and click Next
- Enter Project Name and Click Next.
- In the Projects window, right click on the project name -> New -> From Gallery
- Select Web Service Client and Proxy in the right pane and click OK.
- In the Web Service Client and Proxy Wizard, enter WSDL url and click next
- Select Generate As Async, if Asynchronous method are needed else uncheck and click Next
- In the Policy selection screen, Select Oracle / wss_username_token_over_ssl_client_policy and click next.
Now that we have generated the proxy classes for the Location service, we can now add the code to use this proxy class and find locations from oracle sales cloud.
Open LocationServiceSoapHttpPortClient.java file and use the following code.
public class LocationServiceSoapHttpPortClient { public static void main(String[] args) { String username = ""; String password = ""; LocationService_Service locationService_Service = new LocationService_Service(); // Configure security feature SecurityPoliciesFeature securityFeatures = new SecurityPoliciesFeature(new String[] { "oracle/wss_username_token_over_ssl_client_policy" }); LocationService locationService = locationService_Service.getLocationServiceSoapHttpPort(securityFeatures); WSBindingProvider wsbp = (WSBindingProvider) locationService; Map<string, object=""> requestContext = wsbp.getRequestContext(); //Map to appropriate Fusion user ID, no need to provide password with SAML authentication requestContext.put(WSBindingProvider.USERNAME_PROPERTY, username); requestContext.put(WSBindingProvider.PASSWORD_PROPERTY, password); FindControl findControl = new FindControl(); FindCriteria findCriteria = new FindCriteria(); findCriteria.setFetchSize(1); LocationResult lr; try { lr = locationService.findLocation(findCriteria, findControl); List list = lr.getValue(); System.out.println("list size is: " + list.size()); System.out.println("the location id of the created location: " + lr.getValue().get(0).getLocationId()); if (list.size() == 0) { System.out.println("no locations found"); } } catch (Exception e) { System.out.println("Exception occurred in location creation:::" + e.getMessage()); e.printStackTrace(); } } }
Result:
list size is: 1
the location id of the created location: 300000001xxxxx
Hope this post was helpful for you to get started with using fusion services in JDeveloper.