2010-08-10 1 views
4

SOAPpy 요청을 작성하고 있지만 태그의 속성을 설정하는 방법을 알 수 없습니다.SOAPpy에서 XML 속성을 어떻게 설정합니까?

<ReportRequest startRow="0" shownRows="200"> 

이 어떻게 속성을 추가하려면 :

<?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> 
<ns1:getAvailablePmcReports xmlns:ns1="urn:yahoo:overture:stats:3.0" SOAP-ENC:root="1"> 
<ReportRequest xsi:type="xsd:string"></ReportRequest> 
<ReportAuth> 
<username xsi:type="xsd:string">myuser</username> 
<cookie xsi:type="xsd:string">cookie here...</cookie> 
</ReportAuth> 
</ns1:getAvailablePmcReports> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

하지만 내가 원하는 것은 이것이다 :

url = wsdlfile = 'https://stats2.overture.com/ExternalSOAP/statsPMCAPI_1_0.wsdl' 
n = 'urn:yahoo:overture:stats:3.0' 
server = WSDL.Proxy(wsdlfile) 
server.soapproxy.config.dumpSOAPOut = 1 
server.soapproxy.config.dumpSOAPIn = 1 
result = server.getAvailablePmcReports(ReportAuth = {'username': username, 'cookie': YBY}, ReportRequest= '') 
print(result) 

이 출력 : 여기 내 코드는? 감사합니다. .

+0

당신은, 전체 소스 XML 문서와 최종 XML 문서를 제공시겠습니까 그것으로부터 형성하고 싶습니까? 나는 도울 수 있을지도 모른다. –

답변

3

ReportRequest 키워드 인수에 대한 값을 입력하여이 작업을 수행 할 수 있습니다. 예를 들어,이에 getAvailablePmcReports 라인을 변경하는 경우 :

from SOAPpy import Types 
result = server.getAvailablePmcReports(
    ReportAuth = {'username': username, 'cookie': YBY}, 
    ReportRequest= Types.stringType('', attrs={'startRow': 0, 'shownRows': 200})) 

결과 요청은이 같은 태그를 포함

<ReportRequest xsi:type="xsd:string" shownRows="200" startRow="0"></ReportRequest>