gsoap报文打印

作为客户端的时候
soap_begin_recv
    //发送完请求报文 获取请求报文信息
    g_str_reqXml.clear();
    std::string strBuf;
    std::string::size_type pos1= std::string::npos;
    std::string::size_type pos2 = std::string::npos;
    strBuf = soap->buf;
    pos1 = strBuf.find("     pos2 = strBuf.find("",0);
    if(pos1!=std::string::npos && pos2!=std::string::npos)
    {
        g_str_reqXml = strBuf.substr(pos1,pos2-pos1+20);
    }

soap_body_end_in
    //接收完应答报文 获取应答报文信息
    g_str_resXml.clear();
    std::string strBuf;
    std::string::size_type pos1= std::string::npos;
    std::string::size_type pos2 = std::string::npos;
    pos1= std::string::npos;
    pos2 = std::string::npos;
    soap->buf[SOAP_BUFLEN-1] = '\0';
    strBuf = soap->buf;
    pos1 = strBuf.find("     pos2 = strBuf.find("",0);
    if(pos1!=std::string::npos && pos2!=std::string::npos)
    {
        g_str_resXml = strBuf.substr(pos1,pos2-pos1+19);
    }

作为服务端的时候
soap_recv_raw
    //接收完客户端的请求报文 获取请求报文信息
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket=%d/fd=%d\n", (unsigned int)ret, soap->socket, soap->recvfd));
    DBGMSG(RECV, soap->buf, ret);

    //请求报文
    std::string req_data;
    req_data.assign(soap->buf, ret);
    g_pLog->WriteLog(req_data.c_str(), LOG_INFO);

soap_flush_raw
    DBGMSG(SENT, s, n);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Send %u bytes to socket=%d/fd=%d\n", (unsigned int)n, soap->socket, soap->sendfd));

    //应答报文
    std::string res_data;
    res_data.assign(s, n);
    g_pLog->WriteLog(res_data.c_str(), LOG_INFO);

你可能感兴趣的:(gsoap报文打印)