public MultiFilingServicePortClient getMultiFilingServiceClient() { if (multiFilingServiceClient == null) { multiFilingServiceClient = new MultiFilingServicePortClient(); setCredentials(multiFilingServiceClient, username, password); } return(multiFilingServiceClient); }
private object InitServiceObject(string serviceKey) { object portObject = null; CustomBinding binding; string wcfBinding = session.GetValue(SessionParameter.WebServicesWCFBinding) as string; if (wcfBinding != null) { binding = new CustomBinding(wcfBinding); } else { long messageSize = session.GetValue(SessionParameter.MessageSize, 4 * 1024 * 1024); List<BindingElement> elements = new List<BindingElement>(); SecurityBindingElement securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); securityElement.SecurityHeaderLayout = SecurityHeaderLayout.LaxTimestampFirst; string enableUnsecuredResponseFlag = session.GetValue(SessionParameter.WebServicesEnableUnsecuredResponse) as string; if (enableUnsecuredResponseFlag != null && enableUnsecuredResponseFlag.ToLower().Equals("true")) { PropertyInfo eur = securityElement.GetType().GetProperty("EnableUnsecuredResponse"); if (eur != null) { eur.GetSetMethod().Invoke(securityElement, new object[] { true }); } } elements.Add(securityElement); MtomMessageEncodingBindingElement mtomElement = new MtomMessageEncodingBindingElement(); mtomElement.MessageVersion = MessageVersion.Soap11; mtomElement.MaxBufferSize = (messageSize > Int32.MaxValue ? Int32.MaxValue : (int)messageSize); elements.Add(mtomElement); HttpsTransportBindingElement transportElement = new HttpsTransportBindingElement(); transportElement.MaxReceivedMessageSize = messageSize; transportElement.TransferMode = TransferMode.Streamed; transportElement.AllowCookies = true; elements.Add(transportElement); binding = new CustomBinding(elements); string openTimeOut = session.GetValue(SessionParameter.WebServicesOpenTimeout) as string; if (openTimeOut != null) { binding.OpenTimeout = TimeSpan.Parse(openTimeOut); } string closeTimeOut = session.GetValue(SessionParameter.WebServicesCloseTimeout) as string; if (closeTimeOut != null) { binding.CloseTimeout = TimeSpan.Parse(closeTimeOut); } string sendTimeOut = session.GetValue(SessionParameter.WebServicesSendTimeout) as string; if (sendTimeOut != null) { binding.SendTimeout = TimeSpan.Parse(sendTimeOut); } string receiveTimeOut = session.GetValue(SessionParameter.WebServicesReceiveTimeout) as string; if (receiveTimeOut != null) { binding.ReceiveTimeout = TimeSpan.Parse(receiveTimeOut); } } if (serviceKey == SessionParameter.WebServicesRepositoryService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesRepositoryService) as string; portObject = new RepositoryServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesNavigationService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesNavigationService) as string; portObject = new NavigationServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesObjectService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesObjectService) as string; portObject = new ObjectServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesVersioningService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesVersioningService) as string; portObject = new VersioningServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesDiscoveryService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesDiscoveryService) as string; portObject = new DiscoveryServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesRelationshipService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesRelationshipService) as string; portObject = new RelationshipServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesMultifilingService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesMultifilingService) as string; portObject = new MultiFilingServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesPolicyService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesPolicyService) as string; portObject = new PolicyServicePortClient(binding, new EndpointAddress(wsdlUrl)); } else if (serviceKey == SessionParameter.WebServicesAclService) { string wsdlUrl = session.GetValue(SessionParameter.WebServicesAclService) as string; portObject = new ACLServicePortClient(binding, new EndpointAddress(wsdlUrl)); } IAuthenticationProvider authenticationProvider = session.GetAuthenticationProvider(); if (authenticationProvider != null) { authenticationProvider.Authenticate(portObject); } return portObject; }
protected virtual void WebServicesAuthenticate(object connection) { RepositoryServicePortClient repositoryServicePortClient = connection as RepositoryServicePortClient; if (repositoryServicePortClient != null) { AddWebServicesCredentials(repositoryServicePortClient.Endpoint, repositoryServicePortClient.ClientCredentials); return; } NavigationServicePortClient navigationServicePortClient = connection as NavigationServicePortClient; if (navigationServicePortClient != null) { AddWebServicesCredentials(navigationServicePortClient.Endpoint, navigationServicePortClient.ClientCredentials); return; } ObjectServicePortClient objectServicePortClient = connection as ObjectServicePortClient; if (objectServicePortClient != null) { AddWebServicesCredentials(objectServicePortClient.Endpoint, objectServicePortClient.ClientCredentials); return; } VersioningServicePortClient versioningServicePortClient = connection as VersioningServicePortClient; if (versioningServicePortClient != null) { AddWebServicesCredentials(versioningServicePortClient.Endpoint, versioningServicePortClient.ClientCredentials); return; } DiscoveryServicePortClient discoveryServicePortClient = connection as DiscoveryServicePortClient; if (discoveryServicePortClient != null) { AddWebServicesCredentials(discoveryServicePortClient.Endpoint, discoveryServicePortClient.ClientCredentials); return; } RelationshipServicePortClient relationshipServicePortClient = connection as RelationshipServicePortClient; if (relationshipServicePortClient != null) { AddWebServicesCredentials(relationshipServicePortClient.Endpoint, relationshipServicePortClient.ClientCredentials); return; } MultiFilingServicePortClient multiFilingServicePortClient = connection as MultiFilingServicePortClient; if (multiFilingServicePortClient != null) { AddWebServicesCredentials(multiFilingServicePortClient.Endpoint, multiFilingServicePortClient.ClientCredentials); return; } PolicyServicePortClient policyServicePortClient = connection as PolicyServicePortClient; if (policyServicePortClient != null) { AddWebServicesCredentials(policyServicePortClient.Endpoint, policyServicePortClient.ClientCredentials); return; } ACLServicePortClient aclServicePortClient = connection as ACLServicePortClient; if (aclServicePortClient != null) { AddWebServicesCredentials(aclServicePortClient.Endpoint, aclServicePortClient.ClientCredentials); return; } }