Xcode 没有调用 asp.net webservice
我有 Oracle 数据库并使用 Web 服务,我想在其中插入一些记录 所以我在asp.net中创建了web服务,如下所示
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;
}
这个函数为我完成了所有数据插入技巧我在本地机器上使用ip地址测试了这个服务 http:72.44.151.178/PickPillService.asmx 然后, 我看到一个关于如何将 ASP.NET Web 服务附加到 iPhone 应用程序的示例 http://www.devx.com/wireless/Article/43209/ 0/页/4 然后我在 xcode 中创建了类似的代码,其中有 2 个文件
- ConsumePillServiceViewController.m
- ConsumePillServiceViewController.h 文件
现在, 使用 xcode 的设计器,我创建了 5 个文本框(Me_id、Mem_device_id、Test_datetime、Creation_id、PillBayNo),其中所有参数均根据我们的服务需求进行硬编码 然后修改我的 ConsumePillServiceViewController.h 文件,如下所示,
@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
我做了网站中所示的所有操作,当我构建应用程序时,它成功构建了 但在调试窗口中我看到
(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. ---> One or more errors occurred during processing of command.
ORA-00936: missing expression</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
如果一切正常它应该返回 true 这个 ORA-00936 错误是什么意思,
因为它与 webservice
无关请帮我解决这个问题
提前致谢, 瓦伊巴夫·德什潘德
I have oracle database and using webservice i want to insert some records in to it
So i created webservice in asp.net as follows
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;
}
this function did all data insertion trick for me i tested this service on the local mechine with ip address
http:72.44.151.178/PickPillService.asmx
then,
I see an example on how to attach asp.net web service to iphone apps
http://www.devx.com/wireless/Article/43209/0/page/4
then i created simillar code in xcode which has 2 files
- ConsumePillServiceViewController.m
- ConsumePillServiceViewController.h file
Now,
Using Designer of xcode i created 5 textboxes(Me_id,Mem_device_id,Test_datetime,Creation_id,PillBayNo) with all parameters hardcode as our service demands
then modify my ConsumePillServiceViewController.h file as follows
@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
I did all things as shown in the website and when i built application it successfully built
but in the debuggin window i see
(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. ---> One or more errors occurred during processing of command.
ORA-00936: missing expression</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
It should return me true if all things are ok
What is this ORA-00936 error all about
as it is not releted with webservice
Please help me solving this problem
Thanks in advance,
Vaibhav Deshpande
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论