2014-12-24 3 views
1

gsoap httppost 플러그인을 사용하여 게시 요청을 수락하는 서버를 구현하고 있습니다. 오류의 경우404 오류시 gsoap 응답 내용 유형 변경

내가 404 오류를 반환하고 있지만 콘텐츠 형식 그러나 나는 아래 text/html

로 콘텐츠 형식을 필요로 항상 text/xml이다는 코드

int wildcard_handler(struct soap* soap) 
{ 
    stringstream ss; 
    ss << "In wild card handler content_type" << soap->http_content; 
    LOGDEBUG(ss.str()); 

    soap->http_content = "text/html"; 
    soap_send_empty_response(soap, 404); 
    return SOAP_OK; 

} 

하지만 브라우저에서 나는 텍스트를 수신/xml & 오류 404.

답변

1

stdsoap2.cpptext/html 답을 표시하려면

을 사용해야합니다.
int wildcard_handler(struct soap* soap) 
{ 
    soap_response(soap, SOAP_HTML); 
    soap_send(soap, "<HTML>...</HTML>"); 
    soap_end_send(soap); 
    soap_closesock(soap); 
    return SOAP_OK; 
} 

이것은 HTML 대답하지만 오류를 보낼 수 404

(404)을 전송하기 위해

text/html 함량이 가능하지만 그것은 비누 -를 오버라이드 (override)하는 필요가 있기 때문에 더 복잡하다> HTTP 응답 코드와 SOAP_HTML 플래그를 전달하는 fresponse 핸들러.