Exemplo n.º 1
0
        TypeStubInfo CreateTypeStubInfo(Type type)
        {
            TypeStubInfo tsi = (TypeStubInfo)Activator.CreateInstance(type, new object[] { this });

            tsi.Initialize();
            return(tsi);
        }
Exemplo n.º 2
0
        internal TypeStubInfo GetTypeStub(string protocolName)
        {
            lock (this)
            {
                switch (protocolName)
                {
                case "Soap":
                    if (soapProtocol == null)
                    {
                        soapProtocol = new SoapTypeStubInfo(this);
                        soapProtocol.Initialize();
                    }
                    return(soapProtocol);

                case "Soap12":
                    if (soap12Protocol == null)
                    {
                        soap12Protocol = new Soap12TypeStubInfo(this);
                        soap12Protocol.Initialize();
                    }
                    return(soap12Protocol);
                }
                throw new InvalidOperationException("Protocol " + protocolName + " not supported");
            }
        }
Exemplo n.º 3
0
        protected override MethodStubInfo CreateMethodStubInfo(TypeStubInfo parent, LogicalMethodInfo lmi, bool isClientProxy)
        {
            SoapMethodStubInfo res = null;

            object [] ats = lmi.GetCustomAttributes(typeof(SoapDocumentMethodAttribute));
            if (ats.Length == 0)
            {
                ats = lmi.GetCustomAttributes(typeof(SoapRpcMethodAttribute));
            }

            if (ats.Length == 0 && isClientProxy)
            {
                return(null);
            }
            else if (ats.Length == 0)
            {
                res = new SoapMethodStubInfo(parent, lmi, null, xmlImporter, soapImporter);
            }
            else
            {
                res = new SoapMethodStubInfo(parent, lmi, ats[0], xmlImporter, soapImporter);
            }

            methods_byaction [res.Action] = res;
            return(res);
        }
Exemplo n.º 4
0
        public SoapServerMethod(Type serverType, LogicalMethodInfo methodInfo)
        {
            TypeStubInfo type = TypeStubManager.GetTypeStub(serverType, "Soap");

            info = type.GetMethod(methodInfo.Name) as SoapMethodStubInfo;
            if (info == null)
            {
                throw new InvalidOperationException("Argument methodInfo does not seem to be a member of the server type.");
            }
        }
Exemplo n.º 5
0
		public HttpSimpleMethodStubInfo (TypeStubInfo parent, LogicalMethodInfo source): base (parent, source)
		{
			object[] atts = source.CustomAttributeProvider.GetCustomAttributes (typeof(HttpMethodAttribute), true);
			if (atts.Length > 0)
			{
				HttpMethodAttribute at = (HttpMethodAttribute) atts[0];
				ParameterWriterType = new MimeFormatterInfo (at.ParameterFormatter);
				ReturnReaderType = new MimeFormatterInfo (at.ReturnFormatter);
			}
			
			if (ReturnReaderType == null) {
				if (source.IsVoid) ReturnReaderType = new MimeFormatterInfo (typeof(NopReturnReader));
				else ReturnReaderType = new MimeFormatterInfo (typeof(XmlReturnReader));
			}
		}
		//
		// Constructor
		//
		public MethodStubInfo (TypeStubInfo parent, LogicalMethodInfo source)
		{
			TypeStub = parent;
			MethodInfo = source;

			object [] o = source.GetCustomAttributes (typeof (WebMethodAttribute));
			if (o.Length > 0)
			{
				MethodAttribute = (WebMethodAttribute) o [0];
				Name = MethodAttribute.MessageName;
				if (Name == "") Name = source.Name;
			}
			else
				Name = source.Name;
		}
Exemplo n.º 7
0
        internal TypeStubInfo GetTypeStub(string protocolName)
        {
            lock (this)
            {
                switch (protocolName)
                {
                case "Soap":
                    if (soapProtocol == null)
                    {
                        soapProtocol = new SoapTypeStubInfo(this);
                        soapProtocol.Initialize();
                    }
                    return(soapProtocol);

                case "Soap12":
                    if (soap12Protocol == null)
                    {
                        soap12Protocol = new Soap12TypeStubInfo(this);
                        soap12Protocol.Initialize();
                    }
                    return(soap12Protocol);

#if !MOBILE && !XAMMAC_4_5
                case "HttpGet":
                    if (httpGetProtocol == null)
                    {
                        httpGetProtocol = new HttpGetTypeStubInfo(this);
                        httpGetProtocol.Initialize();
                    }
                    return(httpGetProtocol);

                case "HttpPost":
                    if (httpPostProtocol == null)
                    {
                        httpPostProtocol = new HttpPostTypeStubInfo(this);
                        httpPostProtocol.Initialize();
                    }
                    return(httpPostProtocol);
#endif
                }
                throw new InvalidOperationException("Protocol " + protocolName + " not supported");
            }
        }
