private static modelPortType openConnection() { //WebRequest.DefaultWebProxy = new WebProxy("127.0.0.1", 8888); // uncomment this line if you want to use fiddler modelPortTypeClient service = new modelPortTypeClient(); service.ClientCredentials.UserName.UserName = LOGIN_USERNAME; service.ClientCredentials.UserName.Password = LOGIN_PASSWORD; service.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader(LOGIN_USERNAME, LOGIN_PASSWORD)))); try { return(service.ChannelFactory.CreateChannel(new EndpointAddress(WS_URL))); } catch (Exception e) { throw e; } }
private static modelPortType openConnection() { //WebRequest.DefaultWebProxy = new WebProxy("127.0.0.1", 8888); // uncomment this line if you want to use fiddler modelPortTypeClient service = new modelPortTypeClient(); service.ClientCredentials.UserName.UserName = LOGIN_USERNAME; service.ClientCredentials.UserName.Password = LOGIN_PASSWORD; service.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader(LOGIN_USERNAME, LOGIN_PASSWORD)))); try { return service.ChannelFactory.CreateChannel(new EndpointAddress(WS_URL)); } catch (Exception e) { throw e; } }
/// <summary> /// Creates a new model port for with the administrator credentials. /// Has a default endpoint URL but this can be overridden by passing in a value for the first element in the args parameter. /// </summary> /// <param name="args">If the first argument is defined it overrides the default endpoint URL. Any other args are ignored.</param> /// <returns>The new model port.</returns> public static modelPortType createModelPort(String[] args) { string endpointUrl = DEFAULT_ENDPOINT_URL; if (args.Length > 0) { endpointUrl = args[0]; } modelPortTypeClient modelService = new modelPortTypeClient(); modelService.ClientCredentials.UserName.UserName = ADM_USERNAME; modelService.ClientCredentials.UserName.Password = ADM_PASSWORD; modelService.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader(ADM_USERNAME, ADM_PASSWORD)))); modelPortType modelPort = modelService.ChannelFactory.CreateChannel(new EndpointAddress(endpointUrl)); return modelPort; }