2012-09-02 5 views
2

인터넷에 SOAP 프로토콜로 쿼리하려는 서비스가 있습니다. Python 용 SOAP 라이브러리를 검색 할 때이 게시물은 유익했습니다 : https://stackoverflow.com/a/206964. 그러나 내가 시도한 라이브러리 중이 특정 서비스를 위해 일한 라이브러리가 없습니다.비누 클라이언트 라이브러리

1.

from suds.client import Client 
client = Client("https://personyze.com/site/service/service/social_archive/") 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/client.py", line 109, in __init__ 
    self.wsdl = Definitions(url, options) 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/wsdl.py", line 194, in __init__ 
    self.build_schema() 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/wsdl.py", line 255, in build_schema 
    self.schema = container.load() 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/xsd/schema.py", line 92, in load 
    child.dereference() 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/xsd/schema.py", line 295, in dereference 
    midx, deps = x.dependencies() 
    File "/usr/local/lib/python2.7/dist-packages/suds-0.3.7-py2.7.egg/suds/xsd/sxbasic.py", line 330, in dependencies 
    raise TypeNotFound(self.ref) 
suds.TypeNotFound: Type not found: '(Array, http://schemas.xmlsoap.org/soap/encoding/,)' 

2.

from pysimplesoap.client import SoapClient 
client = SoapClient(wsdl="https://personyze.com/site/service/service/social_archive/", trace=True) 
client.select({"server_id":123456, "api_key":123456}, "user_id") 

많은에게 : 나는 파이썬에서 동일한 작업을 수행하기 위해 다음과 같은 시도를 한

<?php 

$client = new SoapClient('https://personyze.com/site/service/service/social_archive/', array('trace' => true)); 
$result = $client->__soapCall 
( 'select', array 
    ( array('server_id'=>123456, 'api_key'=>123456), 'user_id', null, null, false, 0, 1 
    ) 
); 
echo $client->__getLastRequestHeaders(), $client->__getLastRequest(), "RESULT:\n"; 
var_dump($result); 

을 : 나는 작동 PHP 스크립트를 보다 나은! 오늘날 최고의 결과입니다. 이 라이브러리가 잘못하는 유일한 점은 select() 대신 selectRequest() 메서드를 호출한다는 것입니다.

3.

import SOAPpy 
client = SOAPpy.SOAPProxy("https://personyze.com/site/service/service/social_archive/", "urn:SocialArchiveServiceProviderwsdl") 
client.select({"server_id":123456, "api_key":123456}, "user_id", None, None, False, 0, 2) 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Client.py", line 540, in __call__ 
    return self.__r_call(*args, **kw) 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Client.py", line 562, in __r_call 
    self.__hd, self.__ma) 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Client.py", line 464, in __call 
    p, attrs = parseSOAPRPC(r, attrs = 1) 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Parser.py", line 1074, in parseSOAPRPC 
    t = _parseSOAP(xml_str, rules = rules) 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Parser.py", line 1054, in _parseSOAP 
    parser.parse(inpsrc) 
    File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse 
    xmlreader.IncrementalParser.parse(self, source) 
    File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse 
    self.feed(buffer) 
    File "/usr/lib/python2.7/xml/sax/expatreader.py", line 207, in feed 
    self._parser.Parse(data, isFinal) 
    File "/usr/lib/python2.7/xml/sax/expatreader.py", line 338, in start_element_ns 
    AttributesNSImpl(newattrs, qnames)) 
    File "/usr/local/lib/python2.7/dist-packages/SOAPpy-0.12.6-py2.7.egg/SOAPpy/Parser.py", line 109, in startElementNS 
    "got `%s'" % toStr(name) 
SOAPpy.Errors.Error: <Error : expected `SOAP-ENV:Envelope', got `wsdl:definitions'> 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 140, in <lambda> 
    return lambda *args, **kwargs: self.wsdl_call(attr,*args,**kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 289, in wsdl_call 
    response = self.call(method, *params) 
    File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 188, in call 
    raise SoapFault(unicode(response.faultcode), unicode(response.faultstring)) 
pysimplesoap.client.SoapFault: SOAP-ENV:Server: Procedure 'selectRequest' not present 

내가이 일을하기 위해 무엇을 할 수 있는지 알려주십시오.

답변

2

서버의 WSDL 스키마가 손상된 것 같습니다. 명명 된 객체를 가져 오지 않고 참조합니다.

비눗물로 해결하는 방법은 suds documentation on fixing broken schemas을 참조하십시오.

자세한 내용은 this question을 참조하십시오.

이 나를 위해 작동하는 것 같다 :

from suds.xsd.doctor import Import 
from suds.xsd.doctor import ImportDoctor 
from suds.client import Client 


url = 'https://personyze.com/site/service/service/social_archive/' 
tns = 'urn:SocialArchiveServiceProviderwsdl' 

imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') 
imp.filter.add(tns) 
client = Client(url,plugins=[ImportDoctor(imp)]) 

print client.service.select({"server_id":123456, "api_key":123456}, "user_id") 
+0

스키마는 정말 나뉩니다. 이 서비스는 스키마를 생성하기 위해 YII Framework를 사용하며 배열을 사용할 때 유효한 스키마를 생성하지 못합니다. – jeremiah

관련 문제