Exemplo n.º 8
0
        //
        // Constructor
        //
        public MethodStubInfo(TypeStubInfo parent, LogicalMethodInfo source)
        {
            TypeStub   = parent;
            MethodInfo = source;

            object [] o = source.GetCustomAttributes(typeof(WebMethodAttribute));
            if (o.Length > 0)
            {
                MethodAttribute = (WebMethodAttribute)o [0];
                Name            = MethodAttribute.MessageName;
                if (Name == "")
                {
                    Name = source.Name;
                }
            }
            else
            {
                Name = source.Name;
            }
        }
        public HttpSimpleMethodStubInfo(TypeStubInfo parent, LogicalMethodInfo source) : base(parent, source)
        {
            object[] atts = source.CustomAttributeProvider.GetCustomAttributes(typeof(HttpMethodAttribute), true);
            if (atts.Length > 0)
            {
                HttpMethodAttribute at = (HttpMethodAttribute)atts[0];
                ParameterWriterType = new MimeFormatterInfo(at.ParameterFormatter);
                ReturnReaderType    = new MimeFormatterInfo(at.ReturnFormatter);
            }

            if (ReturnReaderType == null)
            {
                if (source.IsVoid)
                {
                    ReturnReaderType = new MimeFormatterInfo(typeof(NopReturnReader));
                }
                else
                {
                    ReturnReaderType = new MimeFormatterInfo(typeof(XmlReturnReader));
                }
            }
        }
Exemplo n.º 10
0
        internal TypeStubInfo GetTypeStub(string protocolName)
        {
            lock (this)
            {
                switch (protocolName)
                {
                case "Soap":
                    if (soapProtocol == null)
                    {
                        soapProtocol = CreateTypeStubInfo(typeof(SoapTypeStubInfo));
                    }
                    return(soapProtocol);

#if NET_2_0
                case "Soap12":
                    if (soap12Protocol == null)
                    {
                        soap12Protocol = CreateTypeStubInfo(typeof(Soap12TypeStubInfo));
                    }
                    return(soap12Protocol);
#endif
                case "HttpGet":
                    if (httpGetProtocol == null)
                    {
                        httpGetProtocol = CreateTypeStubInfo(typeof(HttpGetTypeStubInfo));
                    }
                    return(httpGetProtocol);

                case "HttpPost":
                    if (httpPostProtocol == null)
                    {
                        httpPostProtocol = CreateTypeStubInfo(typeof(HttpPostTypeStubInfo));
                    }
                    return(httpPostProtocol);
                }
            }
            throw new InvalidOperationException("Protocol " + protocolName + " not supported");
        }
