Esempio n. 1
0
        [Test]         // bug #79988
        public void OutParametersTest()
        {
            IPEndPoint localEP = new IPEndPoint(IPAddress.Loopback, 5000);

            using (SocketResponder sr = new SocketResponder(localEP, s => OutParametersResponse(s))) {
                FooService service = new FooService();
                service.Url = "http://" + IPAddress.Loopback.ToString() + ":5000/";

                int     a;
                bool    b;
                Elem [] e = service.Req("x", out a, out b);
                Assert.IsNull(e, "#A1");
                Assert.AreEqual(0, a, "#A2");
                Assert.IsFalse(b, "#A3");
                service.Dispose();
            }
        }
Esempio n. 2
0
		[Test] // bug #79988
		public void OutParametersTest ()
		{
			IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 5000);
			using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (OutParametersResponse))) {
				sr.Start ();

				FooService service = new FooService ();
				service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";

				int a;
				bool b;
				Elem [] e = service.Req ("x", out a, out b);
				Assert.IsNull (e, "#A1");
				Assert.AreEqual (0, a, "#A2");
				Assert.IsFalse (b, "#A3");
				service.Dispose ();

				sr.Stop ();
			}
		}
        [Test] // bug #81886
        public void FaultTest()
        {
            IPEndPoint localEP = new IPEndPoint(IPAddress.Loopback, 5000);

            using (SocketResponder sr = new SocketResponder(localEP, new SocketRequestHandler(FaultResponse_Qualified)))
            {
                sr.Start();

                FooService service = new FooService();
                service.Url = "http://" + IPAddress.Loopback.ToString() + ":5000/";
                try
                {
                    service.Run();
                    Assert.Fail("#A1");
                }
                catch (SoapException ex)
                {
                    Assert.AreEqual("Mono Web Service", ex.Actor, "#A2");
                    Assert.AreEqual(SoapException.ServerFaultCode, ex.Code, "#A3");
                    Assert.IsNotNull(ex.Detail, "#A4");
                    Assert.AreEqual("detail", ex.Detail.LocalName, "#A5");
                    Assert.AreEqual("http://schemas.xmlsoap.org/soap/envelope/", ex.Detail.NamespaceURI, "#A6");

                    XmlNamespaceManager nsMgr = new XmlNamespaceManager(ex.Detail.OwnerDocument.NameTable);
                    nsMgr.AddNamespace("se", "http://www.mono-project/System");

                    XmlElement systemError = (XmlElement)ex.Detail.SelectSingleNode(
                        "se:systemerror", nsMgr);
                    Assert.IsNotNull(systemError, "#A7");
                    Assert.IsNull(ex.InnerException, "#A8");
                    Assert.AreEqual("Failure processing request.", ex.Message, "#A9");
                }
                service.Dispose();

                sr.Stop();
            }

            using (SocketResponder sr = new SocketResponder(localEP, new SocketRequestHandler(FaultResponse_Unqualified)))
            {
                sr.Start();

                FooService service = new FooService();
                service.Url = "http://" + IPAddress.Loopback.ToString() + ":5000/";
                try
                {
                    service.Run();
                    Assert.Fail("#B1");
                }
                catch (SoapException ex)
                {
                    Assert.AreEqual("Mono Web Service", ex.Actor, "#B2");
                    Assert.AreEqual(SoapException.ServerFaultCode, ex.Code, "#B3");
                    Assert.IsNotNull(ex.Detail, "#B4");
                    Assert.AreEqual("detail", ex.Detail.LocalName, "#B5");
                    Assert.AreEqual(string.Empty, ex.Detail.NamespaceURI, "#B6");

                    XmlNamespaceManager nsMgr = new XmlNamespaceManager(ex.Detail.OwnerDocument.NameTable);
                    nsMgr.AddNamespace("se", "http://www.mono-project/System");

                    XmlElement systemError = (XmlElement)ex.Detail.SelectSingleNode(
                        "se:systemerror", nsMgr);
                    Assert.IsNotNull(systemError, "#B7");
                    Assert.IsNull(ex.InnerException, "#B8");
                    Assert.AreEqual("Failure processing request.", ex.Message, "#B9");
                }
                service.Dispose();

                sr.Stop();
            }
        }
Esempio n. 4
0
		[Test] // bug #81886
		public void FaultTest ()
		{
			IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 5000);
			using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (FaultResponse_Qualified))) {
				sr.Start ();

				FooService service = new FooService ();
				service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";
				try {
					service.Run ();
					Assert.Fail ("#A1");
				} catch (SoapException ex) {
					Assert.AreEqual ("Mono Web Service", ex.Actor, "#A2");
					Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#A3");
					Assert.IsNotNull (ex.Detail, "#A4");
					Assert.AreEqual ("detail", ex.Detail.LocalName, "#A5");
					Assert.AreEqual ("http://schemas.xmlsoap.org/soap/envelope/", ex.Detail.NamespaceURI, "#A6");

					XmlNamespaceManager nsMgr = new XmlNamespaceManager (ex.Detail.OwnerDocument.NameTable);
					nsMgr.AddNamespace ("se", "http://www.mono-project/System");

					XmlElement systemError = (XmlElement) ex.Detail.SelectSingleNode (
						"se:systemerror", nsMgr);
					Assert.IsNotNull (systemError, "#A7");
					Assert.IsNull (ex.InnerException, "#A8");
					Assert.AreEqual ("Failure processing request.", ex.Message, "#A9");
				}
				service.Dispose ();

				sr.Stop ();
			}

			using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (FaultResponse_Unqualified))) {
				sr.Start ();

				FooService service = new FooService ();
				service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";
				try {
					service.Run ();
					Assert.Fail ("#B1");
				} catch (SoapException ex) {
					Assert.AreEqual ("Mono Web Service", ex.Actor, "#B2");
					Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#B3");
					Assert.IsNotNull (ex.Detail, "#B4");
					Assert.AreEqual ("detail", ex.Detail.LocalName, "#B5");
					Assert.AreEqual (string.Empty, ex.Detail.NamespaceURI, "#B6");

					XmlNamespaceManager nsMgr = new XmlNamespaceManager (ex.Detail.OwnerDocument.NameTable);
					nsMgr.AddNamespace ("se", "http://www.mono-project/System");

					XmlElement systemError = (XmlElement) ex.Detail.SelectSingleNode (
						"se:systemerror", nsMgr);
					Assert.IsNotNull (systemError, "#B7");
					Assert.IsNull (ex.InnerException, "#B8");
					Assert.AreEqual ("Failure processing request.", ex.Message, "#B9");
				}
				service.Dispose ();

				sr.Stop ();
			}
		}