Skip to main content

Development

How to add JAX-WS Proxy of Fusion Services

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

Create Application in JDeveloper

  • Enter Application name and click Next

Enter Application Name

  • Enter Project Name and Click Next.
  • In the Projects window, right click on the project name -> New -> From Gallery

Open Gallery from New Context Menu

  • Select Web Service Client and Proxy in the right pane and click OK.

Select Web Service Client and Proxy

  • In the Web Service Client and Proxy Wizard, enter WSDL url and click next

Create Web Service Client and Proxy Wizard
 

Create Web Service Client and Proxy Wizard
 

Create Web Service Client and Proxy Wizard
 

 

Create Web Service Client and Proxy Wizard

  • Select Generate As Async, if Asynchronous method are needed else uncheck and click Next

Create Web Service Client and Proxy Wizard
 

Create Web Service Client and Proxy Wizard

  • In the Policy selection screen, Select Oracle / wss_username_token_over_ssl_client_policy and click next.

Create Web Service Client and Proxy Wizard
 

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Athaur Rahman Gudiyatham Salt

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram