Re: SOAP requests sometimes fails
Re: SOAP requests sometimes fails
- Subject: Re: SOAP requests sometimes fails
- From: Ivan C Myrvold <email@hidden>
- Date: Fri, 10 Sep 2010 20:12:52 +0200
My SOAP request is coded like this:
#pragma mark -
#pragma mark SOAP method
- (void)sXMLRequest:(NSString *)message {
WSMethodInvocationRef soapCall;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:message, @"sXMLRequest", nil];
NSDictionary *result;
NSString *theresult;
NSDictionary *values = [NSDictionary dictionaryWithObjectsAndKeys:tansaLocation, @"WebServiceURL", nil];
NSXMLDocument *xmldoc = [[[NSXMLDocument alloc] initWithXMLString:message options:NSXMLDocumentTidyXML error:nil] autorelease];
NSString *messageName = [self objectForQuery:@"//ts4/data(@name)" xmldoc:xmldoc];
NSLog(@"sXMLRequest name: %@ message: %@", messageName, message);
[self setCurrentMessage:message];
[self setCurrentMessageName:messageName];
if ([values valueForKey:@"WebServiceURL"]) {
WSClientContext context = { 0, (void*) self, (WSClientContextRetainCallBackProcPtr) CFRetain, (WSClientContextReleaseCallBackProcPtr) CFRelease, (WSClientContextCopyDescriptionCallBackProcPtr) CFCopyDescription};
NSURL *soapURL = [NSURL URLWithString: [values valueForKey:@"WebServiceURL"]];
if (tansaMethod) {
soapCall = WSMethodInvocationCreate ((CFURLRef) soapURL, (CFStringRef) tansaMethod, kWSSOAP2001Protocol);
[soapURL release];
WSMethodInvocationSetProperty(soapCall, kWSSOAPBodyEncodingStyle, (NSString*) kWSSOAPStyleRPC);
WSMethodInvocationSetProperty(soapCall, kWSSOAPMethodNamespaceURI, tansaNamespace);
WSMethodInvocationSetParameters (soapCall, (CFDictionaryRef) params, NULL);
NSString * soapActionKey = @"SOAPAction";
NSDictionary * headers = [[NSDictionary dictionaryWithObjects:&soapAction forKeys:&soapActionKey count:1] retain];
WSMethodInvocationSetProperty(soapCall, kWSHTTPExtraHeaders, headers);
WSMethodInvocationSetProperty(soapCall, kWSMethodInvocationTimeoutValue, (CFNumberRef)[self tansaMethodInvocationTimeoutValue]);
[headers release];
//Do the actual XML-SOAP call and get the result.
WSMethodInvocationSetCallBack(soapCall, &callback, &context);
WSMethodInvocationScheduleWithRunLoop(soapCall, [[NSRunLoop currentRunLoop] getCFRunLoop], (CFStringRef)NSDefaultRunLoopMode);
} else {
NSLog(@"sXMLRequest no tansaMethod");
}
} else {
NSLog(@"sXMLRequest no WebServiceURL");
NSUserDefaults *nsud = [NSUserDefaults standardUserDefaults];
NSString *urlstr = [nsud objectForKey:@"tansaServerURL"];
NSString *errordescription = @"couldNotConnect";
NSString *errormessage = [NSString stringWithFormat:@"URL: %@", urlstr];
NSString *type = @"connectFailedDialog";
NSString *errSource = @"sXMLRequest";
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:errordescription, @"localizedError", type, @"type", errormessage, @"errMessage", errSource, @"errSource", nil];
[[NSRunLoop currentRunLoop] performSelector:@selector(sendErrorNotification:) target:self argument:dict order:0 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden