2017-12-18 3 views
0

안녕하세요 zeep 비누 기반 웹 서비스, 을 사용하고 HTTP 상태 415 오류가 계속 발생합니다. 나는 조금 아래로 파고 Pycharm Debuggger를 사용하는 이유는 것을 발견했다 :파이썬 Zeep - HTTP 상태 415 (사용 가능한 콘텐츠 없음)

'Cannot process the message because the content type \'text/xml; charset=utf-8 XaSOfalw: rtt; ___utmvmBfuwVEwB=yEnqIuCmRhw\' was not the expected type \'text/xml; charset=utf-8\'.'

콘텐츠 유형에 어떤 문제가 있습니까? 지프로 바꾸려면 어떻게해야합니까?

난 그냥 같이 보입니다 간단한 테스트 코드 생성 :

from zeep import Client 

pretend_wsdl = 'https://pretendwsdl' 
client = Client(wsdl=pretend_wsdl) 

res = client.service.NameOfService() 
print(res) 

을이 오류 얻을 : zeep 클라이언트에 plugins를 사용하여 내가 문제를 해결 한

zeep.exceptions.TransportError: Server returned HTTP status 415 (no content available)

답변

0

합니다.

내 코드는 다음과 같습니다

from zeep import Client 
from zeep import Plugin 


class MyLoggingPlugin(Plugin): 

    def ingress(self, envelope, http_headers, operation): 
     return envelope, http_headers 

    def egress(self, envelope, http_headers, operation, binding_options): 
     http_headers['Content-Type'] = 'text/xml; charset=utf-8;' 
     return envelope, http_headers 


pretend_wsdl = 'https://pretendwsdl.com' 

client = Client(wsdl=pretend_wsdl, plugins=[MyLoggingPlugin()]) 

res = client.service.NameOfService() 

print(res) 

나는 그것이 zeep의 기본 콘텐츠 형식은 텍스트/XML입니다 이상한 때문에 찾을; charset = utf-8; 그리고 내가 사용하는 wsdl은 zeep의 콘텐츠 유형이 text/xml이라고 생각하지 않습니다. charset = utf-8;

그래서 저는 지프 플러그 인을 사용하여 명시 적으로 콘텐츠 유형을 text/xml로 설정했습니다. charset = utf-8; 놀랍게도 작동합니다.

관련 문제