Beispiel #1
0
        /// <summary>
        /// Static method to obtain instance of the OpportunityService
        /// </summary>
        /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided
        /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
        /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
        /// <param name="credentials">The credentials to be used to invoke the service</param>
        /// <returns>Instance of the OpportunityService client</returns>
        public static OpportunityServiceClient GetOpportunityServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
        {
            OpportunityServiceClient client = new OpportunityServiceClient(binding, endpointAddress);

            client.ClientCredentials.UserName.UserName = credentials.UserName;
            client.ClientCredentials.UserName.Password = credentials.Password;
            client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
            return(client);
        }
        /// <summary>
        /// Tests a call to Opportunity Service
        /// </summary>
        static void TestOpportunityService()
        {
            Console.WriteLine("TestOpportunityService");
            System.ServiceModel.Channels.Binding binding      = FaBindingFactory.GetUsernameTokenOverSslBinding();
            EndpointAddress          endpointAddress          = new EndpointAddress(new Uri("Url to the service"));
            OpportunityServiceClient opportunityServiceClient = FaServiceFactory.GetOpportunityServiceClient(binding, endpointAddress, new NetworkCredential(userName, password));

            FusionApplicationAccelerator.OpportunityServiceReference.FindCriteria findCriteria = new FusionApplicationAccelerator.OpportunityServiceReference.FindCriteria();
            findCriteria.fetchSize  = 2;
            findCriteria.fetchStart = 0;

            string[] findAttributes = new string[2] {
                "OptyId", "CustomerAccountId"
            };
            findCriteria.findAttribute = findAttributes;

            FusionApplicationAccelerator.OpportunityServiceReference.FindControl findControl = new FusionApplicationAccelerator.OpportunityServiceReference.FindControl();
            Opportunity[] result = opportunityServiceClient.findOpportunity(findCriteria, findControl);
            if (null != result && result.Length > 0)
            {
                foreach (Opportunity opportunity in result)
                {
                    Console.WriteLine("  OptyId = " + opportunity.OptyId);
                }
            }
            else
            {
                if (null == result)
                {
                    Console.WriteLine("  result null ");
                }
                else
                {
                    Console.WriteLine("  result empty ");
                }
            }
        }
 /// <summary>
 /// Static method to obtain instance of the OpportunityService
 /// </summary>
 /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided 
 /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
 /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
 /// <param name="credentials">The credentials to be used to invoke the service</param>
 /// <returns>Instance of the OpportunityService client</returns>
 public static OpportunityServiceClient GetOpportunityServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
 {
     OpportunityServiceClient client = new OpportunityServiceClient(binding, endpointAddress);
     client.ClientCredentials.UserName.UserName = credentials.UserName;
     client.ClientCredentials.UserName.Password = credentials.Password;
     client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
     return client;
 }