Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Xcode未调用asp.net Web服务_Objective C_Xcode_Oracle_Ora 00936 - Fatal编程技术网

Objective c Xcode未调用asp.net Web服务

Objective c Xcode未调用asp.net Web服务,objective-c,xcode,oracle,ora-00936,Objective C,Xcode,Oracle,Ora 00936,我有oracle数据库,使用webservice我想在其中插入一些记录 因此,我在asp.net中创建了webservice,如下所示 public bool PickPill(string Me_id, string Mem_device_id, string Test_datetime, string Creation_id, string PillBayNo) { string Hed_seq_id = Hed_seq_Id(); bool Res

我有oracle数据库,使用webservice我想在其中插入一些记录 因此,我在asp.net中创建了webservice,如下所示

 public bool PickPill(string Me_id, string Mem_device_id, string Test_datetime, string Creation_id, string PillBayNo)
    {
        string Hed_seq_id = Hed_seq_Id();
        bool ResultHED = InsHealthEData(Hed_seq_id, Mem_device_id, Me_id, Test_datetime, Creation_id);
        bool ResultHET = InsHealthETest(Hed_seq_id, PillBayNo, Test_datetime, Creation_id);

        if (ResultHED == ResultHET == true)
            return true;
        else
            return false;

    }
@interface ConsumePillServiceViewController : UIViewController {
 //---outlets---
  IBOutlet UITextField *Me_id;
  IBOutlet UITextField *Mem_device_id;
  IBOutlet UITextField *Test_datetime;
  IBOutlet UITextField *Creation_id;
  IBOutlet UITextField *PillBayNo;
 //---web service access---
    NSMutableData *webData;
    NSMutableString *soapResults;
    NSURLConnection *conn;

}
@property (nonatomic, retain) UITextField *Me_id;
@property (nonatomic, retain) UITextField *Mem_device_id;
@property (nonatomic, retain) UITextField *Test_datetime;
@property (nonatomic, retain) UITextField *Creation_id;
@property (nonatomic, retain) UITextField *PillBayNo;
- (IBAction)buttonClicked:(id)sender;
@end

and 
ConsumePillServiceViewController.m as follows

#import "ConsumePillServiceViewController.h"

@implementation ConsumePillServiceViewController
@synthesize Me_id;
@synthesize Mem_device_id;
@synthesize Test_datetime;
@synthesize Creation_id;
@synthesize PillBayNo;

- (IBAction)buttonClicked:(id)sender {
NSString *soapMsg = 
 @"<?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/\">"
 "<soap:Body>"
"<PickPill xml1ns=\"http://tempuri.org/\">";
NSString *smMe_id=
[soapMsg stringByAppendingString:
[NSString stringWithFormat:
@"<Me_id>%@</Me_id>",Me_id.text]];

 NSString *smMem_device_id=
 [smMe_id stringByAppendingString:
[NSString stringWithFormat:
 @"<Mem_device_id>%@</Mem_device_id>",Mem_device_id.text]];

NSString *smTest_datetime=
 [smMem_device_id stringByAppendingString:
 [NSString stringWithFormat:
  @"<Test_datetime>%@</Test_datetime>",Test_datetime.text]];

NSString *smCreation_id=
 [smTest_datetime stringByAppendingString:
[NSString stringWithFormat:
 @"<Creation_id>%@</Creation_id>",Creation_id.text]];

NSString *smPillBayNo=
 [smCreation_id stringByAppendingString:
[NSString stringWithFormat:
 @"<PillBayNo>%@</PillBayNo>",PillBayNo.text]];

NSString *smRestMsg=
 [smPillBayNo stringByAppendingString:
@"</PickPill>"
"</soap:Body>" "</soap:Envelope>"];

 soapMsg=smRestMsg;

 //---print it to the Debugger Console for verification---
 NSLog(soapMsg);


 NSURL *url = [NSURL URLWithString:   //create a URL load request object using instances :
      @"http://72.44.151.178/PickPillService.asmx"];//of the NSMutableURLRequest and NSURL objects
 NSMutableURLRequest *req = 
 [NSMutableURLRequest requestWithURL:url];



 //opulate the request object with the various headers, such as Content-Type, SOAPAction, and Content-Length. 
 //You also set the HTTP method and HTTP body
 NSString *msgLength = 
 [NSString stringWithFormat:@"%d", [soapMsg length]];
 [req addValue:@"text/xml; charset=utf-8"  
forHTTPHeaderField:@"Content-Type"];
 [req addValue:@"http://tempuri.org/PickPill" 
forHTTPHeaderField:@"SOAPAction"];
 [req addValue:msgLength 
forHTTPHeaderField:@"Content-Length"];
 //---set the HTTP method and body---
 [req setHTTPMethod:@"POST"];
 [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];



 conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; //establish the connection with the web service, 
 if (conn) {  //you use the NSURLConnection class together with the request object just created
  webData = [[NSMutableData data] retain];//webData object use to receive incoming data from the web service
 }    

}//End of button clicked event





-(void) connection:(NSURLConnection *) connection //Recive response
didReceiveResponse:(NSURLResponse *) response {
 [webData setLength: 0];
}
-(void) connection:(NSURLConnection *) connection //Repeative call method and append data to webData
 didReceiveData:(NSData *) data {
 [webData appendData:data];
}

-(void) connection:(NSURLConnection *) connection//If error occure error should be displayed  
  didFailWithError:(NSError *) error {
 [webData release];
    [connection release];
}


-(void) connectionDidFinishLoading:(NSURLConnection *) connection {
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc] 
                        initWithBytes: [webData mutableBytes] 
                        length:[webData length] 
                        encoding:NSUTF8StringEncoding];
    //---shows the XML---
    NSLog(theXML);

    [connection release];
    [webData release];
}



