Go to primary content
Oracle® Retail Integration Cloud Service Implementation Guide–Concepts
Release 22.1.302.0
F60189-01
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

B Appendix - SOAP Publisher Client Sample Code

import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
 
import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature;
import weblogic.wsee.security.unt.ClientUNTCredentialProvider;
import weblogic.xml.crypto.wss.WSSecurityContext;
import weblogic.xml.crypto.wss.provider.CredentialProvider;
 
 
import com.oracle.retail.service.ApplicationMessagePublishingPortType;
import com.oracle.retail.service.ApplicationMessagePublishingService;
 
public class RibApplicationMessagePolicyATester {
 
private void publishMessages(String nameSpace, String serviceName, String urlString, String userName, String password ,String payloadXmlPath) {
   try {   
        QName qName = new QName(nameSpace, serviceName);
        URL url = new URL(urlString);
        ApplicationMessagePublishingService myService = new ApplicationMessagePublishingService(url, qName);
        String[] policyA = new String[] { "policy:oracle/wss_username_token_over_ssl_client_policy" };
 
            SecurityPoliciesFeature securityFeatures = new SecurityPoliciesFeature(policyA);
            ApplicationMessagePublishingPortType myServicePort = myService.getPort(ApplicationMessagePublishingPortType.class, securityFeatures);            
            List<CredentialProvider> credProviders = new ArrayList<CredentialProvider>();
            CredentialProvider cp = new ClientUNTCredentialProvider(userName.getBytes(), password.getBytes());
            credProviders.add(cp);
            BindingProvider bindingProvider = (BindingProvider) myServicePort;
            Map<String, Object> requestContext = bindingProvider.getRequestContext();            
            requestContext.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST, credProviders);
            requestContext.put(BindingProvider.USERNAME_PROPERTY, userName);
            requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
            PublisherUtility testPublisher = new PublisherUtility();
            myServicePort.publishMessages(testPublisher.transformRibMessageVoToApplicationMessages(payloadXmlPath));
            System.out.println("Message publishing ends .......");
 
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    public static void main(String[] args) {
        try {
 
            String serviceName = "ApplicationMessagePublishingService";
            String urlString = "https://rex.retail.us-phoenix-1.ocs.oc-test.com:443/rgbu-rex-rgbu-dev1-rics/rib-ext-services-web/ApplicationMessagePublishingService?WSDL";
            String userName = <IDCS Login user>
            String password = <IDCS Login Password>                      
            String nameSpace = "http://www.oracle.com/retail/rib/integration/services/ApplicationMessagePublishingService/v1";
            String serviceName = "ApplicationMessagePublishingService";
            String payloadXMLPath = <pick the payload from sample XML>;
                        
 
            RibApplicationMessagePolicyATester tester = new RibApplicationMessagePolicyATester();
            tester.ping(nameSpace, serviceName, urlString, userName, password);
            tester.publishMessages(nameSpace, serviceName, urlString, userName, password,payloadXMLPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}