Re: -[NSInvocation length]: selector not recognized [self = 0x30abd0]

  • Hello Tito,

    Thanks for replying. I have been struggling with this for a while now.

    Here I am pasting my code from both server side and client side. Please
    help.

    Best regards

    S

    /*main.c*/

    int main(int argc, char *argv[])
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        MyMessageServer *server = [[MyMessageServer alloc] init];
        NSConnection *defaultConnection;
        defaultConnection = [NSConnection defaultConnection];

        [defaultConnection setRootObject:server];

        if ([defaultConnection registerName:@"server"] == NO) {
            NSLog(@"Failed to register name\n");
        }

        //[defaultConnection setDelegate:server];

        [[NSRunLoop currentRunLoop] configureAsServer];
        [[NSRunLoop currentRunLoop] run];

        [server release];
        [pool release];

        return 0;
        //return NSApplicationMain(argc,  (const char **) argv);
    }

    /*MyMessageServerProtocol.h*/
    #import <Cocoa/Cocoa.h>
    #import <Foundation/Foundation.h>

    @protocol MyMessageServerProtocol

    - (void)broadcastMessageString:(NSString *)aString
                    sentFromClient:(id)aClient;

    @end

    /* MyMessageServer.h*/
    #import <Cocoa/Cocoa.h>
    #import <Foundation/Foundation.h>
    #import "MyMessageServerProtocol.h"
    #import <SOAPAPI/SOAPAPI.h>

    @class SoapSession;
    @interface MyMessageServer : NSObject <MyMessageServerProtocol> {
        SoapSession *_sess;
    }

    - (SoapSession *)login;

    @end

    /* MyMessageServer.m*/

    #import "MyMessageServer.h"

    @implementation MyMessageServer

    - (void)broadcastMessageString:(NSString *)aString
                    sentFromClient:(id)aClient
    {
        if ([aString isEqualToString:@"login"]) {
            _sess = [self login];
        }

        NSLog(@"_sess:%@\n\n",_sess);

        [aClient performSelector:@selector(appendMessageString:)
                      withObject:_sess ];

        NSLog(@"Time from server:%@\n\n",[[_sess SOAPAPI] getCurrentTime]);
    }

    - (void) dealloc {
        [_myListOfClients release];
        _myListOfClients = nil;
        [super dealloc];
    }

    - (SoapSession *)login
    {
        id _session = [[SoapSession alloc] initWithUserName:@"admin"
                                                andPassword:@"testpwd"
                                            andAppName:@"DO"
                                                andVersion:@"1.0"
                                                andHost:@"doHost"];
        return _session;

    }

    @end

    ===========================================
    /*MyMasterController .m  -> Client Program*/

    #import "MyMasterController.h"
    #import <SOAPAPI/SOAPAPI.h>

    @protocol MyMessageServerProtocol

    - (void)broadcastMessageString:(NSString *)aString
    sentFromClient:(id)aClient;

    @end

    @implementation MyMasterController

    - (IBAction)sendMessage:(id)sender
    {
        [server broadcastMessageString:[composeView string]
    sentFromClient:self];
        [composeView setString:@""];
    }

    - (oneway void)appendMessageString:(id)response
    {
        NSLog(@"current time on client:%@",[[response publicAPI]
    getCurrentTime]);
    }

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        server = [[NSConnection
    rootProxyForConnectionWithRegisteredName:@"server" host:nil] retain];

        if (! server ) {
            NSLog(@"Error: Failed to connect to server.");
        } else {
            [server setProtocolForProxy:@protocol(MyMessageServerProtocol)];
            [server broadcastMessageString:@"login" sentFromClient:self];
        }

    }

    - (void)applicationWillTerminate:(NSNotification *)aNotification
    {
        [server release];
        server = nil;
    }

    @end

    /*****MyMasterController .h********/

    #import <Cocoa/Cocoa.h>
    #import <SOAPAPI/SOAPAPI.h>

    @class SoapSession;
    @interface MyMasterController : NSObject {
        IBOutlet NSTextView *composeView;
        IBOutlet NSTextView *messageView;
        id server;
    }

    - (IBAction)sendMessage:(id)sender;

    - (oneway void)appendMessageString:(id)response;

    @end

    On 9/23/07, Tito Ciuro <tciuro...> wrote:
    >
    > Hey S,
    > Can you print the type of class it's being sent to you? Place this on the
    > entry point:
    >
    > NSLog(@"session id class: %@", [session_id class]); // Assuming the
    > variable is called session_id
    >
    > Looks like the SOAP agent is trying to send a length message, perhaps
    > assuming that the session_id is of type NSString.
    >
    > Let me know,
    >
    > -- Tito
    >
    >
    > On Sep 23, 2007, at 12:33 PM, NSTask wrote:
    >
    > Hello,
    >
    > I am posting this question again today, hoping somebody can give me a clue
    > what I am missing. I am using distributed objects and managed to talk to
    > server.
    > Client is getting responses successfully from the server. However the
    > problem is when client
    > receives session id from the server and try to use that session id for
    > further queries
    > with the soap api it always get the error message from the server saying
    >
    > -[NSInvocation length]: selector not recognized [self = 0x30abd0]
    >
    > I do not understand what is that I am doing wrong. Do tell me if this is
    > not
    > the mailing list
    > where I should post distributed object related stuff.
    >
    >
    > Best regards
    >
    > S
    >
    >
    >
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today