【问题标题】:Is it possible to use wsdl web service in iphone?是否可以在 iphone 中使用 wsdl 网络服务?
【发布时间】:2011-10-03 05:38:22
【问题描述】:

大家好.....

 I am using wsdl web service in my project.I don't know how to use it.But from the wsdl2objc i generate the wsdl into objective c form.And after that i implement it into my project.In my wsdl there are many methods like getCountryList,getCityList,getCompanyContact....etc.Now i have a problem...i mean i fetched getCityList but not all city is shown in my city list.
Now i don't know what is the problem in my code.

请告诉我一些建议......如果你理解我的问题......我的代码是......

- (SoapRequest*) getScanCustomerCompanies: (id <SoapDelegate>) handler machineId: (NSString*) machineId loc: (NSString*) loc cat: (int) cat pausefollow:(int)pausefollow favorite:(int)favorite activeontop:(int)activeontop nationwide:(int)nationwide orderby:(int)orderby
{
    return [self getScanCustomerCompanies: handler action: nil machineId: machineId loc: loc cat: cat pausefollow:pausefollow favorite:favorite activeontop:activeontop nationwide:nationwide orderby:orderby];
}

- (SoapRequest*) getScanCustomerCompanies: (id) _target action: (SEL) _action machineId: (NSString*) machineId loc: (NSString*) loc cat: (int) cat pausefollow:(int)pausefollow favorite:(int)favorite activeontop:(int)activeontop nationwide:(int)nationwide orderby:(int)orderby
{
    NSMutableArray* _params = [NSMutableArray array];

    [_params addObject: [[[SoapParameter alloc] initWithValue: machineId forName: @"machineId"] autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue: loc forName: @"loc"] autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: cat] forName: @"cat"] autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue:[NSNumber numberWithInt:pausefollow] forName:@"pausefollow"]autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue:[NSNumber numberWithInt:favorite] forName:@"favorite"]autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue:[NSNumber numberWithInt:activeontop] forName:@"activeontop"]autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue:[NSNumber numberWithInt:nationwide] forName:@"nationwide"]autorelease]];
    [_params addObject: [[[SoapParameter alloc] initWithValue:[NSNumber numberWithInt:orderby] forName:@"orderby"]autorelease]];

    NSString* _envelope = [Soap createEnvelope: @"getScanCustomerCompanies" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
    SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"urn:abc#getScanCustomerCompanies" postData: _envelope deserializeTo: [[SDZscanCustomerCompanies alloc] autorelease]];
    [_request send];
    return _request;
}

谢谢.......

【问题讨论】:

    标签: iphone sdk


    【解决方案1】:

    您可以在此处试用在线提供的工具:

    http://sudzc.com/

    每当我需要处理 SOAP 请求时,我总是使用此服务。

    【讨论】:

    • 我也在使用这个。但我在获取数据时遇到问题。我的所有城市都没有在我的列表中获取。我的意思是我的网络服务器上有 30 个城市。但只有 21 个城市返回给我.. .告诉我我在做什么......?
    • 检查可能损坏的 XML 或节点不正确。如果两者都不是,那么继续并再次生成类并使用它们。
    • 我都做了,我检查了 XML 是否正常工作,我也尝试重新生成类。但我不知道会发生什么......你有一些链接或代码示例...... ?
    • 转储它...只是为了解析不要使用它。这是另一个解决方案,应该很有用:troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter>
    • @KPT....感谢您的帮助。我正在检查和学习此链接..此链接是否可以帮助我使用 wsdl?
    【解决方案2】:

    是的,iOS 可以使用包括 WSDL 样式的 WebServices。 可能没有人知道您的问题出在哪里,因为您还没有发布任何代码。

    编辑:

    Cudzc 生成器创建一个根据您在网站上指定的 wsdl 名称和前缀命名的类。在这个类中,我必须根据肥皂标准更改名称空间和 url。

    - (id) 初始化 { 如果(自我 = [超级初始化]) { self.serviceUrl = @"https://isir.justice.cz:8443/isir_ws/services/IsirPub001"; self.namespace = @"urn:IsirPub001/types"; self.headers = nil; self.logging = YES; } 回归自我; }

    基本上我建议您使用 SOAPUI,在您的机器上测试服务并与您的代码生成的请求进行比较。

    【讨论】:

    • 您是否尝试过通过 SOAP UI 或类似的方式调用 Web 服务来测试源代码?只是猜测问题可能出在源端。
    • 我只是使用来自 wsdl2objc 的内置代码并在该代码中使用 NSXMLParsing……soap 调用在生成的代码中。但它并没有显示所有公司列表。 ....你能告诉我我现在在做什么吗?
    • @vanya....你知道如何在 iphone 中使用 wsdl....你能告诉我一些链接或任何 wsdl 样式的示例
    • 是的,我为 WSDL 使用了另一个代码生成器 sudzc.com,我只是稍微更改了 url 请求并且一切正常。
    • @vanya...我也在使用 sudzc 代码生成器。它是 wsdl2objc 代码生成器...请告诉我你在 url 请求中做了什么更改..plz
    最近更新 更多