public static IFGSMSNetService getproxyWithMonitor(string _url_internal) { BasicHttpBinding b = null; b = new BasicHttpBinding(BasicHttpSecurityMode.None); b.MaxBufferSize = Int32.MaxValue; b.MaxReceivedMessageSize = Int32.MaxValue; b.MaxBufferPoolSize = Int32.MaxValue; b.TransferMode = TransferMode.Buffered; b.ReaderQuotas.MaxArrayLength = Int32.MaxValue; b.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; b.ReaderQuotas.MaxDepth = Int32.MaxValue; b.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue; b.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; b.ReceiveTimeout = new TimeSpan(0, 5, 0); b.SendTimeout = new TimeSpan(0, 5, 0); b.UseDefaultWebProxy = true; b.TextEncoding = Encoding.UTF8; b.OpenTimeout = new TimeSpan(0, 0, 5); //b.Namespace = "urn:org.miloss.FGSMS.services.interfaces.policyConfiguration"; b.MessageEncoding = WSMessageEncoding.Text; b.CloseTimeout = new TimeSpan(0, 0, 5); b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; ChannelFactory <IFGSMSNetService> factory = new ChannelFactory <IFGSMSNetService>(b, _url_internal); b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; factory.Endpoint.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFClientEndpointBehavior)); factory.Endpoint.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFClientEndpointBehavior()); IFGSMSNetService polservice = factory.CreateChannel(); return(polservice); }
public SomeComplexReturnObject getDataViaChain(SomeComplexRequestObject request) { IFGSMSNetService anotherendpoint = WCFtTests.getproxyWithMonitor(TC00134.urlSecondHop); SomeComplexReturnObject r = anotherendpoint.getData(request); ((IClientChannel)anotherendpoint).Close(); ((IClientChannel)anotherendpoint).Dispose(); r.stderr += " hi via chaining!!"; return(r); }
void dowork_TC00134_ALL_SELF_HOSTED(bool recordrequest, bool recordresponse) { CommonUtils.RemoveService(urlFirstHop); CommonUtils.RemoveService(urlSecondHop); CommonUtils.SetPolicy(urlFirstHop, recordrequest, recordresponse); CommonUtils.SetPolicy(urlSecondHop, recordrequest, recordresponse); try { MessageProcessor mp = MessageProcessor.Instance; MessageProcessor.PurgePolicyCache(); MessageProcessor.PurgeOutboundQueue(); Assert.IsTrue(MessageProcessor.GetPolicyCacheSize() == 0); Assert.IsTrue(MessageProcessor.GetQueueSize() == 0); ServiceHost host = new ServiceHost(typeof(FGSMSNetServiceImpl)); host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior)); host.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior()); host.Open(); ServiceHost host2 = new ServiceHost(typeof(FGSMSNetServiceImpl2)); host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior)); host2.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior()); host2.Open(); IFGSMSNetService svc = WCFtTests.getproxyWithMonitor(urlFirstHop); SomeComplexRequestObject req = new SomeComplexRequestObject(); req.stdout = "hi"; SomeComplexReturnObject ret = svc.getDataViaChain(req); Thread.Sleep(10000); DateTime timeout = DateTime.Now.AddMinutes(2); Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize()); while (MessageProcessor.GetQueueSize() > 0 && DateTime.Now < timeout) { Thread.Sleep(1000); } ((IClientChannel)svc).Close(); ((IClientChannel)svc).Dispose(); host.Close(); host2.Close(); } catch (Exception ex) { string _err = ""; while (ex != null) { _err += ex.Message + " " + ex.StackTrace; ex = ex.InnerException; } CommonUtils.RemoveService(urlFirstHop); CommonUtils.RemoveService(urlSecondHop); Assert.Fail(_err); } Thread.Sleep(10000); string err = ""; if (MessageProcessor.GetPolicyCacheSize() == 0) { err += "policy cache is empty, it should have at least one item in it"; } if (!String.IsNullOrEmpty(MessageProcessor.LastErrorMessage)) { err += "agent error " + MessageProcessor.LastErrorMessage; } TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(urlFirstHop, true); if (tp == null) { err += "the policy for the service was not cached, which means something went wrong" + urlFirstHop; } tp = MessageProcessor.GetPolicyIfAvailable(urlSecondHop, true); if (tp == null) { err += "the policy for the service was not cached, which means something went wrong" + urlSecondHop; } // err += CommonUtils.VerifyLastMessagePayloads(urlFirstHop, recordrequest, recordresponse, 2); //err += CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(urlFirstHop); err += CommonUtils.VerifyServiceChainingEvents(urlFirstHop, urlSecondHop, recordrequest, recordresponse); CommonUtils.RemoveService(urlFirstHop); CommonUtils.RemoveService(urlSecondHop); if (!String.IsNullOrEmpty(err)) { Assert.Fail(err); } }