Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.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# 从WSDL文件获取策略的复杂LINQ查询_C#_.net_Linq_Soap_Wsdl - Fatal编程技术网

C# 从WSDL文件获取策略的复杂LINQ查询

C# 从WSDL文件获取策略的复杂LINQ查询,c#,.net,linq,soap,wsdl,C#,.net,Linq,Soap,Wsdl,XDocument wsdlDocument=XDocument.Load\u wsdlPath private string GetPolicy() { XDocument wsdlDocument = XDocument.Load(_wsdlPath); XName operationElementName = XName.Get("operation", "http://schemas.xmlsoap.org/wsdl/"

XDocument wsdlDocument=XDocument.Load\u wsdlPath

 private string GetPolicy()
        {
            XDocument wsdlDocument = XDocument.Load(_wsdlPath);

            XName operationElementName = XName.Get("operation", "http://schemas.xmlsoap.org/wsdl/");
            XName policyReferenceElementName = XName.Get("PolicyReference", "http://schemas.xmlsoap.org/ws/2004/09/policy");
            XName policyElementName = XName.Get("Policy", "http://schemas.xmlsoap.org/ws/2004/09/policy");
            XName idAttributeName = XName.Get("Id", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd");

            var operationPolicy = from operation in wsdlDocument.Descendants(operationElementName)
                                  where operation.Attribute("name").Value == _operationSelected //"concat"
                                  from policyReference in operation.Descendants(policyReferenceElementName)
                                  where policyReference.Attribute("URI").Value.StartsWith("#")
                                  let uri = policyReference.Attribute("URI").Value.Substring(1)
                                  from policy in wsdlDocument.Descendants(policyElementName)
                                  where policy.Attribute(idAttributeName).Value == uri            
                                  select policy.ToString();

           string temp = operationPolicy.FirstOrDefault();
            return temp;
        }

这个问题在以后是否仍然相关?
<wsp:Policy wsu:Id="p1">
     <sp:SignedParts>
     <sp:Body />
     </sp:SignedParts>
    </wsp:Policy>
<wsp:Policy wsu:Id="p1">
 <sp:SignedParts>
 <sp:Body />
 </sp:SignedParts>
</wsp:Policy>
 private string GetPolicy()
        {
            XDocument wsdlDocument = XDocument.Load(_wsdlPath);

            XName operationElementName = XName.Get("operation", "http://schemas.xmlsoap.org/wsdl/");
            XName policyReferenceElementName = XName.Get("PolicyReference", "http://schemas.xmlsoap.org/ws/2004/09/policy");
            XName policyElementName = XName.Get("Policy", "http://schemas.xmlsoap.org/ws/2004/09/policy");
            XName idAttributeName = XName.Get("Id", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd");

            var operationPolicy = from operation in wsdlDocument.Descendants(operationElementName)
                                  where operation.Attribute("name").Value == _operationSelected //"concat"
                                  from policyReference in operation.Descendants(policyReferenceElementName)
                                  where policyReference.Attribute("URI").Value.StartsWith("#")
                                  let uri = policyReference.Attribute("URI").Value.Substring(1)
                                  from policy in wsdlDocument.Descendants(policyElementName)
                                  where policy.Attribute(idAttributeName).Value == uri            
                                  select policy.ToString();

           string temp = operationPolicy.FirstOrDefault();
            return temp;
        }
        XName operationElementName = XName.Get(Constants.OPERATION, Constants.WSDL_NS);
        XName policyReferenceElementName = XName.Get(Constants.POLICY_REFERENCE, Constants.NamespacePath.POLICY);
        XName policyElementName = XName.Get(Constants.POLICY, Constants.NamespacePath.POLICY);
        XName idAttributeName = XName.Get("Id", Constants.NamespacePath.WSSECURITY);


        var uriNo = from operation in wsdlDocument.Descendants(operationElementName)
                    where operation.HasAttributes && operation.Attribute(Constants.NAME).Value == _operationSelected
                    from policyReference in operation.Descendants(policyReferenceElementName)
                    where policyReference.HasAttributes && policyReference.Attribute(Constants.URI).Value.StartsWith(Constants.HASH)
                    select policyReference.Attribute(Constants.URI).Value.Substring(1);

        string uritemp = uriNo.FirstOrDefault().ToString();

        var operationPolicy = from policy in wsdlDocument.Descendants(policyElementName)
                              where policy.HasAttributes && policy.Attribute(idAttributeName).Value == uritemp
                              select policy;

        string temp = operationPolicy.FirstOrDefault().ToString();
        return temp;