예제 #1
0
void doTestHandle(funtik::SSLConnection *conn,ulxr::Requester& client,ulxr::HttpProtocol& prot,std::string strClientState)
{
    ulxr::MethodCall checkaccess ("checkaccess");
	checkaccess.addParam(ulxr::RpcString("string"));


	try{
		std::cout<<"  "<<strClientState.c_str();
		if(!prot.isOpen())
			prot.open();

    	    ulxr::MethodResponse resp = client.call(checkaccess, "/RPC2");
//    	    std::cout << "call result: \n";
//	    	std::cout << resp.getXml(0) << std::endl;
		    std::cout <<"Access allow"<<std::endl;

	}
	catch(funtik::SSLConnectionException& ex)
	{
		std::cout <<"Access denied"<<std::endl;
	    std::cout << "Error occured: " << ex.why()
	    		<< std::endl;
	}
		if(prot.isOpen())
	    	prot.close();

}
예제 #2
0
//@return call success flag
void callEcho(ulxr::Requester& aClient)
{
    // Setup call args
    const int myIntArg = -123;
    const bool myBoolArg = true;
    const double myDoubleArg = -3.1415;
    const std::string myDateArg1 = "20110912T10:23:45";
    const time_t myDateArg2 = 0;
    std::string myStrArg  = "<>&\"'string\t\r\n</xml>&amp;&lt;\"'0xd9f0Анди)/()/";
    std::string myB64Arg  =  "<>&\"'binary garbage\xf9\xFF\t\r\n";
    myB64Arg += '\0';
    myB64Arg += "\x2F</xml>&amp;&lt;\"'0xd9f0Анди)/()/";
    std::vector<int> myArrayArg;
    myArrayArg.push_back(0);
    myArrayArg.push_back(999);
    myArrayArg.push_back(-1);
    std::vector<StrBool> myStrBools;
    myStrBools.push_back(StrBool("s1", true));
    myStrBools.push_back(StrBool("s2", false));
    const MyStruct myStructArg(9876, myStrBools);

    ulxr::MethodCall echoProxyFunc ("echo");
    echoProxyFunc.addParam(ulxr::Integer(myIntArg));
    echoProxyFunc.addParam(ulxr::Boolean(myBoolArg));
    echoProxyFunc.addParam(ulxr::Double(myDoubleArg));
    echoProxyFunc.addParam(ulxr::DateTime(myDateArg1));
    echoProxyFunc.addParam(ulxr::DateTime(myDateArg2));
    echoProxyFunc.addParam(ulxr::RpcString(myStrArg));
    echoProxyFunc.addParam(ulxr::Base64(myB64Arg));
    echoProxyFunc.addParam(serializeIntContainer<std::vector<int> >(myArrayArg));
    echoProxyFunc.addParam(serializeMyStruct(myStructArg));

    ulxr::MethodResponse resp = aClient.call(echoProxyFunc, "/RPC2");

    const ulxr::Struct myResp = ulxr::Struct(resp.getResult());
    TEST_ASSERT(!myResp.hasMember("faultCode"));
    TEST_ASSERT_EQUALS(ulxr::Integer(myResp.getMember("arg1")).getInteger(), myIntArg);
    TEST_ASSERT_EQUALS(ulxr::Boolean(myResp.getMember("arg2")).getBoolean(), myBoolArg);
    TEST_ASSERT_EQUALS(ulxr::Double(myResp.getMember("arg3")).getDouble(), myDoubleArg);
    TEST_ASSERT_EQUALS(ulxr::DateTime(myResp.getMember("arg4")).getDateTime(), myDateArg1);
    //@todo fix&enable this check (use local time)
    // TEST_ASSERT_EQUALS(ulxr::DateTime(myResp.getMember("arg5")).getDateTime(), "19700101T00:00:00");
    TEST_ASSERT_EQUALS(ulxr::RpcString(myResp.getMember("arg6")).getString(), myStrArg);
    TEST_ASSERT_EQUALS(ulxr::Base64(myResp.getMember("arg7")).getString(), myB64Arg);
    TEST_ASSERT_EQUALS_NOPRINT(deserializeIntArray<std::vector<int> >(ulxr::Array(myResp.getMember("arg8"))), myArrayArg);
    TEST_ASSERT_EQUALS_NOPRINT(deserializeMyStruct(ulxr::Struct(myResp.getMember("arg9"))), myStructArg);
}