Exemplo n.º 1
0
		public HttpGetMethodStubInfo (TypeStubInfo parent, LogicalMethodInfo source): base (parent, source)
		{
			ParameterReaderType = new MimeFormatterInfo (typeof(UrlParameterReader));
			ReturnWriterType = new MimeFormatterInfo (typeof(XmlReturnWriter));
			
			if (ParameterWriterType == null) ParameterWriterType = new MimeFormatterInfo (typeof(UrlParameterWriter));
		}
        public HttpGetMethodStubInfo(TypeStubInfo parent, LogicalMethodInfo source) : base(parent, source)
        {
            ParameterReaderType = new MimeFormatterInfo(typeof(UrlParameterReader));
            ReturnWriterType    = new MimeFormatterInfo(typeof(XmlReturnWriter));

            if (ParameterWriterType == null)
            {
                ParameterWriterType = new MimeFormatterInfo(typeof(UrlParameterWriter));
            }
        }
 protected override MethodStubInfo CreateMethodStubInfo(TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy)
 {
     if (isClientProxy && methodInfo.ActualMethodInfo.GetCustomAttributes(typeof(HttpMethodAttribute), true).Length == 0)
     {
         return(null);
     }
     if (!ValueCollectionParameterReader.IsSupported(methodInfo))
     {
         return(null);
     }
     return(new HttpGetMethodStubInfo(typeInfo, methodInfo));
 }
Exemplo n.º 4
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.º 5
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.º 6
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 NET_2_0
            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;
            }
#endif

            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())
                {
#if NET_2_0
                    // (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);
#endif
                }

                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);
            }
        }
Exemplo n.º 7
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 NET_2_0
            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());
                    }
                }
            }
#endif
        }
Exemplo n.º 8
0
		protected override MethodStubInfo CreateMethodStubInfo (TypeStubInfo typeInfo, LogicalMethodInfo methodInfo, bool isClientProxy)
		{
			if (isClientProxy && methodInfo.ActualMethodInfo.GetCustomAttributes (typeof(HttpMethodAttribute),true).Length == 0) return null;
			if (!ValueCollectionParameterReader.IsSupported (methodInfo)) return null;
			return new HttpGetMethodStubInfo (typeInfo, methodInfo);
		}