Oracle® Retail Service Backbone Oracle Retail Service Backbone Security Guide Release 19.0 F23586-01 |
|
Previous |
Next |
package com.oracle.retail.oms.integration.client; import java.net.URL; import java.util.Map; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import com.oracle.retail.integration.base.bo.custorderref.v1.CustOrderRef; import com.oracle.retail.integration.base.bo.nothing.v1.Nothing; import com.oracle.retail.oms.integration.services.customerorderservice.v1.CustomerOrderPortType; import com.oracle.retail.oms.integration.services.customerorderservice.v1.CustomerOrderService; import java.util.ArrayList; import java.util.List; import weblogic.wsee.security.unt.ClientUNTCredentialProvider; import weblogic.xml.crypto.wss.WSSecurityContext; import weblogic.xml.crypto.wss.provider.CredentialProvider; import weblogic.wsee.jws.jaxws.owsm.SecurityPoliciesFeature; public class CustomerClient { private void invokeHttpsService(){ try { QName qName = new QName("http://www.oracle.com/retail/oms/integration/services/CustomerOrderService/v1", "CustomerOrderService"); URL url = new URL("https://rsbhost:22004/oms-CustomerOrder-AppServiceDecorator/ProxyService/CustomerOrderAppServiceProxy?wsdl"); CustomerOrderService myService = new CustomerOrderService(url, qName); String[] policyA = new String[] { "policy:oracle/wss_username_token_over_ssl_client_policy" };SecurityPoliciesFeature securityFeatures = new SecurityPoliciesFeature(policyA);CustomerOrderPortType myServicePort = myService.getPort(CustomerOrderPortType.class, securityFeatures); List<CredentialProvider> credProviders = new ArrayList<CredentialProvider>(); // These should come from wallet in production code. String username = "rsbuser"; String password = <rsbuser password>; 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); Nothing nothing = new Nothing(); nothing.setDescription("nothing"); CustOrderRef d = myServicePort.requestNewCustomerOrderId(nothing); System.out.println("Got Response : " + d.getOrderId()); } catch(Exception e) { e.printStackTrace(); } } }