Exemplo n.º 11
0
		//
		// Constructor
		//
		public SoapMethodStubInfo (TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
		: base (typeStub, source)
		{
			SoapTypeStubInfo parent = (SoapTypeStubInfo) typeStub;
			XmlElementAttribute optional_ns = null;

			if (kind == null) {
				Use = parent.LogicalType.BindingUse;
				RequestName = "";
				RequestNamespace = "";
				ResponseName = "";
				ResponseNamespace = "";
				ParameterStyle = parent.ParameterStyle;
				SoapBindingStyle = parent.SoapBindingStyle;
				OneWay = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
			}
			else if (kind is SoapDocumentMethodAttribute){
				SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute) kind;
				
				Use = dma.Use;
				if (Use == SoapBindingUse.Default) {
					if (parent.SoapBindingStyle == SoapBindingStyle.Document)
						Use = parent.LogicalType.BindingUse;
					else
						Use = SoapBindingUse.Literal;
				}
				
				Action = dma.Action;
				Binding = dma.Binding;
				RequestName = dma.RequestElementName;
				RequestNamespace = dma.RequestNamespace;
				ResponseName = dma.ResponseElementName;
				ResponseNamespace = dma.ResponseNamespace;
				ParameterStyle = dma.ParameterStyle;
				if (ParameterStyle == SoapParameterStyle.Default)
					ParameterStyle = parent.ParameterStyle;
				OneWay = dma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute) kind;
				Use = SoapBindingUse.Encoded;	// RPC always use encoded

				Action = rma.Action;
				if (Action != null && Action.Length == 0)
					Action = null;
				Binding = rma.Binding;
				
				// When using RPC, MS.NET seems to ignore RequestElementName and
				// MessageName, and it always uses the method name
				RequestName = source.Name;
				ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
				RequestNamespace = rma.RequestNamespace;
				ResponseNamespace = rma.ResponseNamespace;
				ParameterStyle = SoapParameterStyle.Wrapped;
				OneWay = rma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Rpc;

				// For RPC calls, make all arguments be part of the empty namespace
				optional_ns = new XmlElementAttribute ();
				optional_ns.Namespace = "";
			}

			if (OneWay){
				if (source.ReturnType != typeof (void))
					throw new Exception ("OneWay methods should not have a return value.");
				if (source.OutParameters.Length != 0)
					throw new Exception ("OneWay methods should not have out/ref parameters.");
			}
			
			BindingInfo binfo = parent.GetBinding (Binding);
			if (binfo == null) throw new InvalidOperationException ("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
			
			string serviceNamespace = binfo.Namespace;
				
			if (RequestNamespace == "") RequestNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (ResponseNamespace == "") ResponseNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (RequestName == "") RequestName = Name;
			if (ResponseName == "")	ResponseName = Name + "Response";
			if (Action == null)
				Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
			
			bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
			bool writeAccessors = (SoapBindingStyle == SoapBindingStyle.Rpc);
			
			XmlReflectionMember [] in_members = BuildRequestReflectionMembers (optional_ns);
			XmlReflectionMember [] out_members = BuildResponseReflectionMembers (optional_ns);

			if (Use == SoapBindingUse.Literal) {
				xmlImporter.IncludeTypes (source.CustomAttributeProvider);
				InputMembersMapping = xmlImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem);
				OutputMembersMapping = xmlImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem);
			}
			else {
				soapImporter.IncludeTypes (source.CustomAttributeProvider);
				InputMembersMapping = soapImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
				OutputMembersMapping = soapImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
			}

			InputMembersMapping.SetKey(RequestName);
			OutputMembersMapping.SetKey(ResponseName);

			requestSerializerId = parent.RegisterSerializer (InputMembersMapping);
			responseSerializerId = parent.RegisterSerializer (OutputMembersMapping);

			object[] o = source.GetCustomAttributes (typeof (SoapHeaderAttribute));
			ArrayList allHeaderList = new ArrayList (o.Length);
			ArrayList inHeaderList = new ArrayList (o.Length);
			ArrayList outHeaderList = new ArrayList (o.Length);
			ArrayList faultHeaderList = new ArrayList ();
			
			SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;
			
			for (int i = 0; i < o.Length; i++) {
				SoapHeaderAttribute att = (SoapHeaderAttribute) o[i];
				MemberInfo[] mems = source.DeclaringType.GetMember (att.MemberName);
				if (mems.Length == 0) throw new InvalidOperationException ("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
				
				HeaderInfo header = new HeaderInfo (mems[0], att);
				allHeaderList.Add (header);
				if (!header.Custom) {
					if ((header.Direction & SoapHeaderDirection.In) != 0)
						inHeaderList.Add (header);
					if ((header.Direction & SoapHeaderDirection.Out) != 0)
						outHeaderList.Add (header);
					if ((header.Direction & SoapHeaderDirection.Fault) != 0)
						faultHeaderList.Add (header);
				} else
					unknownHeaderDirections |= header.Direction;
			}
			
			Headers = (HeaderInfo[]) allHeaderList.ToArray (typeof(HeaderInfo));

			if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0) {
				InHeaders = (HeaderInfo[]) inHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (InHeaders);
				
				if (Use == SoapBindingUse.Literal)
					InputHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					InputHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);
				
				InputHeaderMembersMapping.SetKey(RequestName + ":InHeaders");
				
				requestHeadersSerializerId = parent.RegisterSerializer (InputHeaderMembersMapping);
			}
			
			if (outHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Out) != 0) {
				OutHeaders = (HeaderInfo[]) outHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (OutHeaders);
				
				if (Use == SoapBindingUse.Literal)
					OutputHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					OutputHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);

				OutputHeaderMembersMapping.SetKey(ResponseName + ":OutHeaders");

				responseHeadersSerializerId = parent.RegisterSerializer (OutputHeaderMembersMapping);
			}
			
			if (faultHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Fault) != 0) {
				FaultHeaders = (HeaderInfo[]) faultHeaderList.ToArray (typeof(HeaderInfo));
				XmlReflectionMember[] members = BuildHeadersReflectionMembers (FaultHeaders);
				
				if (Use == SoapBindingUse.Literal)
					FaultHeaderMembersMapping = xmlImporter.ImportMembersMapping ("", RequestNamespace, members, false);
				else
					FaultHeaderMembersMapping = soapImporter.ImportMembersMapping ("", RequestNamespace, members, false, false);
				
				faultHeadersSerializerId = parent.RegisterSerializer (FaultHeaderMembersMapping);
			}
			
			SoapExtensions = SoapExtension.GetMethodExtensions (source);
		}
		protected abstract MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy);
