webservice and soap ios
来源:互联网 发布:正版蓝博软件 编辑:程序博客网 时间:2024/05/22 06:55
第一种方式:
//构建http请求对象
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
//以下对请求信息添加属性前四句是必有的,第五句是soap信息。
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"www.example.org/services/VersionUpdate/getVersionInfo" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: [NSString stringWithFormat:@"%d", xmlstr.length] forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:data ];// [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
DMXProtocolFactory *haha = [[DMXProtocolFactory alloc]init];
//发送异步请求
// NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:haha];
//如果连接已经建好,则初始化data
if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
// 發送同步請求, 這裡得returnData就是返回得數據楽
NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:nil error:nil];
NSString *str = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
第二种方式:(用ASIFormDataRequest 或 ASIHTTPRequest 请求都可以 --- 但要配置好头信息)
// ASIFormDataRequest *reques = [[ASIFormDataRequest alloc]initWithURL:url];
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
//设置ASIHTTPRequest代理
// request.delegate = aRequestModel.delegate;
//设置协议请求类型
[request setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1],@"RequestType",nil]];
// 设置请求方式
[request setRequestMethod:@"POST"];
// 设置请求头
[request setRequestHeaders:[NSMutableDictionary dictionaryWithDictionary:[DMXProtocolInteractiveEngine commonHeader:xmlstr.length]]];
// 设置post的数据
[request setPostBody:data];
[request startSynchronous];
NSError *errors = [request error];
NSString *response = nil;
if (!errors)
{
response = [request responseString];
}
- webservice and soap ios
- iOS webservice+soap
- ios webservice+soap编程
- iOS+webservice+soap
- iOS webservice+soap
- WebService SOAP request and response
- iOS +AFNetworking2.0+webservice+soap
- IOS之 soap协议 webservice篇
- iOS调用WebService(SOAP接口)
- iOS WebService SOAP 请求的实现
- SOAP,WebService
- WebService,SOAP
- webservice soap
- webservice soap
- WebService SOAP
- WebService,SOAP
- webservice soap
- webservice--SOAP
- GRASP模式
- 科学岛游记
- 写了个简单的内联API钩子类
- Java连接各种数据库的实例
- 【php】目录操作
- webservice and soap ios
- Android SDK更新 Connection to http://dl-ssl.google.com refused 解决方法
- 棋牌游戏服务器架构: 详细设计(二) 应用层设计
- 说句公道话
- C语言的 debug,log,try的区别和用法
- sizeof new delete
- 以后还得自已写点东西
- 母版页中引用图片,外部js、css文件的路径问题
- “ 第一次亲密接触”—系统测试