1. 抛出错误的代码
      [cpp] ​​view plain​​​​copy​

      1. //如果返回的报文是错误信息,则抛出错误  
      2.    if([outParams count] <= 0)  
      3.    {  
      4.        [NSException raise:@"WebService error" format:@"%@", returnJson4SOAP];  
      5.    }  


    2. 在调用中捕获错误代码
      [cpp] ​​view plain​​​​copy​

      1. //从soap 信息中解析出CusotmerDetail 对象  
      2.     @try  
      3.     {  
      4.         customerDetail = [[[SoapRtnJsonParser alloc] init] parse2CustomerDtail:[returnSoapXML dataUsingEncoding:NSUTF8StringEncoding]];  
      5.     }@catch (NSException * e) {  
      6.         NSLog(@"Exception: %@", e);  
      7.         UIAlertView * alert =  
      8.         [[UIAlertView alloc]  
      9.          initWithTitle:@"错误"  
      10.          message: [[NSString alloc] initWithFormat:@"%@",e]  
      11.          delegate:self  
      12.          cancelButtonTitle:nil  
      13.          otherButtonTitles:@"OK", nil];   
      14.         [alert show];  
      15.         [alert release];  
      16.         return;  
      17.     }