Exemplo n.º 13
0
        //
        // Constructor
        //
        public SoapMethodStubInfo(TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
            : base(typeStub, source)
        {
            SoapTypeStubInfo    parent      = (SoapTypeStubInfo)typeStub;
            XmlElementAttribute optional_ns = null;

            if (kind == null)
            {
                Use               = parent.LogicalType.BindingUse;
                RequestName       = "";
                RequestNamespace  = "";
                ResponseName      = "";
                ResponseNamespace = "";
                ParameterStyle    = parent.ParameterStyle;
                SoapBindingStyle  = parent.SoapBindingStyle;
                OneWay            = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
            }
            else if (kind is SoapDocumentMethodAttribute)
            {
                SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute)kind;

                Use = dma.Use;
                if (Use == SoapBindingUse.Default)
                {
                    if (parent.SoapBindingStyle == SoapBindingStyle.Document)
                    {
                        Use = parent.LogicalType.BindingUse;
                    }
                    else
                    {
                        Use = SoapBindingUse.Literal;
                    }
                }

                Action            = dma.Action;
                Binding           = dma.Binding;
                RequestName       = dma.RequestElementName;
                RequestNamespace  = dma.RequestNamespace;
                ResponseName      = dma.ResponseElementName;
                ResponseNamespace = dma.ResponseNamespace;
                ParameterStyle    = dma.ParameterStyle;
                if (ParameterStyle == SoapParameterStyle.Default)
                {
                    ParameterStyle = parent.ParameterStyle;
                }
                OneWay           = dma.OneWay;
                SoapBindingStyle = SoapBindingStyle.Document;
            }
            else
            {
                SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute)kind;
                Use = SoapBindingUse.Encoded;                   // RPC always use encoded

                Action = rma.Action;
                if (Action != null && Action.Length == 0)
                {
                    Action = null;
                }
                Binding = rma.Binding;

                // When using RPC, MS.NET seems to ignore RequestElementName and
                // MessageName, and it always uses the method name
                RequestName  = source.Name;
                ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
                RequestNamespace  = rma.RequestNamespace;
                ResponseNamespace = rma.ResponseNamespace;
                ParameterStyle    = SoapParameterStyle.Wrapped;
                OneWay            = rma.OneWay;
                SoapBindingStyle  = SoapBindingStyle.Rpc;

                // For RPC calls, make all arguments be part of the empty namespace
                optional_ns           = new XmlElementAttribute();
                optional_ns.Namespace = "";
            }

            if (OneWay)
            {
                if (source.ReturnType != typeof(void))
                {
                    throw new Exception("OneWay methods should not have a return value.");
                }
                if (source.OutParameters.Length != 0)
                {
                    throw new Exception("OneWay methods should not have out/ref parameters.");
                }
            }

            BindingInfo binfo = parent.GetBinding(Binding);

            if (binfo == null)
            {
                throw new InvalidOperationException("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
            }

            string serviceNamespace = binfo.Namespace;

            if (RequestNamespace == "")
            {
                RequestNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (ResponseNamespace == "")
            {
                ResponseNamespace = parent.LogicalType.GetWebServiceNamespace(serviceNamespace, Use);
            }
            if (RequestName == "")
            {
                RequestName = Name;
            }
            if (ResponseName == "")
            {
                ResponseName = Name + "Response";
            }
            if (Action == null)
            {
                Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
            }

            bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
            bool writeAccessors  = (SoapBindingStyle == SoapBindingStyle.Rpc);

            XmlReflectionMember [] in_members  = BuildRequestReflectionMembers(optional_ns);
            XmlReflectionMember [] out_members = BuildResponseReflectionMembers(optional_ns);

            if (Use == SoapBindingUse.Literal)
            {
                xmlImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = xmlImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem);
                OutputMembersMapping = xmlImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem);
            }
            else
            {
                soapImporter.IncludeTypes(source.CustomAttributeProvider);
                InputMembersMapping  = soapImporter.ImportMembersMapping(RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
                OutputMembersMapping = soapImporter.ImportMembersMapping(ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
            }

            requestSerializerId  = parent.RegisterSerializer(InputMembersMapping);
            responseSerializerId = parent.RegisterSerializer(OutputMembersMapping);

            object[]  o               = source.GetCustomAttributes(typeof(SoapHeaderAttribute));
            ArrayList allHeaderList   = new ArrayList(o.Length);
            ArrayList inHeaderList    = new ArrayList(o.Length);
            ArrayList outHeaderList   = new ArrayList(o.Length);
            ArrayList faultHeaderList = new ArrayList();

            SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;

            for (int i = 0; i < o.Length; i++)
            {
                SoapHeaderAttribute att  = (SoapHeaderAttribute)o[i];
                MemberInfo[]        mems = source.DeclaringType.GetMember(att.MemberName);
                if (mems.Length == 0)
                {
                    throw new InvalidOperationException("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
                }

                HeaderInfo header = new HeaderInfo(mems[0], att);
                allHeaderList.Add(header);
                if (!header.Custom)
                {
                    if ((header.Direction & SoapHeaderDirection.In) != 0)
                    {
                        inHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Out) != 0)
                    {
                        outHeaderList.Add(header);
                    }
                    if ((header.Direction & SoapHeaderDirection.Fault) != 0)
                    {
                        faultHeaderList.Add(header);
                    }
                }
                else
                {
                    unknownHeaderDirections |= header.Direction;
                }
            }

            Headers = (HeaderInfo[])allHeaderList.ToArray(typeof(HeaderInfo));

            if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0)
            {
                InHeaders = (HeaderInfo[])inHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(InHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    InputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    InputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                requestHeadersSerializerId = parent.RegisterSerializer(InputHeaderMembersMapping);
            }

            if (outHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Out) != 0)
            {
                OutHeaders = (HeaderInfo[])outHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(OutHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    OutputHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    OutputHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                responseHeadersSerializerId = parent.RegisterSerializer(OutputHeaderMembersMapping);
            }

            if (faultHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.Fault) != 0)
            {
                FaultHeaders = (HeaderInfo[])faultHeaderList.ToArray(typeof(HeaderInfo));
                XmlReflectionMember[] members = BuildHeadersReflectionMembers(FaultHeaders);

                if (Use == SoapBindingUse.Literal)
                {
                    FaultHeaderMembersMapping = xmlImporter.ImportMembersMapping("", RequestNamespace, members, false);
                }
                else
                {
                    FaultHeaderMembersMapping = soapImporter.ImportMembersMapping("", RequestNamespace, members, false, false);
                }

                faultHeadersSerializerId = parent.RegisterSerializer(FaultHeaderMembersMapping);
            }

            SoapExtensions = SoapExtension.GetMethodExtensions(source);
        }
