
/*
 *  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
*/
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.SecurityPoliciesFeature;
// This source file is generated by Oracle tools.
// Contents may be subject to change.
// For reporting problems, use the following:
// Generated by Oracle JDeveloper 12c 12.1.2.0.0.6668
public class HelloWorldPortClient {
    public static void main(String[] args) {
        HelloWorldService helloWorldService = new HelloWorldService();

        // Configure security feature
        SecurityPoliciesFeature securityFeatures = new SecurityPoliciesFeature(new String[] {
                                                                               "oracle/wss11_saml_token_with_message_protection_client_policy" });
        HelloWorld helloWorld = helloWorldService.getHelloWorldPort(securityFeatures);
        // Add your code to call the desired methods.


    }
    
    public static String callHelloWorld(String wsdl, String address, String policy, 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 weblogic.wsee.jws.jaxws.owsm.SecurityPolicyFeature("oracle/wss11_saml_token_with_message_protection_client_policy"));
        helloWorld = helloWorldService.getHelloWorldPort(new weblogic.wsee.jws.jaxws.owsm.SecurityPolicyFeature(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);
    }
}

