Writing a Client That Can Access an Oracle Sales Cloud Application

This client exposes a SAML policy that enables message-level protection and SAML token population for outbound web service requests, which allows it to access the Oracle Sales Cloud application with which it is associated.

To create the client and expose the proper security policy, you need to:
  1. Obtain the web service descriptor (WSDL) from the service you want your Java Cloud Service - SaaS Extension application to access by issuing this command:
    service_end_point ? wsdl
    To find theservice_end_point, either use the Service Catalog Service or:
    1. Look up the web service in the Oracle Enterprise Repository to get the service path by following the instructions in Searching for Public External Services.

    2. Derive the end point by following the instructions in Deriving the Business Object Service Endpoint and WSDL.

  2. Create a client .java application; for example, helloWorld.java.
  3. Attach the security policy you will be invoking; for example, the following snippet, uses the SAML security policy oracle/wss11_saml_token_with_message_protection_client_policy, which is supported by Oracle Sales Cloud and enables message-level protection and SAML token population for outbound web service requests by using mechanisms described in WS-Security 1.1:
    package oracle.jcs.ws.sample.saml.proxy;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import java.util.Map;
    
    import javax.xml.namespace.QName;
    import javax.xml.ws.BindingProvider;
    
    import weblogic.wsee.jws.jaxws.owsm.SecurityPolicyFeature;
    
    public class HelloWorldPortClient {
        
        public static String callHelloWorld(String wsdl, String address, String issuername, String name, String username) throws MalformedURLException {
            QName serviceName = new QName("http://saml.sample.ws.jcs.oracle/", "HelloWorldService");
    
            HelloWorldService helloWorldService = new HelloWorldService(new URL(wsdl), serviceName);
            HelloWorld helloWorld = null; 
         
            helloWorld = helloWorldService.getHelloWorldPort(new SecurityPolicyFeature("oracle/wss11_saml_token_with_message_protection_client_policy"));
            
            Map<String, Object> ctxt = ((BindingProvider)helloWorld).getRequestContext();
            ctxt.put("oracle.webservices.security.saml.issuer.name", issuername);
            ctxt.put("oracle.webservices.security.recipient.key.alias", "orakey");
            ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,address);
            ctxt.put(BindingProvider.USERNAME_PROPERTY, username);
            System.out.println("Testing inbound to the Cloud");
            return helloWorld.hello(name);
        }
    }

    For additional information on security policies, see Securing JAX-WS Web Services.

  4. Package your application into a WAR file and deploy it to Java Cloud Service - SaaS Extension by using your specific IDE’s deployment process or as described in Deploying an Application.