Exemplo n.º 14
0
		internal TypeStubInfo GetTypeStub (string protocolName)
		{
			lock (this)
			{
				switch (protocolName)
				{
					case "Soap": 
						if (soapProtocol == null) soapProtocol = CreateTypeStubInfo (typeof(SoapTypeStubInfo));
						return soapProtocol;
#if NET_2_0
					case "Soap12": 
						if (soap12Protocol == null) soap12Protocol = CreateTypeStubInfo (typeof(Soap12TypeStubInfo));
						return soap12Protocol;
#endif
					case "HttpGet":
						if (httpGetProtocol == null) httpGetProtocol = CreateTypeStubInfo (typeof(HttpGetTypeStubInfo));
						return httpGetProtocol;
					case "HttpPost":
						if (httpPostProtocol == null) httpPostProtocol = CreateTypeStubInfo (typeof(HttpPostTypeStubInfo));
						return httpPostProtocol;
				}
			}
			throw new InvalidOperationException ("Protocol " + protocolName + " not supported");
		}
Exemplo n.º 15
0
		void ImportBinding (ServiceDescription desc, Service service, TypeStubInfo typeInfo, string url, BindingInfo binfo)
		{
			port = new Port ();
			port.Name = portNames.AddUnique (binfo.Name, port);
			bool bindingFull = true;

			if (binfo.Namespace != desc.TargetNamespace)
			{
				if (binfo.Location == null || binfo.Location == string.Empty)
				{
					ServiceDescription newDesc = new ServiceDescription();
					newDesc.TargetNamespace = binfo.Namespace;
					newDesc.Name = binfo.Name;
					bindingFull = ImportBindingContent (newDesc, typeInfo, url, binfo);
					if (bindingFull) {
						int id = ServiceDescriptions.Add (newDesc);
						AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
					}
				}
				else {
					AddImport (desc, binfo.Namespace, binfo.Location);
					bindingFull = true;
				}
			}
			else
				bindingFull = ImportBindingContent (desc, typeInfo, url, binfo);
				
			if (bindingFull)
			{
				port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
				
				int n = 0;
				string name = binfo.Name; 
				bool found;
				do {

					found = false;
					foreach (Port p in service.Ports)
						if (p.Name == name) { found = true; n++; name = binfo.Name + n; break; }
				}
				while (found);
				port.Name = name;
				service.Ports.Add (port);
			}

			if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.ConformsTo != WsiProfiles.None && String.IsNullOrEmpty (binfo.WebServiceBindingAttribute.Name)) {
				BasicProfileViolationCollection violations = new BasicProfileViolationCollection ();
				desc.Types.Schemas.Add (Schemas);
				ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
				col.Add (desc);
				ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
				ctx.ServiceDescription = desc;
				ConformanceChecker[] checkers = WebServicesInteroperability.GetCheckers (binfo.WebServiceBindingAttribute.ConformsTo);
				foreach (ConformanceChecker checker in checkers) {
					ctx.Checker = checker;
					WebServicesInteroperability.Check (ctx, checker, binding);
					if (violations.Count > 0)
						throw new InvalidOperationException (violations [0].ToString ());
				}
			}
		}