- (void)didReceiveMemoryWarning {
 // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

 // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
 // Release any retained subviews of the main view.
 // e.g. self.myOutlet = nil;
}


- (void)dealloc {
 [Me_id release];
 [Creation_id release];
 [Mem_device_id release];
 [Test_datetime release];
 [PillBayNo release];
    [soapResults release];
    [super dealloc];
}

@end
这个函数为我做了所有的数据插入技巧。我在本地机器上用ip地址测试了这个服务 http:72.44.151.178/PickPillService.asmx 然后 我看到了一个关于如何将asp.net web服务附加到iphone应用程序的示例 然后我在xcode中创建了类似的代码,它有两个文件

  • ConsumerPillServiceViewController.m
  • ConsumerPillServiceViewController.h文件
  • 现在,, 使用xcode的Designer,我创建了5个文本框(Me_id、Mem_device_id、Test_datetime、Creation_id、PillBayNo),所有参数都按照我们的服务要求硬编码 然后修改我的ConsumerPillServiceViewController.h文件,如下所示

     public bool PickPill(string Me_id, string Mem_device_id, string Test_datetime, string Creation_id, string PillBayNo)
        {
            string Hed_seq_id = Hed_seq_Id();
            bool ResultHED = InsHealthEData(Hed_seq_id, Mem_device_id, Me_id, Test_datetime, Creation_id);
            bool ResultHET = InsHealthETest(Hed_seq_id, PillBayNo, Test_datetime, Creation_id);
    
            if (ResultHED == ResultHET == true)
                return true;
            else
                return false;
    
        }
    
    @interface ConsumePillServiceViewController : UIViewController {
     //---outlets---
      IBOutlet UITextField *Me_id;
      IBOutlet UITextField *Mem_device_id;
      IBOutlet UITextField *Test_datetime;
      IBOutlet UITextField *Creation_id;
      IBOutlet UITextField *PillBayNo;
     //---web service access---
        NSMutableData *webData;
        NSMutableString *soapResults;
        NSURLConnection *conn;
    
    }
    @property (nonatomic, retain) UITextField *Me_id;
    @property (nonatomic, retain) UITextField *Mem_device_id;
    @property (nonatomic, retain) UITextField *Test_datetime;
    @property (nonatomic, retain) UITextField *Creation_id;
    @property (nonatomic, retain) UITextField *PillBayNo;
    - (IBAction)buttonClicked:(id)sender;
    @end
    
    and 
    ConsumePillServiceViewController.m as follows
    
    #import "ConsumePillServiceViewController.h"
    
    @implementation ConsumePillServiceViewController
    @synthesize Me_id;
    @synthesize Mem_device_id;
    @synthesize Test_datetime;
    @synthesize Creation_id;
    @synthesize PillBayNo;
    
    - (IBAction)buttonClicked:(id)sender {
    NSString *soapMsg = 
     @"<?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/\">"
     "<soap:Body>"
    "<PickPill xml1ns=\"http://tempuri.org/\">";
    NSString *smMe_id=
    [soapMsg stringByAppendingString:
    [NSString stringWithFormat:
    @"<Me_id>%@</Me_id>",Me_id.text]];
    
     NSString *smMem_device_id=
     [smMe_id stringByAppendingString:
    [NSString stringWithFormat:
     @"<Mem_device_id>%@</Mem_device_id>",Mem_device_id.text]];
    
    NSString *smTest_datetime=
     [smMem_device_id stringByAppendingString:
     [NSString stringWithFormat:
      @"<Test_datetime>%@</Test_datetime>",Test_datetime.text]];
    
    NSString *smCreation_id=
     [smTest_datetime stringByAppendingString:
    [NSString stringWithFormat:
     @"<Creation_id>%@</Creation_id>",Creation_id.text]];
    
    NSString *smPillBayNo=
     [smCreation_id stringByAppendingString:
    [NSString stringWithFormat:
     @"<PillBayNo>%@</PillBayNo>",PillBayNo.text]];
    
    NSString *smRestMsg=
     [smPillBayNo stringByAppendingString:
    @"</PickPill>"
    "</soap:Body>" "</soap:Envelope>"];
    
     soapMsg=smRestMsg;
    
     //---print it to the Debugger Console for verification---
     NSLog(soapMsg);
    
    
     NSURL *url = [NSURL URLWithString:   //create a URL load request object using instances :
          @"http://72.44.151.178/PickPillService.asmx"];//of the NSMutableURLRequest and NSURL objects
     NSMutableURLRequest *req = 
     [NSMutableURLRequest requestWithURL:url];
    
    
    
     //opulate the request object with the various headers, such as Content-Type, SOAPAction, and Content-Length. 
     //You also set the HTTP method and HTTP body
     NSString *msgLength = 
     [NSString stringWithFormat:@"%d", [soapMsg length]];
     [req addValue:@"text/xml; charset=utf-8"  
    forHTTPHeaderField:@"Content-Type"];
     [req addValue:@"http://tempuri.org/PickPill" 
    forHTTPHeaderField:@"SOAPAction"];
     [req addValue:msgLength 
    forHTTPHeaderField:@"Content-Length"];
     //---set the HTTP method and body---
     [req setHTTPMethod:@"POST"];
     [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
    
    
    
     conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; //establish the connection with the web service, 
     if (conn) {  //you use the NSURLConnection class together with the request object just created
      webData = [[NSMutableData data] retain];//webData object use to receive incoming data from the web service
     }    
    
    }//End of button clicked event
    
    
    
    
    
    -(void) connection:(NSURLConnection *) connection //Recive response
    didReceiveResponse:(NSURLResponse *) response {
     [webData setLength: 0];
    }
    -(void) connection:(NSURLConnection *) connection //Repeative call method and append data to webData
     didReceiveData:(NSData *) data {
     [webData appendData:data];
    }
    
    -(void) connection:(NSURLConnection *) connection//If error occure error should be displayed  
      didFailWithError:(NSError *) error {
     [webData release];
        [connection release];
    }
    
    
    -(void) connectionDidFinishLoading:(NSURLConnection *) connection {
        NSLog(@"DONE. Received Bytes: %d", [webData length]);
        NSString *theXML = [[NSString alloc] 
                            initWithBytes: [webData mutableBytes] 
                            length:[webData length] 
                            encoding:NSUTF8StringEncoding];
        //---shows the XML---
        NSLog(theXML);
    
        [connection release];
        [webData release];
    }
    
    
    
    - (void)didReceiveMemoryWarning {
     // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
    
     // Release any cached data, images, etc that aren't in use.
    }
    
    - (void)viewDidUnload {
     // Release any retained subviews of the main view.
     // e.g. self.myOutlet = nil;
    }
    
    
    - (void)dealloc {
     [Me_id release];
     [Creation_id release];
     [Mem_device_id release];
     [Test_datetime release];
     [PillBayNo release];
        [soapResults release];
        [super dealloc];
    }
    
    @end
    
    @接口服务视图控制器:UIViewController{
    //---出口---
    IBOutlet UITextField*Me\u id;
    IBOUTLE UITextField*内存设备id;
    IBOUTLE UITextField*测试日期时间;
    IBOutlet UITextField*创建\u id;
    IBUitextField*PillBayNo;
    //---web服务访问---
    NSMutableData*webData;
    NSMutableString*soapResults;
    NSURL连接*conn;
    }
    @属性(非原子,保留)UITextField*Me\u id;
    @属性(非原子,保留)UITextField*Mem\u device\u id;
    @属性(非原子,保留)UITextField*Test_datetime;
    @属性(非原子,保留)UITextField*创建id;
    @属性(非原子,保留)UITextField*PillBayNo;
    -(iAction)按钮勾选:(id)发送方;
    @结束
    和
    使用ServiceViewController.m,如下所示
    #导入“ConsumerPillServiceViewController.h”
    @ServiceViewController的实现
    @合成我的id;
    @合成内存设备id;
    @综合测试时间;
    @综合创造id;
    @合成PillBayNo;
    -(iAction)按钮点击:(id)发送者{
    NSString*soapMsg=
    @""
    ""
    ""
    "";
    NSString*smMe\U id=
    [soapMsg stringByAppendingString:
    [NSString stringWithFormat:
    @“%@”,Me_id.text]];
    NSString*smMem\u设备\u id=
    [smMe\u id字符串通过附加字符串:
    [NSString stringWithFormat:
    @“%@”,Mem_device_id.text]];
    NSString*smTest\U日期时间=
    [smMem\u设备\u id字符串通过附加字符串:
    [NSString stringWithFormat:
    @“%@”,Test_datetime.text]];
    NSString*smCreation\u id=
    [smTest_datetime stringByAppendingString:
    [NSString stringWithFormat:
    @“%@”,创建id.text]];
    NSString*smPillBayNo=
    [smCreation_id stringByAppendingString:
    [NSString stringWithFormat:
    @“%@”,PillBayNo.text]];
    NSString*smRestMsg=
    [smPillBayNo stringByAppendingString:
    @""
    "" ""];
    soapMsg=smRestMsg;
    //---将其打印到调试器控制台进行验证---
    NSLog(soapMsg);
    NSURL*url=[NSURL URLWithString://使用实例创建url加载请求对象:
    @"http://72.44.151.178/PickPillService.asmxNSMutableURLRequest和NSURL对象的“];//个
    NSMutableURLRequest*req=
    [NSMutableUrlRequestWithURL:url];
    //使用各种标头填充请求对象,例如内容类型、SOAPAction和内容长度。
    //您还可以设置HTTP方法和HTTP正文
    NSString*msgLength=
    [NSString stringWithFormat:@“%d”,[soapMsg长度]];
    [req addValue:@“text/xml;charset=utf-8”
    forHTTPHeaderField:@“内容类型”];
    [请求添加值:@”http://tempuri.org/PickPill" 
    forHTTPHeaderField:@“SOAPAction”];
    [req addValue:msgLength
    forHTTPHeaderField:@“内容长度”];
    //---设置HTTP方法和正文---
    [req setHTTPMethod:@“POST”];
    [req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
    conn=[[NSURLConnection alloc]initWithRequest:req delegate:self];//建立与web服务的连接,
    如果(conn){//将NSURLConnection类与刚刚创建的请求对象一起使用
    webData=[[NSMutableData]retain];//webData对象用于接收来自web服务的传入数据
    }    
    }//单击按钮事件的结束
    -(void)连接:(NSURLConnection*)连接//接收响应
    didReceiveResponse:(NSURLRResponse*)响应{
    [webData setLength:0];
    }
    -(void)连接:(NSURLConnection*)连接//重复调用方法并将数据附加到webData
    didReceiveData:(NSData*)数据{
    [webData:data];
    }
    -(void)连接:(NSURLConnection*)连接//如果发生错误,则应显示错误
    didFailWithError:(n错误*)错误{
    [网络数据发布];
    [连接释放];
    }
    -(无效)连接IDFinishLoading:(NSURLConnection*)连接{
    NSLog(@“完成。收到的字节数:%d”,[webData长度];
    NSString*theXML=[[NSString alloc]
    initWithBytes:[webData可变字节]
    长度:[webData长度]
    编码:NSUTF8StringEncoding];
    //---显示XML---
    NSLog(theXML);
    [连接释放];
    [网络数据发布];
    }
    -(无效)未收到记忆警告{
    //如果视图没有superview,则释放该视图。
    [超级记忆警告];
    //释放所有未使用的缓存数据、图像等。
    }
    -(无效)视图卸载{
    //释放主视图的所有保留子视图。
    //例如,self.myOutlet=nil;
    }
    -(无效)解除锁定{
    [Me_id释放];
    [创建/发布id];
    [内存设备id释放];
    [测试日期时间发布];
    [没有释放];
    [结果发布];
    [super dealoc];
    }
    @结束
    
    我做了网站上显示的所有事情,当我构建应用程序时,它成功构建了 但在调试窗口我看到了

    (gdb) continue
    2010-03-17 09:09:54.595 ConsumePillService[6546:20b] <?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/"><soap:Body><PickPill xml1ns="http://tempuri.org/"><Me_id>A00000004303</Me_id><Mem_device_id>1011</Mem_device_id><Test_datetime>03/13/2010 07:34:38</Test_datetime><Creation_id>Hboxdata</Creation_id><PillBayNo>2</PillBayNo></PickPill></soap:Body></soap:Envelope>
    (gdb) continue
    (gdb) continue
    (gdb) continue
    2010-03-17 09:10:05.411 ConsumePillService[6546:20b] DONE. Received Bytes: 476
    2010-03-17 09:10:05.412 ConsumePillService[6546:20b] <?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><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---&gt; One or more errors occurred during processing of command.
    
    ORA-00936: missing expression</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
    
    (gdb)继续吗
    2010-03-17 09:09:54.595消费电子服务[6546:20b]A00000004303101103/13/2010 07:34:38Hboxdata2
    (gdb)继续
    (gdb)继续
    (gdb)继续
    2010-03-17 09:10:05.411服务完成。接收字节:476
    2010-03-17 09:10:05.412服务[6546:20b]soap:服务器服务器无法处理请求。--处理命令期间发生一个或多个错误。
    ORA-00936:缺少表达式
    
    如果一切都好的话,我会得到真实的结果 这个ORA-00936错误是怎么回事

    因为它与webservice不相关

    请帮我解决这个问题