2009-03-24 3 views
1
내가 파이썬 인터프리터에서 다음 코드를 사용하여 간단한 SOAP의 웹 서비스를 호출하려고 주위를 연주하고

:파이썬 SOAPpy 웹 서비스 호출에있어 문제점은 무엇입니까?

from SOAPpy import WSDL 
wsdl = "http://www.webservicex.net/whois.asmx?wsdl" 
proxy = WSDL.Proxy(wsdl) 
proxy.soapproxy.config.dumpSOAPOut=1 
proxy.soapproxy.config.dumpSOAPIn=1 
proxy.GetWhoIS(HostName="google.com") 

가 (그래, 나는 diveintopython의 일을하고, 파이썬에 새로 온 사람 ...)

GetWhoIS 메서드 호출이 실패합니다. 그렇지 않으면 여기에서 묻지 않을 것입니다. 여기에 보내는 SOAP입니다 :

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"> 
    <SOAP-ENV:Body> 
    <GetWhoIS SOAP-ENC:root="1"> 
     <HostName xsi:type="xsd:string">google.com</HostName> 
    </GetWhoIS> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

그리고 여기 들어오는 응답입니다.

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
    <soap:Fault> 
     <faultcode>soap:Server</faultcode> 
     <faultstring> 
      System.Web.Services.Protocols.SoapException: 
      Server was unable to process request. ---&gt; 
      System.ArgumentNullException: Value cannot be null. 
     at whois.whois.GetWhoIS(String HostName) 
     --- End of inner exception stack trace --- 
     </faultstring> 
     <detail /> 
    </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

은 (수동으로 쉽게 읽을 포맷)

사람이 내가 잘못 뭐하는 거지 말씀해 주시겠습니까?

SOAPpy의 사용 측면과 SOAP 메시지가 올바르지 않은 이유 모두에서 이상적입니다.

감사합니다.

답변

3

귀하의 전화가 내게 괜찮은 것 같아요. 이것이 문제가되거나 문제가 될 수 있다고 생각합니다. (완전히 조사하지는 않았지만).

이 문서는 soappy와 webservicex.net 사이의 호환성을 제안 : 내가이 특정한 경우에이 문제를 해결 할 방법 http://users.jyu.fi/~mweber/teaching/ITKS545/exercises/ex5.pdf

?

import urllib 

url_handle = urllib.urlopen("http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=%s" \ 
          % ("www.google.com")) 
print url_handle.read() 
2

@ChristopheD에서 언급했듯이 SOAPpy는 WDSL의 특정 구성에서 버그가있는 것 같습니다.

대신 suds (sudo easy_install suds in Ubuntu)를 사용하여 처음 시도했습니다.

from suds.client import Client 
client = Client('http://www.webservicex.net/whois.asmx?wsdl') 
client.service.run_GetWhoIS(HostName="google.com") 

욥의 좋은 유엔.

1

클라이언트가 어떤 이유로 든 거의 사용되지 않는 오래된 양식 ("SOAP 섹션 5 인코딩")을 사용하여 요청을 보내고 있습니다. 다음을 기준으로 알 수 있습니다.

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 

그러나 서비스는 WSDL을 기반으로 일반 SOAP 메시지 만 허용합니다. 따라서, 사용하고있는 SOAP 라이브러리의 WSDL 파싱 부분에서 뭔가 잘못되었을 가능성이 큽니다.

0

다른 질문 here에 대한 내 대답을 확인하십시오. .net에는 비누 동작이 필요하며 이름 공간이 앞에 붙습니다.