Exemplo n.º 16
0
		internal void Reflect (ServiceDescriptionReflector serviceReflector, Type type, string url, XmlSchemaExporter xxporter, SoapSchemaExporter sxporter)
		{
			portNames = new CodeIdentifiers ();
			this.serviceReflector = serviceReflector;
			serviceUrl = url;
			serviceType = type;
			
			schemaExporter = xxporter;
			soapSchemaExporter = sxporter;
			
			typeInfo = TypeStubManager.GetTypeStub (type, ProtocolName);
			
			ServiceDescription desc = ServiceDescriptions [typeInfo.LogicalType.WebServiceNamespace];
			
			if (desc == null)
			{
				desc = new ServiceDescription ();
				desc.TargetNamespace = typeInfo.LogicalType.WebServiceNamespace;
				desc.Name = typeInfo.LogicalType.WebServiceName;
				ServiceDescriptions.Add (desc);
			}
			
			ImportService (desc, typeInfo, url);			
		}
Exemplo n.º 17
0
 protected abstract MethodStubInfo CreateMethodStubInfo(TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy);
Exemplo n.º 18
0
		internal TypeStubInfo GetTypeStub (string protocolName)
		{
			lock (this)
			{
				switch (protocolName)
				{
				case "Soap": 
					if (soapProtocol == null){
						soapProtocol = new SoapTypeStubInfo (this);
						soapProtocol.Initialize ();
					}
					return soapProtocol;
					
				case "Soap12": 
					if (soap12Protocol == null){
						soap12Protocol = new Soap12TypeStubInfo (this);
						soap12Protocol.Initialize ();
					}
					return soap12Protocol;
#if !MOBILE
				case "HttpGet":
					if (httpGetProtocol == null){
						httpGetProtocol = new HttpGetTypeStubInfo (this);
						httpGetProtocol.Initialize ();
					}
					return httpGetProtocol;
				case "HttpPost":
					if (httpPostProtocol == null){
						httpPostProtocol = new HttpPostTypeStubInfo (this);
						httpPostProtocol.Initialize ();
					}
					return httpPostProtocol;
#endif
				}
				throw new InvalidOperationException ("Protocol " + protocolName + " not supported");
			}
		}
		protected override MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy)
		{
			return new HttpSimpleMethodStubInfo (typeInfo, methodInfo);
		}
