0

How can I delete data using web service?

I have UILabel as uiOid in CustomTableviewCell.h. Now I am using uiOid as cell.uiOid.text=[orid objectAtIndex:indexPath.row]; in ViewController.m. Here orid is NSMutablearray for retrieving records from webservice. I retrieved data correctly, but my problem is How can I delete? I am using webservice to delete data.

I inserted delete webservice in

//Updated//

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
  {      
    [desc removeObjectAtIndex:indexPath.row];
    [item removeObjectAtIndex:indexPath.row];
    [cpack removeObjectAtIndex:indexPath.row];
    [uprice removeObjectAtIndex:indexPath.row];
    [cprice removeObjectAtIndex:indexPath.row];
    [quantity removeObjectAtIndex:indexPath.row];
    [total removeObjectAtIndex:indexPath.row];
    [orid removeObjectAtIndex:indexPath.row];


    NSLog(@"%@",[uid objectForKey:@"OID"]);
    NSLog(@"%@",orid);


    NSString *soapmessage = [NSString stringWithFormat:
                             @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                             "<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/\">\n"
                             "<soap:Body>\n"
                             "<DeleteValue xmlns=\"http://tempuri.org/\">\n"
                             "<oid>%@</oid>"
                             "</DeleteValue>\n"
                             "</soap:Body>\n"
                             "</soap:Envelope>\n",orid

                             ];

    NSLog(@"%@",soapmessage);

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",appdev.hostname]];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapmessage length]];

    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: @"http://tempuri.org/DeleteVaue" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapmessage dataUsingEncoding:NSUTF8StringEncoding]];

}

[mytableview reloadData];

}

method. When I put static number "89291", data successfully deleted(Not useful for multiple operation). But I want to pass orid (NSMutableArray) in webservice instead of static number. How can I fix this? Thanks for any help.

4

2 回答 2

0

pass this in your delete service method:

[orid objectAtIndex:indexPath.row];

It is executed every time a row is deleted from table. After that:

[orid removeObjectAtIndex:indexPath.row];
[aTableView reloadData];
于 2013-07-26T11:26:05.330 回答
0

Remove from yourDataAry

[orid removeObjectAtIndex:indexPath.row];
[yourTableView reloadData];  

And make a webService to delete this record from ServerDataBase too.

于 2013-07-26T11:39:03.663 回答