WSDL的Objective-C SOAP客户端生成器? [英] SOAP Client Generator for Objective-C from WSDL?

查看:145
本文介绍了WSDL的Objective-C SOAP客户端生成器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持使用SOAP集成项目。我需要从iPad应用程序调用一些SOAP Web服务。

I'm stuck on a SOAP integration project. I need to call some SOAP Web Services from an iPad app.

我有 WSDL ,我需要生成Objective-C类来调用服务调用。

I have the WSDL, and I need to generate the Objective-C classes to invoke the service calls.

Mac开发人员库有一个< a href =https://developer.apple.com/library/mac/documentation/Networking/Conceptual/UsingWebservices/Tasks/Tasks.html#//apple_ref/doc/uid/TP30000985-CH101-SW3\"rel =nofollow >示例:使用HTTP身份验证调用SOAP操作,但它链接到的示例代码已损坏( SOAP_AuthExample.dmg,404

The Mac developer library has an "Example: Calling a SOAP Operation with HTTP Authentication", but the sample code it links to is broken (SOAP_AuthExample.dmg, 404).

Web服务核心编程指南甚至说(强调)补充):

The Web Services Core Programming Guide even says (emphasis added):


目前,OS X 不提供高级支持,用于从WSDL文件中提取SOAP函数。但是,您可以使用NSXMLParser从URL将WSDL文件读入内存。然后,在文件中搜索特定方法名称或查找与服务关联的URL相对简单。通过更多的努力,您可以提取方法名称,数据类型和参数名称来构建SOAP调用。然后,您可以使用Web Services Core框架进行SOAP调用并解析响应。

"Currently, OS X provides no high-level support for extracting SOAP functions from WSDL files. You can use NSXMLParser to read a WSDL file into memory from a URL, however. It is then relatively simple to search the file for a particular method name or to find a URL associated with a service. With a bit more effort, you can extract method names, data types, and parameter names to build a SOAP call. You can then use the Web Services Core framework to make SOAP calls and parse the responses."

我还发现了以下三个然而,第一个是关于一些丢失的文件抛出错误,第二个代码生成并且当我尝试构建(并且重构器不工作)时无休止的ARC错误流,第三个是paywalled。

I've also found the following three generators; however, the first is throwing an error about some missing files, the second's code generates and endless stream of ARC errors when I try to build (and a refactor is not working), and the third is paywalled.


  1. http://easywsdl.com/

  2. https://code.google.com/p/wsdl2objc/

  3. http://sudzc.com/

  1. http://easywsdl.com/
  2. https://code.google.com/p/wsdl2objc/
  3. http://sudzc.com/

任何人都可以引导我朝着正确的方向前进吗?

Can anyone steer me in the right direction?

推荐答案

几个月前我遇到了同样的情况,我目前正在使用需要连接到SOAP服务的iPad应用程序。我已经有了类,但它们是特定的我的项目的ic,我无权分享。但是,我正在制作一个更通用的Objective-C类(无论如何是所有SOAP服务器的最终解决方案),以便与Github上的世界共享它。

I was in your same situation a couple of months ago, and I'm currently working in an iPad app that requires to connect to a SOAP service. I already have the classes, but they are specific for my project and I'm not authorised to share it. However, I'm making a more generic Objective-C class (in any case the final solution for all the SOAP servers) to share it with the world on Github.

首先,您必须设置SOAP消息。它有一个像这样的通用结构:

First of all you have to set the SOAP message. It has a common structure like this:

<?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:Header>
    // here comes the header information: credentials, connection information. If needed, of course
</soap:Header>
<soap:Body>
    // here comes the request parameters. In my case, these parameters are related to a resource called SOAPAction (That identifies the method to be called. e.g getListOfClients). I don't know if it is the same in all servers
</soap:Body>
</soap:Envelope>

我告诉你,我正在制作应用程序的公司为我提供了方法和认证信息。我不知道这是不是你的情况,但你在这里一瞥一下该怎么做。

I say to you, the company for which I'm making the app, has provided me with the methods and authentication information. I don't know if this is your case, but you have here a general glance of what to do.

我用 AFNetworking 以这种方式发送请求:

I use AFNetworking to send the request, in this way:

NSString *messageLength = [NSString stringWithFormat:@"%lu", (unsigned long)[msg length]];

NSURL *requestURL = [NSURL URLWithString:self.requestURL];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];
[theRequest addValue:[requestURL host] forHTTPHeaderField:@"Host"];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:soapAction forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[msg dataUsingEncoding:NSUTF8StringEncoding]];

// sending the request

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:theRequest];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSString *xml = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"Take the data master Yoda: %@", xml);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Bad SOAP server!. Error: %@", error.description)
}];

[[NSOperationQueue mainQueue] addOperation:operation];

self.requestURL 是服务器URL,明显。如果请求成功,那么您已准备好解析服务器的xml响应。如果没有,否则请求错误说明。

self.requestURL is the server URL, obviously. If the request was successful, then you have the server's xml response ready to parse. If not, a request error description otherwise.

这个页面帮助我找到了解决我遇到的一些问题的解决方案,它与网站有关<您在上面引用的一个href =http://sudzc.com/ =nofollow> http://sudzc.com/ :

This page helped me a lot to find out a solution for some issues that I encountered, and it is related to the website http://sudzc.com/ that you quotes above:

http://blog.exadel.com/working-with-ios-and -soap /

我希望这会有所帮助。

这篇关于WSDL的Objective-C SOAP客户端生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