【百度实习】soap请求失败问题排查

主要内容:

1. 问题说明

2. WSDL

3. Python测试脚本

4. 测试结果

5. 总结

1. 问题说明

soap请求方法getPosterityNodes时出现504错误。

504错误是什么
- 使用soap协议进行ws请求时,服务端超时返回,无响应

2. WSDL

生成的wsdl如下

Service ( TreeNodeInfoProviderService ) tns="urn:TreeNodeInfoProviderwsdl"
   Prefixes (1)
      ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
   Ports (1):
      (TreeNodeInfoProviderPort)
         Methods (55):
            getAncestorNodeIds(xs:int nodeId, xs:int withZero, xs:int withSelf)
            getAncestorNodes(xs:int nodeId, xs:int withZero, xs:int withSelf)
            getBudgetRelatedNodeIdsById(xs:int nodeId)
            getBudgetRelatedNodeIdsByPath(xs:string path)
            getBudgetRelatedNodesById(xs:int nodeId)
            getBudgetRelatedNodesByPath(xs:string path)
            getChildrenNodeIds(xs:int nodeId)
            getChildrenNodeIdsByUserId(xs:int nodeId, xs:int userId, xs:string funcName)
            getChildrenNodes(xs:int nodeId)
            getChildrenNodesByUserId(xs:int nodeId, xs:int userId, xs:string funcName)
            getDepartmentNodeByNodeId(xs:int nodeId)
            getDepartments()
            getNodeById(xs:int nodeId)
            getNodeByPath(xs:int treeId, xs:string path)
            getNodeIdByPath(xs:int treeId, xs:string path)
            getNodeIdsByName(xs:string name)
            getNodeIdsByPartName(xs:string name)
            getNodeIdsByPartPath(xs:string name)
            getNodeIdsByProductLineId(xs:int productLineId)
            getNodeIdsByTagType(xs:string tagType)
            getNodeIdsByTagTypeName(xs:string tagType, xs:string tagName)
            getNodeIdsByTreeIdPartPath(xs:int treeId, xs:string name)
            getNodeIdsByTreeIdProductLineName(xs:int treeId, xs:string productLineName)
            getNodePathById(xs:int nodeId)
            getNodePathsByIds(ns0:Array nodeIds)
            getNodesByName(xs:string name)
            getNodesByPartName(xs:string name)
            getNodesByPartPath(xs:string name)
            getNodesByProductLineId(xs:int productLineId)
            getNodesByProductLineName(xs:string productLineName)
            getNodesByTagTypeName(xs:string tagType, xs:string tagName)
            getNodesByTreeIdPartPath(xs:int treeId, xs:string name)
            getNumPathByNodeId(xs:int nodeId)
            getPosterityNodeIds(xs:int nodeId, xs:int withSelf)
            getPosterityNodeIdsByProductLineId(xs:int productLineId)
            getPosterityNodeIdsByProductLineName(xs:string name)
            getPosterityNodeIdsByUserId(xs:int nodeId, xs:int userId, xs:int withSelf, xs:string funcName)
            getPosterityNodes(xs:int nodeId, xs:int withSelf)
            getPosterityNodesByProductLineId(xs:int productLineId)
            getPosterityNodesByProductLineName(xs:string name)
            getPosterityNodesByUserId(xs:int nodeId, xs:int userId, xs:int withSelf, xs:string funcName)
            getProductLineById(xs:int productLineId)
            getProductLineByName(xs:string name)
            getProductLineNodeByNodeId(xs:int nodeId)
            getProductLineNodes()
            getProductLines()
            getSpecialTreeNodeFullInfoByNodeid(xs:int nodeId, xs:int userId)
            getSpecialTreeNodeInfo(xs:int nodeId)
            getSpecialTreeNodeInfoByNodeid(xs:int nodeId, xs:int userId)
            getTagNamesByTagType(xs:string tagType)
            getTagTypeNameHash()
            getTagTypes()
            proxyCall(xs:string rMethod, xs:string rParamList)
            suggestNodePaths(xs:int treeId, xs:string token, xs:int limit)
            suggestNodePathsByUserId(xs:int treeId, xs:string token, xs:int limit, xs:int userId)
         Types (48):
            ns0:Array
            ns0:ENTITIES
            ns0:ENTITY
            ns0:ID
            ns0:IDREF
            ns0:IDREFS
            ns0:NCName
            ns0:NMTOKEN
            ns0:NMTOKENS
            ns0:NOTATION
            ns0:Name
            ns0:QName
            ns0:Struct
            ns0:anyURI
            ns0:arrayCoordinate
            ns0:base64
            ns0:base64Binary
            ns0:boolean
            ns0:byte
            ns0:date
            ns0:dateTime
            ns0:decimal
            ns0:double
            ns0:duration
            ns0:float
            ns0:gDay
            ns0:gMonth
            ns0:gMonthDay
            ns0:gYear
            ns0:gYearMonth
            ns0:hexBinary
            ns0:int
            ns0:integer
            ns0:language
            ns0:long
            ns0:negativeInteger
            ns0:nonNegativeInteger
            ns0:nonPositiveInteger
            ns0:normalizedString
            ns0:positiveInteger
            ns0:short
            ns0:string
            ns0:time
            ns0:token
            ns0:unsignedByte
            ns0:unsignedInt
            ns0:unsignedLong
            ns0:unsignedShort 

