如何在iphonesdk的数据库中插入soap响应
我得到了这样的回应:如何在iphonesdk的数据库中插入soap响应,iphone,objective-c,ios,soap,Iphone,Objective C,Ios,Soap,我得到了这样的回应: 2012-12-19 19:04:39.253 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xm
2012-12-19 19:04:39.253 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://tempuri.org/"><soap:Body><GetAtheletDetailByUserKey><UserProfileKey>3</UserProfileKey></GetAtheletDetailByUserKey></soap:Body></soap:Envelope>
2012-12-19 19:04:51.678 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAtheletDetailByUserKeyResponse xmlns="http://tempuri.org/"><GetAtheletDetailByUserKeyResult><AtheletDetailList><WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>
2012-12-19 19:10:53.024 SwimboardDemo[4507:f803] GetAllAtheleteHandler returned the value: (
"<WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00.000</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>"
)
2012-12-19 19:10:53.281 SwimboardDemo[4507:f803] Result Count :: 3
2012-12-19 19:11:03.785 SwimboardDemo[4507:f803] Athelet Handler Done 0
2012-12-19 19:11:05.272 SwimboardDemo[4507:f803] Insertion Failed
- (IBAction)btnSync:(id)sender {
// if(![[NSUserDefaults standardUserDefaults] valueForKey:@"SychTeam"])
// {
SBSwimboardService* service = [SBSwimboardService service];
service.logging = YES;
[service GetAtheletDetailByUserKey:self action:@selector(GetAllAtheletDetailHandler:) UserProfileKey:3];
//}
//[service GetSplitDataByUserKey:self action:@selector(GetAllSplitDataHandler:) UserProfileKey:3];
}
#pragma mark - Delegate Methods
-(void)GetAllAtheletDetailHandler:(id)value
{
int j;
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
NSMutableArray* result = (NSMutableArray*)value;
NSLog(@"GetAllAtheleteHandler returned the value: %@", result );
// if([[NSString stringWithFormat:@"%@",result] isEqualToString:@"1"]){
NSLog(@"Result Count :: %d",[result count]);
for (int i =0; i<[result count]; i++) {
NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"AtheletDetail_PK"] forKey:@"AtheletDetail_PK"];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"Athelet_FK"] forKey:@"Athelet_FK"];
DAL *objDAL=[[DAL alloc]initDatabase:@"Abc.sqlite"];
j = [objDAL insertRecord1:dic inTable:@"Abc"];
NSLog(@"Athelet Handler Done %d",i);
if (j == 0) {
NSLog(@"Inserted Successfully");
}
else if(j == -1)
{
NSLog(@"Insertion Failed");
}
}
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"SychTeam"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
-(int)insertRecord1:(NSDictionary *)record inTable:(NSString *)table {
NSString *query = [NSString stringWithFormat:@"INSERT INTO %@ (", table];
NSString *values = @"(";
int ctr = 1;
int totalKeys = [[record allKeys] count];
for (NSString *key in [record allKeys]) {
//NSObject *object = [record objectForKey:key];
NSString *value1 = [record valueForKey:key];
NSObject *object = value1;
NSString *value = [self getValueOfObject:object];
query = [query stringByAppendingFormat:@"%@", key];
values = [values stringByAppendingFormat:@"%@", value];
if (ctr != totalKeys) {
query = [query stringByAppendingString:@", "];
values = [values stringByAppendingString:@", "];
}
else {
query = [query stringByAppendingString:@") VALUES "];
values = [values stringByAppendingString:@");"];
}
ctr++;
}
query = [query stringByAppendingString:values];
// NSLog(@"%@",query);
return [self executeScalar:query];
}
- (SoapRequest*) GetAtheletDetailByUserKey: (id) _target action: (SEL) _action Abc: (int) Abc
{
NSMutableArray* _params = [NSMutableArray array];
[_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: Abc] forName: @"Abc"] autorelease]];
NSString* _envelope = [Soap createEnvelope: @"Abc" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"http://tempuri.org/Abc" postData: _envelope deserializeTo: [[SBArrayOfWAthelet_Detail alloc] autorelease]];
[_request send];
return _request;
}
2012-12-19:04:39.253 SwimboardDemo[4507:f803]3
2012-12-19 19:04:51.678 SwimboardDemo[4507:f803]1250SFreeF47.750011-04-29T00:00:00卢克·杰弗里纪念杯2Strue2012-12-10T15:52:20.8332012-12-19T17:34:48.73314108
我在数据库中插入时得到响应:
2012-12-19 19:04:39.253 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://tempuri.org/"><soap:Body><GetAtheletDetailByUserKey><UserProfileKey>3</UserProfileKey></GetAtheletDetailByUserKey></soap:Body></soap:Envelope>
2012-12-19 19:04:51.678 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAtheletDetailByUserKeyResponse xmlns="http://tempuri.org/"><GetAtheletDetailByUserKeyResult><AtheletDetailList><WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>
2012-12-19 19:10:53.024 SwimboardDemo[4507:f803] GetAllAtheleteHandler returned the value: (
"<WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00.000</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>"
)
2012-12-19 19:10:53.281 SwimboardDemo[4507:f803] Result Count :: 3
2012-12-19 19:11:03.785 SwimboardDemo[4507:f803] Athelet Handler Done 0
2012-12-19 19:11:05.272 SwimboardDemo[4507:f803] Insertion Failed
- (IBAction)btnSync:(id)sender {
// if(![[NSUserDefaults standardUserDefaults] valueForKey:@"SychTeam"])
// {
SBSwimboardService* service = [SBSwimboardService service];
service.logging = YES;
[service GetAtheletDetailByUserKey:self action:@selector(GetAllAtheletDetailHandler:) UserProfileKey:3];
//}
//[service GetSplitDataByUserKey:self action:@selector(GetAllSplitDataHandler:) UserProfileKey:3];
}
#pragma mark - Delegate Methods
-(void)GetAllAtheletDetailHandler:(id)value
{
int j;
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
NSMutableArray* result = (NSMutableArray*)value;
NSLog(@"GetAllAtheleteHandler returned the value: %@", result );
// if([[NSString stringWithFormat:@"%@",result] isEqualToString:@"1"]){
NSLog(@"Result Count :: %d",[result count]);
for (int i =0; i<[result count]; i++) {
NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"AtheletDetail_PK"] forKey:@"AtheletDetail_PK"];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"Athelet_FK"] forKey:@"Athelet_FK"];
DAL *objDAL=[[DAL alloc]initDatabase:@"Abc.sqlite"];
j = [objDAL insertRecord1:dic inTable:@"Abc"];
NSLog(@"Athelet Handler Done %d",i);
if (j == 0) {
NSLog(@"Inserted Successfully");
}
else if(j == -1)
{
NSLog(@"Insertion Failed");
}
}
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"SychTeam"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
-(int)insertRecord1:(NSDictionary *)record inTable:(NSString *)table {
NSString *query = [NSString stringWithFormat:@"INSERT INTO %@ (", table];
NSString *values = @"(";
int ctr = 1;
int totalKeys = [[record allKeys] count];
for (NSString *key in [record allKeys]) {
//NSObject *object = [record objectForKey:key];
NSString *value1 = [record valueForKey:key];
NSObject *object = value1;
NSString *value = [self getValueOfObject:object];
query = [query stringByAppendingFormat:@"%@", key];
values = [values stringByAppendingFormat:@"%@", value];
if (ctr != totalKeys) {
query = [query stringByAppendingString:@", "];
values = [values stringByAppendingString:@", "];
}
else {
query = [query stringByAppendingString:@") VALUES "];
values = [values stringByAppendingString:@");"];
}
ctr++;
}
query = [query stringByAppendingString:values];
// NSLog(@"%@",query);
return [self executeScalar:query];
}
- (SoapRequest*) GetAtheletDetailByUserKey: (id) _target action: (SEL) _action Abc: (int) Abc
{
NSMutableArray* _params = [NSMutableArray array];
[_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: Abc] forName: @"Abc"] autorelease]];
NSString* _envelope = [Soap createEnvelope: @"Abc" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"http://tempuri.org/Abc" postData: _envelope deserializeTo: [[SBArrayOfWAthelet_Detail alloc] autorelease]];
[_request send];
return _request;
}
2012-12-19:10:53.024 SwimboardDemo[4507:f803]GetAllateHandler返回值:(
“1250SFreeF47.75002011-04-29T00:00:00.000卢克·杰弗里纪念杯2Strue2012-12-10T15:52:20.8332012-12-19T17:34:48.73314108”,
“000000”,
“000000”
)
2012-12-19:10:53.281 SwimboardDemo[4507:f803]结果计数::3
SwimboardDemo[4507:f803]Athelet Handler完成0
2012-12-19:11:05.272 SwimboardDemo[4507:f803]插入失败
代码如下所示:
2012-12-19 19:04:39.253 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://tempuri.org/"><soap:Body><GetAtheletDetailByUserKey><UserProfileKey>3</UserProfileKey></GetAtheletDetailByUserKey></soap:Body></soap:Envelope>
2012-12-19 19:04:51.678 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAtheletDetailByUserKeyResponse xmlns="http://tempuri.org/"><GetAtheletDetailByUserKeyResult><AtheletDetailList><WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>
2012-12-19 19:10:53.024 SwimboardDemo[4507:f803] GetAllAtheleteHandler returned the value: (
"<WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00.000</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>",
"<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>"
)
2012-12-19 19:10:53.281 SwimboardDemo[4507:f803] Result Count :: 3
2012-12-19 19:11:03.785 SwimboardDemo[4507:f803] Athelet Handler Done 0
2012-12-19 19:11:05.272 SwimboardDemo[4507:f803] Insertion Failed
- (IBAction)btnSync:(id)sender {
// if(![[NSUserDefaults standardUserDefaults] valueForKey:@"SychTeam"])
// {
SBSwimboardService* service = [SBSwimboardService service];
service.logging = YES;
[service GetAtheletDetailByUserKey:self action:@selector(GetAllAtheletDetailHandler:) UserProfileKey:3];
//}
//[service GetSplitDataByUserKey:self action:@selector(GetAllSplitDataHandler:) UserProfileKey:3];
}
#pragma mark - Delegate Methods
-(void)GetAllAtheletDetailHandler:(id)value
{
int j;
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
NSMutableArray* result = (NSMutableArray*)value;
NSLog(@"GetAllAtheleteHandler returned the value: %@", result );
// if([[NSString stringWithFormat:@"%@",result] isEqualToString:@"1"]){
NSLog(@"Result Count :: %d",[result count]);
for (int i =0; i<[result count]; i++) {
NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"AtheletDetail_PK"] forKey:@"AtheletDetail_PK"];
[dic setValue:[[result objectAtIndex:i] valueForKey:@"Athelet_FK"] forKey:@"Athelet_FK"];
DAL *objDAL=[[DAL alloc]initDatabase:@"Abc.sqlite"];
j = [objDAL insertRecord1:dic inTable:@"Abc"];
NSLog(@"Athelet Handler Done %d",i);
if (j == 0) {
NSLog(@"Inserted Successfully");
}
else if(j == -1)
{
NSLog(@"Insertion Failed");
}
}
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"SychTeam"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
-(int)insertRecord1:(NSDictionary *)record inTable:(NSString *)table {
NSString *query = [NSString stringWithFormat:@"INSERT INTO %@ (", table];
NSString *values = @"(";
int ctr = 1;
int totalKeys = [[record allKeys] count];
for (NSString *key in [record allKeys]) {
//NSObject *object = [record objectForKey:key];
NSString *value1 = [record valueForKey:key];
NSObject *object = value1;
NSString *value = [self getValueOfObject:object];
query = [query stringByAppendingFormat:@"%@", key];
values = [values stringByAppendingFormat:@"%@", value];
if (ctr != totalKeys) {
query = [query stringByAppendingString:@", "];
values = [values stringByAppendingString:@", "];
}
else {
query = [query stringByAppendingString:@") VALUES "];
values = [values stringByAppendingString:@");"];
}
ctr++;
}
query = [query stringByAppendingString:values];
// NSLog(@"%@",query);
return [self executeScalar:query];
}
- (SoapRequest*) GetAtheletDetailByUserKey: (id) _target action: (SEL) _action Abc: (int) Abc
{
NSMutableArray* _params = [NSMutableArray array];
[_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: Abc] forName: @"Abc"] autorelease]];
NSString* _envelope = [Soap createEnvelope: @"Abc" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"http://tempuri.org/Abc" postData: _envelope deserializeTo: [[SBArrayOfWAthelet_Detail alloc] autorelease]];
[_request send];
return _request;
}
-(iAction)btnSync:(id)发送方{
//如果(![[NSUserDefaults standardUserDefaults]valueForKey:@“SychTeam”])
// {
SBSwimboardService*服务=[SBSwimboardService服务];
service.logging=是;
[service GetAtheletDetailByUserKey:self action:@selector(GetAllateTheletDetailHandler:)UserProfileKey:3];
//}
//[service GetSplitDataYUserKey:self action:@selector(GetAllSplitDataHandler:)UserProfileKey:3];
}
#pragma标记-委托方法
-(void)getAllateDetailHandler:(id)值
{
int j;
if([value iskindof类:[n错误类]]){
NSLog(@“%@”,值);
返回;
}
//处理故障
if([value iskindof类:[SoapFault类]]){
NSLog(@“%@”,值);
返回;
}
NSMutableArray*结果=(NSMutableArray*)值;
NSLog(@“GetAllateHandler返回值:%@”,结果);
//如果([[NSString stringWithFormat:@“%@”,结果]IsequalString:@“1”]){
NSLog(@“结果计数::%d”,[结果计数]);
对于(int i=0;i问题是什么?插入失败了吗?是的,你能帮我解决这个问题吗?我是Web服务的新手,请将查询字符串记录到控制台并检查它,同时检查控制台上是否有任何错误消息。你能给我你编写的东西的代码吗?谢谢你给我这个想法