Closed ankyo closed 6 years ago
代码
static void Main(string[] args) { var profile = DefaultProfile.GetProfile("cn-hangzhou", "************", "************"); var client = new DefaultAcsClient(profile); var request = new GetWhoisInfoRequest(); request.DomainName = "aliyun.com"; try { var response = client.GetAcsResponse<GetWhoisInfoResponse>(request); Console.WriteLine(response.DomainName); } catch(ServerException ex) { Console.WriteLine("ServerException"); Console.WriteLine(ex.ErrorCode); Console.WriteLine(ex.Message); } catch (ClientException ex) { Console.WriteLine("ClientException"); Console.WriteLine(ex.ErrorCode); Console.WriteLine(ex.Message); } //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} Console.Read(); }
出错信息
未经处理的异常: System.Xml.XPath.XPathException: 表达式的计算结果必须为节点集。 在 MS.Internal.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput, AxisType axisType, XPathNodeType nodeType) 在 MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseExpresion(AstNode qyInput) 在 MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion) 在 System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver) 在 System.Xml.XPath.XPathNavigator.Select(String xpath) 在 System.Xml.XmlNode.SelectNodes(String xpath) 在 Aliyun.Acs.Core.Reader.XmlReader.Read(XmlNode element, String path, Boolean appendPath) 在 Aliyun.Acs.Core.Reader.XmlReader.Read(XmlNode element, String path, Boolean appendPath) 在 Aliyun.Acs.Core.Reader.XmlReader.Read(String xml, String endpoint) 在 Aliyun.Acs.Core.DefaultAcsClient.ReadResponse[T](AcsRequest`1 request, HttpResponse httpResponse, Nullable`1 for 在 Aliyun.Acs.Core.DefaultAcsClient.ParseAcsResponse[T](AcsRequest`1 request, HttpResponse httpResponse) 在 Aliyun.Acs.Core.DefaultAcsClient.GetAcsResponse[T](AcsRequest`1 request)
request.AcceptFormat = FormatType.JSON; 改成JSON格式就正常 调试了一下是 XmlRead 读取失败,从 response 的 body 看内容是正确返回了的
我也遇到了这个问题
@ankyo 您好,您升级到最新版本试下,目前SDK的默认设置已经改成FormatType.JSON,谢谢您的关注!
代码
出错信息