【iOS SOAP】基于第三方开源项目:wsdl2objc
来源:互联网 发布:sql攻击 政府网站 编辑:程序博客网 时间:2024/05/20 11:46
转自:http://www.cnblogs.com/dyingbleed/archive/2013/01/18/2866210.html
【iOS SOAP】基于第三方开源项目:wsdl2objc
wsdl2objc
地址:http://code.google.com/p/wsdl2objc/
服务器端,参考:【Web Service】Apache Tuscany发布Web Service
准备工作:
svn checkout http://wsdl2objc.googlecode.com/svn/trunk/
<生成代码
运行WSDLParser项目
WSDL栏输入wsdl的地址
Output Location栏输入输出代码的目录
点击Parse WSDL按钮生成代码:
<添加到项目
<支持libxml2
TARGETS -> Build Settings -> Linking -> Other Linker Flags,设置“-lxml2”
TARGETS -> Building Settings -> Apple LLVM compiler 4.1 - Language -> Other C Flags,设置“-I/usr/include/libxml2”
<添加framework
TARGETS -> Build Phases -> Link Binary With Libraries,添加CFNetwork.framework
代码示例
#import <UIKit/UIKit.h>#import "IHelloWorldService.h"@interface ViewController : UIViewController <IHelloWorldServiceBindingResponseDelegate> { UITextField *mNameTextField; UITextView *mMessageTextView; }@property (retain, nonatomic) IBOutlet UITextField *nameTextField;@property (retain, nonatomic) IBOutlet UITextView *messageTextView;- (IBAction)sendButtonPressed:(id)sender;@end
#import "ViewController.h"@interface ViewController ()@end@implementation ViewController@synthesize nameTextField = mNameTextField, messageTextView = mMessageTextView;- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (IBAction)sendButtonPressed:(id)sender { IHelloWorldServiceBinding *binding = [IHelloWorldService IHelloWorldServiceBinding]; IHelloWorldService_say *say = [[IHelloWorldService_say new] autorelease]; say.arg0 = [mNameTextField text]; [binding sayAsyncUsingSay:say delegate:self];}- (void)operation:(IHelloWorldServiceBindingOperation *)operation completedWithResponse:(IHelloWorldServiceBindingResponse *)response { NSArray *responseHeaders = response.headers; NSArray *responseBodyParts = response.bodyParts; for(id header in responseHeaders) { // here do what you want with the headers, if there's anything of value in them } for(id bodyPart in responseBodyParts) { if ([bodyPart isKindOfClass:[SOAPFault class]]) { // continue; } if([bodyPart isKindOfClass:[IHelloWorldService_sayResponse class]]) { IHelloWorldService_sayResponse *body = (IHelloWorldService_sayResponse*)bodyPart; NSString *text = body.return_; mMessageTextView.text = [NSString stringWithFormat:@"%@\n%@", mMessageTextView.text, text]; continue; } }}@end
Build,报错:"libxml/tree.h" file not found
解决方法:
PROJECT -> Build Settings -> Search Paths -> Header Search Paths,设置“${SDK_DIR}/usr/include/libxml2”
TARGETS -> Build Settings -> Search Paths -> Header Search Paths,设置“${SDK_DIR}/usr/include/libxml2”
参考:http://mmz06.blog.163.com/blog/static/121416962012913202818/
Build,Run
请求,参数为“Anthony”
相应,内容为“Hello null”
wsdl2objc Bug!!!
解决方法:修改文件IHelloWorldService.m中,类“IHelloWorldService_say”的“- (void)addElementsToNode:(xmlNodePtr)node”方法。
设置元素命名空间前缀为“nil”
xmlAddChild(node, [self.arg0xmlNodeForDoc:node->docelementName:@"arg0"elementNSPrefix:nil]);
Build,Run
成功!!!
- 【iOS SOAP】基于第三方开源项目:wsdl2objc
- 【iOS SOAP】基于第三方开源项目:wsdl2objc
- 【iOS SOAP】基于第三方开源项目:wsdl2objc
- 基于第三方开源项目:wsdl2objc
- IOS开发笔记 - 基于wsdl2objc调用webservice
- wsdl2objc
- iOS-90-调用后台接口(WCF,soap访问方式,接口后缀.svc形式),使用WSDL2objc工具才能搞定
- IOS第三方开源项目
- iOS使用WSDL2ObjC工具调用Webservice接口
- openmeetings2.0版本基于SOAP与第三方应用集成
- iOS非常好用的第三方开源项目
- 基于DLNA实现iOS,Android投屏:SOAP控制设备
- IOS:SOAP(Webservice)请求基于AFN2.6之后
- iOS项目常用第三方开源库
- iOS项目常用第三方开源库
- iOS 基于第三方QQ授权登录
- iOS项目常用第三方开源库网址
- iOS第三方应用项目实战
- 算法思想
- 输入一个数字求阶乘
- linux命令和Linux基本常用的知识详解
- java连接几种常用数据库的代码
- ubuntu 12.04 64位 安装ADT搭建安卓开发环境
- 【iOS SOAP】基于第三方开源项目:wsdl2objc
- 蛇形矩阵的解答
- The Snail
- TCP/IP 主要报文头格式
- Steps
- 辞旧迎新,2013年年终感言
- LinkedHashMap与HashMap
- 如何学习网络编程
- 更改ejs模板后缀.ejs为.html