Esempio n. 1
0
        public Parser(WSDescriber wsDesc, ref bool untrustedSSLSecureChannel, ref List<Param> respHeader)
        {
            HttpWebRequest wr = GetHttpWebReq(wsDesc);

            HttpWebResponse wres = null;
            try
            {
                wres = (HttpWebResponse)wr.GetResponse();
            }
            catch (WebException wex)
            {
                if (wex.Status == WebExceptionStatus.TrustFailure)
                {
                    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

                    wr = GetHttpWebReq(wsDesc);
                    wres = (HttpWebResponse)wr.GetResponse();

                    untrustedSSLSecureChannel = true;
                }
            }

            if (wres != null)
            {
                for (int i = 0; i < wres.Headers.Count; ++i)
                {
                    respHeader.Add(new Param() { Name = wres.Headers.Keys[i].ToLowerInvariant(), Value = wres.Headers[i].ToLowerInvariant() });
                }

                StreamReader streamReader = new StreamReader(wres.GetResponseStream());

                rawWSDL = XDocument.Parse(streamReader.ReadToEnd());

                TextReader myTextReader = new StringReader(rawWSDL.ToString());
                serviceDescription = ServiceDescription.Read(myTextReader);

                TargetNameSpace = serviceDescription.TargetNamespace;
                bindColl = serviceDescription.Bindings;
                portTypColl = serviceDescription.PortTypes;
                msgColl = serviceDescription.Messages;
                types = serviceDescription.Types;
                schemas = types.Schemas;
            }
        }
Esempio n. 2
0
		public ServiceDescription ()
		{
			bindings = new BindingCollection (this);
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
			imports = new ImportCollection (this);
			messages = new MessageCollection (this);
#if !NET_2_0
//			name = String.Empty;		
#endif
			portTypes = new PortTypeCollection (this);

			serviceDescriptions = null;
			services = new ServiceCollection (this);
			targetNamespace = null;
			types = new Types ();
		}
Esempio n. 3
0
        public void ConstructorTest()
        {
            const string Url = "http://microsoft.com";
            const string OperationName = "TestOperationName";
            const string InputMessageName = "TestMessageInputName";
            const string OutputMessageName = "TestMessageOutputName";
            const string InputMessagePartName = "TestMessageInputPartName";
            const string OutputMessagePartName = "TestMessageOutputPartName";
            const string XmlSchemaName = "TestXmlSchemaName";
            const string XmlSchemaTypeName = "TestXmlSchemaTypeName";

            var webRequest = Mock.Create<HttpWebRequest>();
            var response = Mock.Create<WebResponse>();
            var stream = Mock.Create<Stream>();
            var serviceDescription = Mock.Create<ServiceDescription>();
            var operation = new Operation { Name = OperationName };
            var portType = new PortType { Name = "TestHttpPost" };
            var types = new Types();
            var xmlSchema = new XmlSchema();
            var item = new XmlSchemaElement();
            var complexType = new XmlSchemaComplexType();
            var sequence = new XmlSchemaSequence();
            var xmlSchemaType = new XmlQualifiedName(XmlSchemaTypeName);
            var childElement = new XmlSchemaElement { Name = XmlSchemaName, SchemaTypeName = xmlSchemaType };

            Mock.Arrange(() => WebRequest.Create(Arg.IsAny<Uri>())).Returns(webRequest);
            Mock.Arrange(() => webRequest.GetResponse()).Returns(response);
            Mock.Arrange(() => response.GetResponseStream()).Returns(stream);
            Mock.Arrange(() => ServiceDescription.Read(Arg.IsAny<Stream>())).Returns(serviceDescription);
            Mock.Arrange(() => serviceDescription.PortTypes).ReturnsCollection(new List<PortType> { portType });
            Mock.Arrange(() => portType.Operations).ReturnsCollection(new List<Operation> { operation });
            Mock.Arrange(() => operation.Messages.Input.Message.Name).Returns(InputMessageName);
            Mock.Arrange(() => operation.Messages.Output.Message.Name).Returns(OutputMessageName);
            Mock.Arrange(() => serviceDescription.Messages[InputMessageName].Parts[0].Element.Name).Returns(InputMessagePartName);
            Mock.Arrange(() => serviceDescription.Messages[OutputMessageName].Parts[0].Element.Name).Returns(OutputMessagePartName);
            Mock.Arrange(() => serviceDescription.Types).Returns(types);
            Mock.Arrange(() => types.Schemas[0]).Returns(xmlSchema);
            Mock.Arrange(() => xmlSchema.Items).Returns(new XmlSchemaObjectCollection { item });
            Mock.Arrange(() => item.Name).Returns(OutputMessagePartName);
            Mock.Arrange(() => item.SchemaType).Returns(complexType);
            Mock.Arrange(() => complexType.Particle).Returns(sequence);
            Mock.Arrange(() => sequence.Items).Returns(new XmlSchemaObjectCollection { childElement });

            WebServiceInfo.OpenWsdl(Url);

            var instance = WebServiceInfo.OpenWsdl(Url);

            Assert.AreEqual(XmlSchemaTypeName, instance.WebMethods.First().InputParameters.First().Type);
        }
		public override void Check (ConformanceCheckContext ctx, Types value)
		{
		}
Esempio n. 5
0
		public virtual void Check (ConformanceCheckContext ctx, Types value) { }
Esempio n. 6
0
		public void InitializeTypes()
		{
			types = new Types();
		}