3. Python测试脚本

使用Python进行soap请求,观察结果,测试脚本如下

from suds.client import  Client
from suds.xsd.doctor import ImportDoctor, Import
from suds.wsse import *
import datetime
url = 'http://st01-noah-matrix86.st01:8810/olive/index.php?r=Tree/infoWS/ws'
doctor = ImportDoctor(imp)
client = Client(url, doctor = doctor)
security = Security()
token = UsernameToken('admin', 'admin')
security.tokens.append(token)
client.set_options(wsse=security)
print(client)                           #打印输出ws提供的接口描述信息(wsdl)
starttime = datetime.datetime.now()
re = client.service.getNodeById(18)   #调用ws方法getNodeById(int)
re = client.service.getNodePathById()   #调用ws方法getNodePathById(int)
re = client.service.getPosterityNodeIds(18,1)   #调用ws方法getPosterityNodeIds(int,int),获取指定节点的所有孩子节点的id
re = client.service.getPosterityNodes(22,1)     #调用ws方法getPosterityNodes(int,int),获取指定节点的所有孩子节点详细信息
print("获取的节点内容:",re)    
endtime = datetime.datetime.now()
print ("运行时间:",(endtime - starttime).seconds) #输出调用方法运行时间

4. 测试结果

参数:nodeId=0时,可以正常返回。

调用方法 返回结果 运行时间
getNodeById root节点 0
getPosterityNodeIds 480759个孩子节点 119
getPosterityNodes None 7

参数:nodeId=1时,可以正常返回。

调用方法 返回结果 运行时间
getNodeById BAIDU节点 0
getPosterityNodeIds 476727个孩子节点 131
getPosterityNodes None 7

参数:nodeId=3时,504错误出现。

调用方法 返回结果 运行时间
getNodeById BAIDU_PS_www(产品线节点) 0
getPosterityNodeIds 61720个孩子节点 18
getPosterityNodes 无返回 504错误

参数:nodeId=22时,可以正常返回。

调用方法 返回结果 运行时间
getNodeById BAIDU_PS_www_online_rs_build_rs-build-rscompact.www.all(叶子节点) 0
getPosterityNodeIds 1个孩子节点(包括自己) 0
getPosterityNodes 可以正常返回自身的详细信息 0

参数:nodeId=18时,可以正常返回。

调用方法 返回结果 运行时间
getNodeById BAIDU_PS_www_online_rs_build(服务节点) 0
getPosterityNodeIds [18, 12055, 22, 23, 24, 200118829]共6个节点 0
getPosterityNodes 可以正常返回6个节点的详细信息 0

5. 总结

  • root节点和BAIDU公司节点在获取孩子节点的详细信息时可以正常返回,但是返回为None
  • 测试节点id = 3,该节点是一产品线节点,下面有60000多孩子节点,获取所有孩子节点id耗时18s,获取所有孩子节点详细信息时,出现504错误
  • 其余测试节点,18和22,下面的孩子节点个数比较少,都可以按时正常返回结果,并且结果符合预期

故:产生504错误的原因可能是大量查询操作耗时太久导致ws服务端未能按时返回结果导致504错误。

猜你喜欢

转载自blog.csdn.net/shannon076/article/details/78944955