public void WcfBasicHttpBinding()
        {
            using (ServiceHost host = new ServiceHost(typeof(WcfServiceImpl), new Uri("http://localhost:8000/WcfBasicHttpBinding/Service")))
            {
                host.AddServiceEndpoint(typeof(IWcfService), new BasicHttpBinding(), string.Empty);

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                host.Description.Behaviors.Add(smb);

                host.Open();

                WebServiceProxyFactory wspf = new WebServiceProxyFactory();
                wspf.ServiceUri       = new UrlResource("http://localhost:8000/WcfBasicHttpBinding/Service");
                wspf.ServiceInterface = typeof(IWcfService);
                wspf.AfterPropertiesSet();

                object proxy = wspf.GetObject();
                Assert.IsNotNull(proxy);

                Type proxyType = proxy.GetType();
                Assert.IsTrue(proxy is IWcfService);
                Assert.IsTrue(proxy is SoapHttpClientProtocol);

                IWcfService srv = proxy as IWcfService;
                Assert.AreEqual("5", srv.WcfMethod(5));
            }
        }
        public void RpcLiteralWithMessageName()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/rpc-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            MethodInfo logHelloMethod = proxyType.GetMethod("LogHello");
            Assert.IsNotNull(logHelloMethod);

            object[] methodAttrs = logHelloMethod.GetCustomAttributes(typeof(SoapRpcMethodAttribute), false);
            Assert.IsTrue(methodAttrs.Length > 0);

            SoapRpcMethodAttribute srma = (SoapRpcMethodAttribute)methodAttrs[0];
            Assert.AreEqual("http://www.springframwework.net/MyLogHello", srma.Action);
            Assert.AreEqual(string.Empty, srma.Binding);
            Assert.AreEqual(false, srma.OneWay);
            Assert.AreEqual(string.Empty, srma.RequestElementName);
            Assert.AreEqual("http://www.springframwework.net", srma.RequestNamespace);
            Assert.AreEqual(string.Empty, srma.ResponseElementName);
            Assert.AreEqual("http://www.springframwework.net", srma.ResponseNamespace);
            Assert.AreEqual(SoapBindingUse.Literal, srma.Use);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void DocumentLiteralWithDefaultConfig()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();

            wspf.ServiceUri       = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/document-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();

            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();

            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            object[] typeAttrs = proxyType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false);
            Assert.IsTrue(typeAttrs.Length > 0);

            WebServiceBindingAttribute wsba = (WebServiceBindingAttribute)typeAttrs[0];

            Assert.AreEqual("HelloWorldServiceSoap", wsba.Name);
            Assert.AreEqual("http://www.springframwework.net", wsba.Namespace);

            MethodInfo sayHelloWorldMethod = proxyType.GetMethod("SayHelloWorld");

            Assert.IsNotNull(sayHelloWorldMethod);

            object[] sdmaAttrs = sayHelloWorldMethod.GetCustomAttributes(typeof(SoapDocumentMethodAttribute), false);
            Assert.IsTrue(sdmaAttrs.Length > 0);

            SoapDocumentMethodAttribute sdma = (SoapDocumentMethodAttribute)sdmaAttrs[0];

            Assert.AreEqual("http://www.springframwework.net/SayHelloWorld", sdma.Action);
            Assert.AreEqual(SoapParameterStyle.Wrapped, sdma.ParameterStyle);
            Assert.AreEqual(string.Empty, sdma.Binding);
            Assert.AreEqual(false, sdma.OneWay);
            Assert.AreEqual(string.Empty, sdma.RequestElementName);
            Assert.AreEqual("http://www.springframwework.net", sdma.RequestNamespace);
            Assert.AreEqual(string.Empty, sdma.ResponseElementName);
            Assert.AreEqual("http://www.springframwework.net", sdma.ResponseNamespace);
            Assert.AreEqual(SoapBindingUse.Literal, sdma.Use);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void WrapProxyType()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ProxyType = typeof(FakeProxyClass);
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void NestedSchema()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
			// cf Post Build Events
            wspf.ServiceUri = new FileSystemResource("file://~/Spring/Web/Services/nestedSchema.wsdl");
            wspf.ServiceInterface = typeof(INestedSchema);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is INestedSchema);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void UseCustomClientProtocolType()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/document-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.WebServiceProxyBaseType = typeof(CustomClientProtocol);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);
            Assert.IsTrue(proxy is CustomClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void DocumentLiteralWithDefaultConfig()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/document-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            object[] typeAttrs = proxyType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false);
            Assert.IsTrue(typeAttrs.Length > 0);

            WebServiceBindingAttribute wsba = (WebServiceBindingAttribute)typeAttrs[0];
            Assert.AreEqual("HelloWorldServiceSoap", wsba.Name);
            Assert.AreEqual("http://www.springframwework.net", wsba.Namespace);

            MethodInfo sayHelloWorldMethod = proxyType.GetMethod("SayHelloWorld");
            Assert.IsNotNull(sayHelloWorldMethod);

            object[] sdmaAttrs = sayHelloWorldMethod.GetCustomAttributes(typeof(SoapDocumentMethodAttribute), false);
            Assert.IsTrue(sdmaAttrs.Length > 0);

            SoapDocumentMethodAttribute sdma = (SoapDocumentMethodAttribute)sdmaAttrs[0];
            Assert.AreEqual("http://www.springframwework.net/SayHelloWorld", sdma.Action);
            Assert.AreEqual(SoapParameterStyle.Wrapped, sdma.ParameterStyle);
            Assert.AreEqual(string.Empty, sdma.Binding);
            Assert.AreEqual(false, sdma.OneWay);
            Assert.AreEqual(string.Empty, sdma.RequestElementName);
            Assert.AreEqual("http://www.springframwework.net", sdma.RequestNamespace);
            Assert.AreEqual(string.Empty, sdma.ResponseElementName);
            Assert.AreEqual("http://www.springframwework.net", sdma.ResponseNamespace);
            Assert.AreEqual(SoapBindingUse.Literal, sdma.Use);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void BailsWhenNotConfigured()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();

            wspf.AfterPropertiesSet();
        }
        public void BailsWhenNotConfigured()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();

            Assert.Throws <ArgumentException>(() => wspf.AfterPropertiesSet());
        }
        public void WcfBasicHttpBinding()
        {
            using (ServiceHost host = new ServiceHost(typeof(WcfServiceImpl), new Uri("http://localhost:8000/WcfBasicHttpBinding/Service")))
            {
                host.AddServiceEndpoint(typeof(IWcfService), new BasicHttpBinding(), string.Empty);

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                host.Description.Behaviors.Add(smb);

                host.Open();

                WebServiceProxyFactory wspf = new WebServiceProxyFactory();
                wspf.ServiceUri = new UrlResource("http://localhost:8000/WcfBasicHttpBinding/Service");
                wspf.ServiceInterface = typeof(IWcfService);
                wspf.AfterPropertiesSet();

                object proxy = wspf.GetObject();
                Assert.IsNotNull(proxy);

                Type proxyType = proxy.GetType();
                Assert.IsTrue(proxy is IWcfService);
                Assert.IsTrue(proxy is SoapHttpClientProtocol);

                IWcfService srv = proxy as IWcfService;
                Assert.AreEqual("5", srv.WcfMethod(5));
            }
        }
        public void NestedSchema()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
			// cf Post Build Events
            wspf.ServiceUri = new FileSystemResource("file://~/Spring/Web/Services/nestedSchema.wsdl");
            wspf.ServiceInterface = typeof(INestedSchema);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is INestedSchema);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void UseCustomClientProtocolType()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/document-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.WebServiceProxyBaseType = typeof(CustomClientProtocol);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);
            Assert.IsTrue(proxy is CustomClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
 public void BailsWhenNotConfigured()
 {
     WebServiceProxyFactory wspf = new WebServiceProxyFactory();
     Assert.Throws<ArgumentException>(() => wspf.AfterPropertiesSet());
 }
        public void WrapProxyType()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ProxyType = typeof(FakeProxyClass);
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
        public void RpcLiteralWithMessageName()
        {
            WebServiceProxyFactory wspf = new WebServiceProxyFactory();
            wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/rpc-literal.wsdl");
            wspf.ServiceInterface = typeof(IHelloWorld);
            wspf.AfterPropertiesSet();

            object proxy = wspf.GetObject();
            Assert.IsNotNull(proxy);

            Type proxyType = proxy.GetType();
            Assert.IsTrue(proxy is IHelloWorld);
            Assert.IsTrue(proxy is SoapHttpClientProtocol);

            MethodInfo logHelloMethod = proxyType.GetMethod("LogHello");
            Assert.IsNotNull(logHelloMethod);

            object[] methodAttrs = logHelloMethod.GetCustomAttributes(typeof(SoapRpcMethodAttribute), false);
            Assert.IsTrue(methodAttrs.Length > 0);

            SoapRpcMethodAttribute srma = (SoapRpcMethodAttribute)methodAttrs[0];
            Assert.AreEqual("http://www.springframwework.net/MyLogHello", srma.Action);
            Assert.AreEqual(string.Empty, srma.Binding);
            Assert.AreEqual(false, srma.OneWay);
            Assert.AreEqual(string.Empty, srma.RequestElementName);
            Assert.AreEqual("http://www.springframwework.net", srma.RequestNamespace);
            Assert.AreEqual(string.Empty, srma.ResponseElementName);
            Assert.AreEqual("http://www.springframwework.net", srma.ResponseNamespace);
            Assert.AreEqual(SoapBindingUse.Literal, srma.Use);

            // Try to instantiate the proxy type
            ObjectUtils.InstantiateType(proxyType);
        }
 public void BailsWhenNotConfigured()
 {
     WebServiceProxyFactory wspf = new WebServiceProxyFactory();
     wspf.AfterPropertiesSet();
 }