Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 读取XML格式的WSDL文件_C#_Xml_Wsdl - Fatal编程技术网

C# 读取XML格式的WSDL文件

C# 读取XML格式的WSDL文件,c#,xml,wsdl,C#,Xml,Wsdl,我试图读取一个WSDL页面,与此类似,我试图获取操作、数据类型、输入和输出信息,并试图在C#中完成这一切。这就像读取XML文件一样吗?这里有教程吗?如果有,你能给我指出正确的方向吗 WSDL确实是一种XML格式。以下是1.1版本的官方定义: WSDL确实是一种XML格式。以下是1.1版本的官方定义: 如果您有WSDL文件位置的URL,您可以使用浏览器导航到它,它将显示(XML)内容。您还应该能够将其添加为VisualStudio项目中的(服务)引用(右键单击引用->添加服务引用) 一旦添加为对项

我试图读取一个WSDL页面,与此类似,我试图获取操作、数据类型、输入和输出信息,并试图在C#中完成这一切。这就像读取XML文件一样吗?这里有教程吗?如果有,你能给我指出正确的方向吗

WSDL确实是一种XML格式。以下是1.1版本的官方定义:


WSDL确实是一种XML格式。以下是1.1版本的官方定义:


如果您有WSDL文件位置的URL,您可以使用浏览器导航到它,它将显示(XML)内容。您还应该能够将其添加为VisualStudio项目中的(服务)引用(右键单击引用->添加服务引用)


一旦添加为对项目的引用,您应该能够使用对象浏览器查看所有方法、属性等。WSDL非常老派,因此在Web上有很多关于它的引用。

如果您有WSDL文件位置的URL,您可以使用浏览器导航到它,它将向您显示(XML)内容。您还应该能够将其添加为VisualStudio项目中的(服务)引用(右键单击引用->添加服务引用)


一旦添加为对项目的引用,您应该能够使用对象浏览器查看所有方法、属性等。WSDL非常老派,因此Web上有很多关于它的引用。

您应该通过右键单击引用文件夹并使用“添加服务引用”来添加对服务的引用。为它提供WSDL的URL,它将创建一组您可以调用的代理类


不要使用“添加Web引用”。它已过时。

您应该通过右键单击引用文件夹并使用“添加服务引用”来添加对服务的引用。为它提供WSDL的URL,它将创建一组您可以调用的代理类


不要使用“添加Web引用”。它已经过时。

使用WSDL路径调用ReturnOperationsParameters,您将拥有所需的一切

 public static void ReturnOperationsParameters(string fileName)
    {

        var reader = new XmlTextReader(fileName);
        var serviceDescription = ServiceDescription.Read(reader);
        BindingCollection bindColl = serviceDescription.Bindings;
        PortTypeCollection portTypColl = serviceDescription.PortTypes;
        MessageCollection msgColl = serviceDescription.Messages;
        Types typs = serviceDescription.Types;


        foreach (Service service in serviceDescription.Services)
        {
            String webServiceNmae = service.Name.ToString();

            foreach (Port port in service.Ports)
            {
                string portName = port.Name;
                string binding = port.Binding.Name;
                System.Web.Services.Description.Binding bind = bindColl[binding];
                PortType portTyp = portTypColl[bind.Type.Name];
                foreach (Operation op in portTyp.Operations)
                {
                    var operatioList = new SoapData();
                   // _soapdata = new SoapData();
                    OperationMessageCollection opMsgColl = op.Messages;
                    OperationInput opInput = opMsgColl.Input;
                    string inputMsg = opInput.Message.Name;
                    Message msgInput = msgColl[inputMsg];
                    MessagePart part = msgInput.Parts[0];
                    operatioList.OperationName = op.Name;


                    operatioList.NameSpace = part.Element.Namespace;

                    TreeItemSource.Add(operatioList);

                }
            }
        }

    }
}

public class SoapData
{
    public int Id { get; set; }
    public string RequestXml { get; set; }
    public string ResponseXml { get; set; }
    public string NameSpace { get; set; }
    public string OperationName { get; set; }
}

使用WSDL路径调用ReturnOperationsParameters,您将获得所需的一切

 public static void ReturnOperationsParameters(string fileName)
    {

        var reader = new XmlTextReader(fileName);
        var serviceDescription = ServiceDescription.Read(reader);
        BindingCollection bindColl = serviceDescription.Bindings;
        PortTypeCollection portTypColl = serviceDescription.PortTypes;
        MessageCollection msgColl = serviceDescription.Messages;
        Types typs = serviceDescription.Types;


        foreach (Service service in serviceDescription.Services)
        {
            String webServiceNmae = service.Name.ToString();

            foreach (Port port in service.Ports)
            {
                string portName = port.Name;
                string binding = port.Binding.Name;
                System.Web.Services.Description.Binding bind = bindColl[binding];
                PortType portTyp = portTypColl[bind.Type.Name];
                foreach (Operation op in portTyp.Operations)
                {
                    var operatioList = new SoapData();
                   // _soapdata = new SoapData();
                    OperationMessageCollection opMsgColl = op.Messages;
                    OperationInput opInput = opMsgColl.Input;
                    string inputMsg = opInput.Message.Name;
                    Message msgInput = msgColl[inputMsg];
                    MessagePart part = msgInput.Parts[0];
                    operatioList.OperationName = op.Name;


                    operatioList.NameSpace = part.Element.Namespace;

                    TreeItemSource.Add(operatioList);

                }
            }
        }

    }
}

public class SoapData
{
    public int Id { get; set; }
    public string RequestXml { get; set; }
    public string ResponseXml { get; set; }
    public string NameSpace { get; set; }
    public string OperationName { get; set; }
}

好电话。习惯的力量,因为我深陷在处理WebSphereSOAP调用的.NET2项目中,必须使用Web引用。编辑了我的答案。打得好。习惯的力量,因为我深陷在处理WebSphereSOAP调用的.NET2项目中,必须使用Web引用。编辑了我的答案。