Esempio n. 7
0
		public ServiceDescriptionReflector ()
		{
			types = new Types ();
			serviceDescriptions = new ServiceDescriptionCollection ();
		}
Esempio n. 8
0
 public override void Check(ConformanceCheckContext ctx, Types value)
 {
 }
Esempio n. 9
0
 public virtual void Check(ConformanceCheckContext ctx, Types value)
 {
 }
Esempio n. 10
0
		public ServiceDescription ()
		{
			bindings = new BindingCollection (this);
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
			imports = new ImportCollection (this);
			messages = new MessageCollection (this);
			portTypes = new PortTypeCollection (this);

			serviceDescriptions = null;
			services = new ServiceCollection (this);
			targetNamespace = null;
			types = new Types ();
		}
 private void Write67_Types(string n, string ns, Types o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(Types)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.WriteStartElement(n, ns, o, false, o.Namespaces);
         if (needType)
         {
             base.WriteXsiType("Types", "http://schemas.xmlsoap.org/wsdl/");
         }
         XmlAttribute[] extensibleAttributes = o.ExtensibleAttributes;
         if (extensibleAttributes != null)
         {
             for (int i = 0; i < extensibleAttributes.Length; i++)
             {
                 XmlAttribute node = extensibleAttributes[i];
                 base.WriteXmlAttribute(node, o);
             }
         }
         if ((o.DocumentationElement == null) && (o.DocumentationElement != null))
         {
             throw base.CreateInvalidAnyTypeException(o.DocumentationElement);
         }
         base.WriteElementLiteral(o.DocumentationElement, "documentation", "http://schemas.xmlsoap.org/wsdl/", false, true);
         ServiceDescriptionFormatExtensionCollection extensions = o.Extensions;
         if (extensions != null)
         {
             for (int j = 0; j < extensions.Count; j++)
             {
                 if (!(extensions[j] is XmlNode) && (extensions[j] != null))
                 {
                     throw base.CreateInvalidAnyTypeException(extensions[j]);
                 }
                 base.WriteElementLiteral((XmlNode) extensions[j], "", null, false, true);
             }
         }
         XmlSchemas schemas = o.Schemas;
         if (schemas != null)
         {
             for (int k = 0; k < schemas.Count; k++)
             {
                 this.Write66_XmlSchema("schema", "http://www.w3.org/2001/XMLSchema", schemas[k], false, false);
             }
         }
         base.WriteEndElement(o);
     }
 }
Esempio n. 12
0
        void ReadServiceDescription()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                XmlTextReader           reader  = new XmlTextReader(comboBox1.Text);
                Desc.ServiceDescription service =
                    Desc.ServiceDescription.Read(reader);

                //WSDLParser.WSDLParser wsdl = new EIBFormDesigner.WSDLParser.WSDLParser(service);

                comboNamespace.Items.Add(service.TargetNamespace);
                foreach (Desc.PortType pt in service.PortTypes)
                {
                    //Console.WriteLine("PortType {0}", pt.Name);

                    foreach (Desc.Operation op in pt.Operations)
                    {
                        //Console.WriteLine("\tOperation: {0}", op.Name);
                        comboBox2.Items.Add(op.Name);
                        //service.Services[service.Name].Ports[pt.Name]
                        Desc.Types types = service.Types;
                        System.Xml.Schema.XmlSchema xmlSchema = types.Schemas[0];

                        //string typeName = service.Messages[op.Messages.Input.Message.Name].FindPartByName(op.Messages.Input.Message.Name).Type.Name;
                        System.Web.Services.Description.MessagePart msgPart = service.Messages[op.Messages.Input.Message.Name].Parts["parameters"];
                        string paramElementName = null;
                        if (msgPart != null)
                        {
                            paramElementName = msgPart.Element.Name;
                            parameterMappings.Add(paramElementName, new Dictionary <string, string>());
                        }
                        foreach (object obj in xmlSchema.Items)
                        {
                            System.Xml.Schema.XmlSchemaElement sElement = obj as System.Xml.Schema.XmlSchemaElement;
                            if (sElement != null && sElement.Name == paramElementName)
                            {
                                if (sElement.SchemaType != null && sElement.SchemaType.GetType() == typeof(System.Xml.Schema.XmlSchemaComplexType))
                                {
                                    System.Xml.Schema.XmlSchemaComplexType xComplexType = sElement.SchemaType as System.Xml.Schema.XmlSchemaComplexType;
                                    TraverseParticle(xComplexType.Particle, paramElementName);
                                }
                                break;
                            }

                            /*if (obj is System.Xml.Schema.XmlSchemaComplexType)
                             * {
                             *  System.Xml.Schema.XmlSchemaComplexType xComplexType = obj as System.Xml.Schema.XmlSchemaComplexType;
                             *  if (xComplexType.Name == )
                             *  {
                             *      MessageBox.Show(xComplexType.Name + " : " + typeName);
                             *      TraverseParticle(xComplexType.ContentTypeParticle);
                             *
                             *  }
                             * }*/
                        }
                    }
                }


                //wsdl.WSDLParser parser = new wsdl.WSDLParser(service);

                //this.tvwService.Nodes.Add(parser.ServiceNode);
                //this.cboURL.Items.Add(cboURL.Text);
                //http://soap.amazon.com/schemas2/AmazonWebServices.wsdl
                //http://glkev.webs.innerhost.com/glkev_ws/weatherfetcher.asmx?wsdl
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }