Problem:
- Product Name: VisiBroker for C
- Product Version: ALL
- Platform Version: ALL
How to change the iiop version of an ior?
Resolution:
Please refer to the Sample code below:
#if defined(_VIS_STD)
# include <fstream>
#else
# include <fstream.h>
#endif
const int MAXBUF = 1024;
// USE_STD_NS is a define setup by VisiBroker to use the std namespace
USE_STD_NS
int main(int argc, char* const* argv) {
try { // Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Read object reference from file
ifstream in("ior.dat");
char ior[MAXBUF];
in.getline(ior, MAXBUF);
in.close();
// convert the object reference to an IORValue
IOP::IORValue_var iorv = VISUtil::to_ior(ior);
// Retrieve the profile body from the IORValue
IIOP::ProfileBodyValue_var iorProfile = VISUtil::get_iiop_body(iorv);
// Retrieve the iiop version from the profile body
GIOP::Version& iiopVersion = iorProfile->version();
// Change the iiop version and write it back into the profile body
iiopVersion.minor = iiopVersion.major;
iorProfile->version(iiopVersion);
VISUtil::replace(iorv, iorProfile);
// Write the changed ior to ior2.dat
CORBA::String_var string_ref = VISUtil::to_string(iorv);
ofstream refFile("ior2.dat");
refFile << string_ref << endl;
} catch(const CORBA::Exception& e) {
cerr << e << endl;
return 1;
}
return 0;
}
#Security
#VisiBroker