Exemplo n.º 20
0
		protected override MethodStubInfo CreateMethodStubInfo (TypeStubInfo parent, LogicalMethodInfo lmi, bool isClientProxy)
		{
			SoapMethodStubInfo res = null;
			object [] ats = lmi.GetCustomAttributes (typeof (SoapDocumentMethodAttribute));
			if (ats.Length == 0) ats = lmi.GetCustomAttributes (typeof (SoapRpcMethodAttribute));

			if (ats.Length == 0 && isClientProxy)
				return null;
			else if (ats.Length == 0)
				res = new SoapMethodStubInfo (parent, lmi, null, xmlImporter, soapImporter);
			else
				res = new SoapMethodStubInfo (parent, lmi, ats[0], xmlImporter, soapImporter);
				
			methods_byaction [res.Action] = res;
			return res;
		}
		bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo)
		{
			serviceDescription = desc;
			
			// Look for an unused name
			
			int n=0;
			string name = binfo.Name;
			bool found;
			do
			{
				found = false;
				foreach (Binding bi in desc.Bindings)
					if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; }
			}
			while (found);
			
			// Create the binding
			
			binding = new Binding ();
			binding.Name = name;
			binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace);
			
			portType = new PortType ();
			portType.Name = binding.Name;

			BeginClass ();
			
			foreach (MethodStubInfo method in typeInfo.Methods)
			{
				methodStubInfo = method;
				
				string metBinding = ReflectMethodBinding ();
				if (typeInfo.GetBinding (metBinding) != binfo) continue;
				
				operation = new Operation ();
				operation.Name = method.OperationName;
				operation.Documentation = method.MethodAttribute.Description;
				
				inputMessage = new Message ();
				inputMessage.Name = method.Name + ProtocolName + "In";
				ServiceDescription.Messages.Add (inputMessage);
				
				outputMessage = new Message ();
				outputMessage.Name = method.Name + ProtocolName + "Out";
				ServiceDescription.Messages.Add (outputMessage);

				OperationInput inOp = new OperationInput ();
				if (method.Name != method.OperationName) inOp.Name = method.Name;
				Operation.Messages.Add (inOp);
				inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace);
				
				OperationOutput outOp = new OperationOutput ();
				if (method.Name != method.OperationName) outOp.Name = method.Name;
				Operation.Messages.Add (outOp);
				outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace);
			
				portType.Operations.Add (operation);
				ImportOperationBinding ();
				
				ReflectMethod ();
				
				foreach (SoapExtensionReflector reflector in extensionReflectors)
				{
					reflector.ReflectionContext = this;
					reflector.ReflectMethod ();
				}
			}
			
			EndClass ();
			
			if (portType.Operations.Count > 0)
			{
				desc.Bindings.Add (binding);
				desc.PortTypes.Add (portType);
				return true;
			}
			else
				return false;
		}
		protected virtual MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy)
		{
			return new MethodStubInfo (typeInfo, methodInfo);
		}
Exemplo n.º 23
0
		void ImportService (ServiceDescription desc, TypeStubInfo typeInfo, string url)
		{
			service = desc.Services [typeInfo.LogicalType.WebServiceName];
			if (service == null)
			{
				service = new Service ();
				service.Name = typeInfo.LogicalType.WebServiceName;
				service.Documentation = typeInfo.LogicalType.Description;
				desc.Services.Add (service);
			}
			
			foreach (BindingInfo binfo in typeInfo.Bindings)
				ImportBinding (desc, service, typeInfo, url, binfo);
		}
Exemplo n.º 24
0
		internal TypeStubInfo GetTypeStub (string protocolName)
		{
			lock (this)
			{
				switch (protocolName)
				{
				case "Soap": 
					if (soapProtocol == null){
						soapProtocol = new SoapTypeStubInfo (this);
						soapProtocol.Initialize ();
					}
					return soapProtocol;
					
				case "Soap12": 
					if (soap12Protocol == null){
						soap12Protocol = new Soap12TypeStubInfo (this);
						soap12Protocol.Initialize ();
					}
					return soap12Protocol;
				}
				throw new InvalidOperationException ("Protocol " + protocolName + " not supported");
			}
		}
