Hi,


I really need some help with the below. I have no problems invoking my
functionality from PowerDynamo. However, the C++ ORB does not seem to work.
It fails on the line
n_cst_wqe_var testObj = n_cst_wqe::_narrow (object);
and sometimes fails on the line above that. This example is straight from
the book.
Am I missing something simple? I am trying to run this inside an ISAPI
script and have even moved it into a console app to debug it.

I have properly generated the C++ stubs and placed them in the proper
compile location, I have tested the package using PowerDynamo with no
problems.

My object lies in a package called WQE and the object itself is called
n_cst_wqe.

Any help would be appreciated. This is simple copy from the text book, it
should work.
Please note I am not using COS naming example, I don't believe I require COS
naming for this or do I?

Thanks for any help.

Regards,
Brad Gawne








// QuoteConsole.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "jaguar.hpp"
#include <SessionManager.hpp>
#include <CosNaming.hpp>
#include <wqe.hpp>
#include <stdio.h>

using namespace CORBA;
using namespace SessionManager;
using namespace WQE;
using namespace CosNaming;


int main(int argc, char* argv[])
{
fprintf(stdout,"Content-Type: text/html\r\n\r\n");
try {

fprintf(stdout,"Creating Jaguar session\n\n");

ORB_var orb = ORB_init (argc, argv,"");
Object_var object = orb->string_to_object ("iiop://24.112.55.126:9000");
Manager_var manager = Manager::_narrow (object);
Session_var session = manager->createSession("jagadmin", "");
object = session->create ("WQE/n_cst_wqe");
n_cst_wqe_var testObj = n_cst_wqe::_narrow (object);
// Initialize the ORB
/* ORB_var orb=ORB_init(argc, argv, 0);

Object_var obj=orb->resolve_initial_references("NameService");
NamingContext_var nc=CosNaming::NamingContext::_narrow(obj);
if (is_nil(nc)) {
fprintf(stdout,"Error: Null NamingContext instance. Exiting.";
return ;
}

Name name;
name.length(1);
name[0].id=string_dup(component_name);
name[0].kind=string_dup();

obj = nc->resolve(name);

Factory_var wqeFactory=SessionManager::Factory::_narrow(obj);

if (is_nil(wqeFactory)) {
fprintf(stdout,"ERROR: Null component factory. ";
return;
}

n_cst_wqe_var
wqe=n_cst_wqe::_narrow(wqeFactory->create("jagadmin",));

// Verify that we really have an instance.
if (is_nil(wqe)) {
fprintf(stdout,"ERROR: Null component instance. ";
return;
}

fprintf(stdout,_T("Everything looks good.");
*/
}

// Requested object (component) does not exist.
catch (NamingContext::NotFound &nf)
{
fprintf(stdout,"Error: Component not found.");
}

// Authentication or authorization failure.
catch ( NO_PERMISSION npe )
{
fprintf(stdout,"Error: CORBA:: NO_PERMISSION exception. ");
}

// Invalid object reference.
catch ( CORBA::INV_OBJREF cio )
{
fprintf(stdout,"Error: CORBA INV_OBJREF exception.");
}

// Communication failure. Server could be down or URL's port value
// could be wrong.
catch ( CORBA::COMM_FAILURE ccf )
{
fprintf(stdout,"Error: CORBA COMM_FAILURE exception. ");
}
// Requested object (component) does not exist.
catch ( CORBA::OBJECT_NOT_EXIST cone )
{
fprintf(stdout,"Error: CORBA OBJECT_NOT_EXIST exception.");
}
// Anything else.
catch ( CORBA::OBJ_ADAPTER )
{
fprintf(stdout,"Error: CORBA::OBJ_ADAPTER \n");
}
catch ( CORBA::SystemException cse )
{
fprintf(stdout,"Error: CORBA System Exception. ");
}
return 0;
}