ios如何使用WSDL2ObjC从webservice获取数据

时间:2013-03-18 02:26:48

标签: ios5 wsdl xcode4.5 wsdl2objc

我无法在iPhone中显示数据。请指教。

getdata.h

    @interface GetDataFromPhoneService_GetPhoneInfoResponse : NSObject {

        /* elements */
        tns2_GetPhoneInfoModel * GetPhoneInfoReturn;
        /* attributes */
            }

    /* elements */
    @property (retain) tns2_GetPhoneInfoModel * GetPhoneInfoReturn;
    /* attributes */
    - (NSDictionary *)attributes;
    @end
    @interface GetDataFromPhoneService_GetPhoneInfo : NSObject {

        /* elements */
        NSString * phoneNo;
        /* attributes */
    }


    @property (retain) NSString * phoneNo;


    @end


    @interface GetDataFromPhoneSoapBinding_GetPhoneInfo :         GetDataFromPhoneSoapBindingOperation {
        GetDataFromPhoneService_GetPhoneInfo * parameters;
    }
    @property (retain) GetDataFromPhoneService_GetPhoneInfo * parameters;

getdata.m

    @implementation GetDataFromPhoneService_GetPhoneInfo
    - (id)init
    {
        if((self = [super init])) {
            phoneNo = 0;
        }

        return self;
    }
    - (void)dealloc
    {
        if(phoneNo != nil) [phoneNo release];

        [super dealloc];
    }
    - (NSString *)nsPrefix
    {
        return @"GetDataFromPhoneService";
    }

getview.m

    - (IBAction)buttonClick:(id)sender {
        GetDataFromPhoneSoapBinding *binding = [[GetDataFromPhoneService                 GetDataFromPhoneSoapBinding] initWithAddress:@"http://..."];
        binding.logXMLInOut = YES;  // to get logging to the console.

     GetDataFromPhoneService_GetPhoneInfo *request =         [[GetDataFromPhoneService_GetPhoneInfo alloc] init];
        request.phoneNo = @"66875920808";  // insert your phone number here.

        GetDataFromPhoneSoapBindingResponse *resp = [binding GetPhoneInfoUsingParameters:request];
        for (id mine in resp.bodyParts)
        {
            if ([mine isKindOfClass:[GetDataFromPhoneService_GetPhoneInfoResponse class]])
            {

                greeting.text = [mine GetPhoneInfoReturn];

            }
        }

这是数据。

  <p372:GetPhoneInfoResponse xmlns:p372="http://Bean.crew.cw.tg">
     <GetPhoneInfoReturn>
        <zimPersno>40347</zimPersno>
        <firstname>WANCHART</firstname>
        <lastname>SANGSUK</lastname>
     </GetPhoneInfoReturn>
  </p372:GetPhoneInfoResponse>

0 个答案:

没有答案