Exemplo n.º 25
0
		bool ImportBindingContent (ServiceDescription desc, TypeStubInfo typeInfo, string url, BindingInfo binfo)
		{
			serviceDescription = desc;
			
			// Look for an unused name
			
			int n=0;
			string name = binfo.Name;
			bool found;
			do
			{
				found = false;
				foreach (Binding bi in desc.Bindings)
					if (bi.Name == name) { found = true; n++; name = binfo.Name+n; break; }
			}
			while (found);
			
			// Create the binding
			
			binding = new Binding ();
			binding.Name = name;
			binding.Type = new XmlQualifiedName (binding.Name, binfo.Namespace);
			if (binfo.WebServiceBindingAttribute != null && binfo.WebServiceBindingAttribute.EmitConformanceClaims) {
				XmlDocument doc = new XmlDocument ();
				XmlElement docElement = doc.CreateElement ("wsdl", "documentation", "http://schemas.xmlsoap.org/wsdl/");
				XmlElement claimsElement = doc.CreateElement ("wsi", "Claim", "http://ws-i.org/schemas/conformanceClaim/");
				claimsElement.Attributes.Append (doc.CreateAttribute ("conformsTo")).Value = "http://ws-i.org/profiles/basic/1.1";
				docElement.AppendChild (claimsElement);
				binding.DocumentationElement = docElement;
			}
			
			portType = new PortType ();
			portType.Name = binding.Name;

			BeginClass ();

			foreach (SoapExtensionReflector reflector in extensionReflectors)
			{
				reflector.ReflectionContext = this;
				reflector.ReflectDescription ();
			}

			foreach (MethodStubInfo method in typeInfo.Methods)
			{
				methodStubInfo = method;
				
				string metBinding = ReflectMethodBinding ();
				if (typeInfo.GetBinding (metBinding) != binfo) continue;
				
				operation = new Operation ();
				operation.Name = method.OperationName;
				operation.Documentation = method.MethodAttribute.Description;

				// FIXME: SOAP 1.1 and SOAP 1.2 should share
				// the same message definitions.

				inputMessage = new Message ();
				inputMessage.Name = method.Name + ProtocolName + "In";
				ServiceDescription.Messages.Add (inputMessage);
				
				outputMessage = new Message ();
				outputMessage.Name = method.Name + ProtocolName + "Out";
				ServiceDescription.Messages.Add (outputMessage);

				OperationInput inOp = new OperationInput ();
				if (method.Name != method.OperationName) inOp.Name = method.Name;
				Operation.Messages.Add (inOp);
				inOp.Message = new XmlQualifiedName (inputMessage.Name, ServiceDescription.TargetNamespace);
				
				OperationOutput outOp = new OperationOutput ();
				if (method.Name != method.OperationName) outOp.Name = method.Name;
				Operation.Messages.Add (outOp);
				outOp.Message = new XmlQualifiedName (outputMessage.Name, ServiceDescription.TargetNamespace);
			
				portType.Operations.Add (operation);
				ImportOperationBinding ();
				
				if (!ReflectMethod ()) {
					// (It is somewhat hacky) If we don't
					// add input/output Messages, update
					// portType/input/@message and
					// porttype/output/@message.
					Message dupIn = Parent.MappedMessagesIn [method.MethodInfo];
					ServiceDescription.Messages.Remove (inputMessage);
					inOp.Message = new XmlQualifiedName (dupIn.Name, ServiceDescription.TargetNamespace);
					Message dupOut = Parent.MappedMessagesOut [method.MethodInfo];
					ServiceDescription.Messages.Remove (outputMessage);
					outOp.Message = new XmlQualifiedName (dupOut.Name, ServiceDescription.TargetNamespace);
				}

				foreach (SoapExtensionReflector reflector in extensionReflectors)
				{
					reflector.ReflectionContext = this;
					reflector.ReflectMethod ();
				}
			}
			
			EndClass ();
			
			if (portType.Operations.Count > 0)
			{
				desc.Bindings.Add (binding);
				desc.PortTypes.Add (portType);
				return true;
			}
			else
				return false;
		}
		void ImportBinding (ServiceDescription desc, Service service, TypeStubInfo typeInfo, string url, BindingInfo binfo)
		{
			port = new Port ();
			port.Name = portNames.AddUnique (binfo.Name, port);
			bool bindingFull = true;

			if (binfo.Namespace != desc.TargetNamespace)
			{
				if (binfo.Location == null || binfo.Location == string.Empty)
				{
					ServiceDescription newDesc = new ServiceDescription();
					newDesc.TargetNamespace = binfo.Namespace;
					newDesc.Name = binfo.Name;
					bindingFull = ImportBindingContent (newDesc, typeInfo, url, binfo);
					if (bindingFull) {
						int id = ServiceDescriptions.Add (newDesc);
						AddImport (desc, binfo.Namespace, GetWsdlUrl (url,id));
					}
				}
				else {
					AddImport (desc, binfo.Namespace, binfo.Location);
					bindingFull = true;
				}
			}
			else
				bindingFull = ImportBindingContent (desc, typeInfo, url, binfo);
				
			if (bindingFull)
			{
				port.Binding = new XmlQualifiedName (binding.Name, binfo.Namespace);
				service.Ports.Add (port);
			}
		}