From: helge Date: Sat, 1 Apr 2006 16:56:37 +0000 (+0000) Subject: improved SOAP request handling X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de3fde4adc78412e3d00b9c58dda4b72455b7cb2;p=sope improved SOAP request handling added debug logging default to selector invocation git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1239 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 4af2be94..24b68d85 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,13 @@ +2006-04-01 Helge Hess + + * v4.5.225 + + * SoObjects/SoSelectorInvocation.m: added default to enable debugging + (SoSelectorInvocationDebugEnabled) + + * SoObjects/SoObjectSOAPDispatcher.m: improved to SOAP request + dispatcher to work with iFolder generated requests + 2006-03-15 Marcus Mueller * NGObjWeb.xcodeproj: latest additions added to Xcode build diff --git a/sope-appserver/NGObjWeb/SoObjects/SoObjectSOAPDispatcher.m b/sope-appserver/NGObjWeb/SoObjects/SoObjectSOAPDispatcher.m index 6e5f5933..b4020597 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoObjectSOAPDispatcher.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoObjectSOAPDispatcher.m @@ -35,6 +35,9 @@ /* TODO: is it required by SOAP that the HTTP method is POST? + Note: + Servers also set a SOAPAction HTTP header. + SOAP sample: + + Another (http://novell.com/simias/domain/GetDomainID): + + + + + + */ @interface SoSOAPRenderer : SoDefaultRenderer @@ -72,6 +85,9 @@ static BOOL debugParsing = NO; debugOn = [ud boolForKey:@"SoObjectSOAPDispatcherDebugEnabled"]; if (debugOn) NSLog(@"Note: SOPE SOAP dispatcher debugging turned on."); + + debugParsing = [ud boolForKey:@"SoObjectSOAPDispatcherParserDebugEnabled"]; + if (debugParsing) NSLog(@"Note: SOPE SOAP parsing debugging turned on."); } /* XML actions */ @@ -98,17 +114,37 @@ static BOOL debugParsing = NO; [self debugWithFormat:@" setting client object: %@", clientObject]; [_ctx setClientObject:clientObject]; } - + /* find callable (method) object */ // TODO: should we allow acquisition? methodObject = [clientObject lookupName:_actionName inContext:_ctx acquire:NO]; if (methodObject == nil) { - if ([_actionName hasSuffix:@"Request"]) - _actionName = [_actionName substringToIndex:[_actionName length] - 7]; - methodObject = [clientObject lookupName:_actionName inContext:_ctx - acquire:NO]; + /* check for common names like "GetFolderRequest" => "GetFolder" */ + if ([_actionName hasSuffix:@"Request"]) { + NSString *an; + + an = [_actionName substringToIndex:([_actionName length] - 7)]; + if (debugOn) [self debugWithFormat:@" try special name: %@", an]; + methodObject = [clientObject lookupName:an inContext:_ctx acquire:NO]; + if (methodObject != nil) _actionName = an; + } + } + if (methodObject == nil) { + /* check for names like "http://novell.com/domain/GetID" => "GetID" */ + NSRange r; + + r = [_actionName rangeOfString:@"/" options:NSBackwardsSearch]; + if (r.length > 0) { + NSString *an; + + an = [_actionName substringFromIndex:(r.location + r.length)]; + if (debugOn) [self debugWithFormat:@" try special name: %@", an]; + + methodObject = [clientObject lookupName:an inContext:_ctx acquire:NO]; + if (methodObject != nil) _actionName = an; + } } if (methodObject == nil) { @@ -220,15 +256,27 @@ static BOOL debugParsing = NO; /* Note: the SOAPAction is also contained in the body which is probably - considered the authority. + considered the authority? We currently prefer the header when + available. */ - SOAPAction = [rq headerForKey:@"soapaction"]; - if ([SOAPAction length] == 0) { + if ([SOAPAction length] > 1) { + + if ([SOAPAction characterAtIndex:0] == '"' && + [SOAPAction characterAtIndex:([SOAPAction length] - 1)] == '"') { + /* a quoted header, like "http://novell.com/simias/domain/GetDomainID" */ + NSRange r; + + r.location = 1; + r.length = [SOAPAction length] - 2; + SOAPAction = [SOAPAction substringWithRange:r]; + } + } + if (![SOAPAction isNotEmpty]) { [self errorWithFormat:@"missing SOAPAction HTTP header!"]; return nil; } - + /* parse XML */ if ((dom = [rq contentAsDOMDocument]) == nil) { diff --git a/sope-appserver/NGObjWeb/SoObjects/SoSelectorInvocation.m b/sope-appserver/NGObjWeb/SoObjects/SoSelectorInvocation.m index 3e62efb7..63f724bd 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoSelectorInvocation.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoSelectorInvocation.m @@ -33,16 +33,20 @@ static BOOL debugOn = NO; + (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; static BOOL didInit = NO; if (didInit) return; didInit = YES; + + debugOn = [ud boolForKey:@"SoSelectorInvocationDebugEnabled"]; + if (debugOn) NSLog(@"Note: SOPE selector invocation debug is enabled."); /* per default selector invocations are public */ [[self soClassSecurityInfo] declareObjectPublic]; } - (id)init { - if ((self = [super init])) { + if ((self = [super init]) != nil) { [self setDoesAddContextParameter:YES]; } return self; @@ -170,7 +174,7 @@ static BOOL debugOn = NO; qppath = [_spec objectAtIndex:i]; value = [qppath isNotNull] ? [soapEnvelope lookupQueryPath:qppath] : nil; - [args addObject:(value != nil ? value : [NSNull null])]; + [args addObject:(value != nil ? value : (id)[NSNull null])]; } return args; } @@ -288,7 +292,7 @@ static BOOL debugOn = NO; [_ctx soRequestType]]; } if ([self doesAddContextParameter]) - args = [NSArray arrayWithObject:(_ctx ? _ctx : [NSNull null])]; + args = [NSArray arrayWithObject:(_ctx ? _ctx : (id)[NSNull null])]; } else { args = [self extractArgumentsFromContext:_ctx @@ -296,9 +300,10 @@ static BOOL debugOn = NO; specification:argspec]; if (debugOn) [self debugWithFormat:@"extracted args %@", args]; if ([self doesAddContextParameter]) { - args = args != nil - ? [args arrayByAddingObject:(_ctx ? _ctx : [NSNull null])] - : [NSArray arrayWithObject:(_ctx ? _ctx : [NSNull null])]; + if (args != nil) + args = [args arrayByAddingObject:(_ctx != nil?_ctx:(id)[NSNull null])]; + else + args = [NSArray arrayWithObject: (_ctx != nil?_ctx:(id)[NSNull null])]; } } @@ -348,7 +353,7 @@ static BOOL debugOn = NO; // step B: validate arguments! if ([self doesAddContextParameter]) - _args = [_args arrayByAddingObject:_ctx ? _ctx : [NSNull null]]; + _args = [_args arrayByAddingObject:_ctx ? _ctx : (id)[NSNull null]]; if (debugOn) { [self debugWithFormat:@"call on %@ with args(%i) %@ context %@", diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index f5718974..f4f4d508 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=224 +SUBMINOR_VERSION:=225 # v4.5.214 requires libNGExtensions v4.5.179 # v4.5.122 requires libNGExtensions v4.5.153