좋아요, 그래서 SUDS는 꽤 많은 마법을 나타냅니다. suds.client.Client
는 WSDL 파일에서 구축 :
client = suds.client.Client("http://mssoapinterop.org/asmx/simple.asmx?WSDL")
그것은 WSDL을 다운로드하고 client.wsdl
의 정의를 만듭니다. client.service.<method>
을 통해 SUDS를 사용하여 메소드를 호출하면 실제로 해석 된 WSDL에 대해 많은 재귀 적 해결 마법을 수행하고 있습니다. 메소드의 매개 변수와 유형을 발견하려면이 객체를 인트로 스펙 트해야합니다. 이 같은 인쇄해야
for method in client.wsdl.services[0].ports[0].methods.values():
print '%s(%s)' % (method.name, ', '.join('%s: %s' % (part.type, part.name) for part in method.soap.input.body.parts))
: 예를 들어
echoInteger((u'int', http://www.w3.org/2001/XMLSchema): inputInteger)
echoFloatArray((u'ArrayOfFloat', http://soapinterop.org/): inputFloatArray)
echoVoid()
echoDecimal((u'decimal', http://www.w3.org/2001/XMLSchema): inputDecimal)
echoStructArray((u'ArrayOfSOAPStruct', http://soapinterop.org/xsd): inputStructArray)
echoIntegerArray((u'ArrayOfInt', http://soapinterop.org/): inputIntegerArray)
echoBase64((u'base64Binary', http://www.w3.org/2001/XMLSchema): inputBase64)
echoHexBinary((u'hexBinary', http://www.w3.org/2001/XMLSchema): inputHexBinary)
echoBoolean((u'boolean', http://www.w3.org/2001/XMLSchema): inputBoolean)
echoStringArray((u'ArrayOfString', http://soapinterop.org/): inputStringArray)
echoStruct((u'SOAPStruct', http://soapinterop.org/xsd): inputStruct)
echoDate((u'dateTime', http://www.w3.org/2001/XMLSchema): inputDate)
echoFloat((u'float', http://www.w3.org/2001/XMLSchema): inputFloat)
echoString((u'string', http://www.w3.org/2001/XMLSchema): inputString)
그래서 부분의 형태 튜플의 첫 번째 요소는 당신이있어 무엇을 아마 후 :
>>> client.factory.create(u'ArrayOfInt')
(ArrayOfInt){
_arrayType = ""
_offset = ""
_id = ""
_href = ""
_arrayType = ""
}
업데이트 :
>>> client = suds.client.Client('http://www.webservicex.net/WeatherForecast.asmx?WSDL')
>>> client.wsdl.services[0].ports[0].methods.values()[0].soap.input.body.parts[0].element
(u'GetWeatherByZipCode', http://www.webservicex.net)
>>> client.factory.create(u'GetWeatherByZipCode')
(GetWeatherByZipCode){
ZipCode = None
}
그러나이 라 client.service.GetWeatherByZipCode("12345")
메서드 호출 (의 매개 변수에 magic'd되어 날씨 서비스의 경우IT는 "매개 변수"는 element
아닌 type
와 일부임을 나타납니다. IIRC 이것은 SOAP RPC 바인딩 스타일입니까? 나는 당신이 시작하기에 충분한 정보가 여기에 있다고 생각합니다. 힌트 : 파이썬 커맨드 라인 인터페이스는 여러분의 친구입니다!
어떤 이유인지 이들은 wsdl에서 모두 "없음"이므로 매개 변수 나 형식을 얻지 못합니다. , 그들은 str (클라이언트)에 나타나고 거기에 매개 변수와 유형이 모두 있습니다. – Wyrmwood