当前位置: 首页>>代码示例>>C++>>正文


C++ IEspContext::getPeer方法代码示例

本文整理汇总了C++中IEspContext::getPeer方法的典型用法代码示例。如果您正苦于以下问题:C++ IEspContext::getPeer方法的具体用法?C++ IEspContext::getPeer怎么用?C++ IEspContext::getPeer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEspContext的用法示例。


在下文中一共展示了IEspContext::getPeer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: queueLog

bool CLogThread::queueLog(IEspContext & context,const char* serviceName, const char* request, const char* response)
{
    IProperties* pProperties = context.queryRequestParameters();

    StringBuffer UserID, UserRealm, UserReference, peer;
    if(pProperties != NULL && pProperties->hasProp("userid_"))
        UserID.appendf("%s",pProperties->queryProp("userid_"));
    else
        context.getUserID(UserID);

    if(pProperties != NULL && pProperties->hasProp("fqdn_"))
        UserRealm.appendf("%s",pProperties->queryProp("fqdn_"));
    else
        context.getRealm(UserRealm);

    Owned<IPropertyTree> pLogTreeInfo = createPTreeFromXMLString(request, ipt_none, ptr_none);
    IArrayOf<IEspLogInfo> LogArray;
    addLogInfo(LogArray, *pLogTreeInfo.get());

    if(pProperties != NULL && pProperties->hasProp("referencecode_"))
    {
        //lets manually add the reference number....
        IClientLogInfo& LogInfoTransaction =  addLogInfoElement(LogArray);
        LogInfoTransaction.setName("referencenumber");
        LogInfoTransaction.setValue(pProperties->queryProp("referencecode_"));
    }

    LOG_INFO _LogStruct(serviceName,-1,false);
    return queueLog(UserID.str(), UserRealm.str() , context.getPeer(peer).str(),_LogStruct, LogArray );
}
开发者ID:AlexLuya,项目名称:HPCC-Platform,代码行数:30,代码来源:LogThread.cpp

示例2: processRequest

int CSoapService::processRequest(ISoapMessage &req, ISoapMessage& resp)
{
    ESP_TIME_SECTION("CSoapService::processRequest()");

    CSoapRequest& request = *(dynamic_cast<CSoapRequest*>(&req));
    CSoapResponse& response = *(dynamic_cast<CSoapResponse*>(&resp));

    IEspContext* ctx = req.queryContext();
    
    StringBuffer requeststr;

    Owned<CMimeMultiPart> multipart;
    if(Utils::strncasecmp(request.get_content_type(), HTTP_TYPE_SOAP, strlen(HTTP_TYPE_SOAP))==0 || Utils::strncasecmp(request.get_content_type(), HTTP_TYPE_TEXT_XML, strlen(HTTP_TYPE_TEXT_XML))==0)
    {
        requeststr.append(request.get_text());
    }
    else if(!Utils::strncasecmp(request.get_content_type(), HTTP_TYPE_MULTIPART_RELATED, strlen(HTTP_TYPE_MULTIPART_RELATED)))
    {
        multipart.setown(LINK(request.queryMultiPart()));
        CMimeBodyPart* rootpart = multipart->queryRootPart();
        if(rootpart != NULL)
            rootpart->getContent(requeststr);
        else
            throw MakeStringException(-1, "MultiPart root is NULL");
    }
    else
    {
        throw MakeStringException(-1, "Request type %s not supported", request.get_content_type());
    }
    
    //Parse the content
    auto_ptr<XmlPullParser> xpp(new XmlPullParser());
    int bufSize = requeststr.length();
    xpp->setSupportNamespaces(true);
    xpp->setInput(requeststr.str(), bufSize);

    int type; 
    StartTag stag;
    EndTag etag;

    Owned<CEnvelope> req_envelope;
    req_envelope.setown(new CEnvelope);

    while((type = xpp->next()) != XmlPullParser::END_DOCUMENT) 
    {
        if(type == XmlPullParser::START_TAG) {
            xpp->readStartTag(stag);
            if(!stricmp(stag.getLocalName(), SOAP_ENVELOPE_NAME))
            {
                req_envelope->unmarshall(xpp.get());
                break;
            }
        }
    }
    
    CHeader* req_header = req_envelope->get_header();
    if(req_header != NULL)
    {
        // As headers are normally for common uses like authentication and routing, let's process it here
        // instead of in binding.
        int ret = processHeader(req_header, ctx);
        if(ret != 0 )
        {
            response.set_status(ret);
            return 0;
        }
    }

    StringBuffer peerStr;
    ctx->getPeer(peerStr);
    const char* userId = ctx->queryUserId();

    CBody* req_body = req_envelope->get_body();
    Owned<CRpcResponse> rpc_response;
    rpc_response.setown(new CRpcResponse);
    rpc_response->setContext(req.queryContext());
    Owned<CRpcCall>rpc_call;
    rpc_call.setown(new CRpcCall);
    rpc_call->setContext(req.queryContext());
    
    try {
        req_body->nextRpcMessage(rpc_call.get());
        rpc_call->unmarshall(xpp.get(), multipart.get());
    } catch (XmlPullParserException& e) {
        response.set_status(SOAP_CLIENT_ERROR);
        response.set_err(e.getMessage().c_str());
        DBGLOG("SOAP request from %[email protected]%s. Parsing xml error: %s. Offending XML: [%s]", (userId&&*userId)?userId:"unknown",
            (peerStr.length()>0)?peerStr.str():"unknown", e.getMessage().c_str(), requeststr.str());
        return 0;
    } catch (...) {
        response.set_status(SOAP_CLIENT_ERROR);
        response.set_err("Unknown error when parsing soap body XML");
        ERRLOG("SOAP request from %[email protected]%s. Unknown error when parsing: %s",  (userId&&*userId)?userId:"unknown",
            (peerStr.length()>0)?peerStr.str():"unknown", requeststr.str());
        return 0;
    }

    DBGLOG("SOAP method <%s> from %[email protected]%s.", rpc_call->get_name(),  (userId&&*userId)?userId:"unknown",
        (peerStr.length()>0)?peerStr.str():"unknown");

//.........这里部分代码省略.........
开发者ID:hhy5277,项目名称:HPCC-Platform,代码行数:101,代码来源:soapservice.cpp


注:本文中的IEspContext::getPeer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。