iphone - WCF 服务不适用于 iPhone

标签 iphone ios web-services ipad

我有 WCF 服务:

http://parentportal.technologyorg.com/ParentPortal.svc

我必须访问并获取数据。但不幸的是我得到了一些 HTML 代码。

我的代码如下

-(IBAction)doit:(id)sender{

    NSString *soapMessage = [NSString stringWithFormat:@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://parentportal.technologyorg.com/ParentPortal.svc\"><SOAP-ENV:Body><GetDictionary></GetDictionary></SOAP-ENV:Body></SOAP-ENV:Envelope>"];

    NSURL *url = [NSURL URLWithString:@"http://parentportal.technologyorg.com/ParentPortal.svc"];
                  NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
                  NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

                  [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
                  [theRequest addValue: @"GetStudentTerms" forHTTPHeaderField:@"SOAPAction"];
                  [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
                  [theRequest setHTTPMethod:@"POST"];
                  [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"%@",theRequest);
                  NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if (theConnection) {
     webData = [NSMutableData data] ;
    }
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"___didReceiveResponse");
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSLog(@"Status code %d", [httpResponse statusCode]);

    [webData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    NSLog(@"___didReceiveData");
    [webData appendData:data];
    NSLog(@"%@",webData);
}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
    NSLog(@"___connectionDidFinishLoading");
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *xmlData = [[NSString alloc]
                         initWithBytes:[webData mutableBytes]
                         length:[webData length]
                         encoding:NSUTF8StringEncoding];

}

我不确定如果我 NSLog 出了什么问题,我会输出一些 HTML 代码。

谁能帮我解决这个问题吗?

最佳答案

尝试 SudzC基于 SOAP 的 Web 服务定义 WSDL 文件

Code generation用于 iPhone 开发的 Objective-C 库。

按照以下步骤操作

enter image description here

enter image description here

关于iphone - WCF 服务不适用于 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14494214/

相关文章:

iphone - 使用 Junit 进行 UI 测试

iphone - 在类方法中访问全局声明的 NSArray 值时出错

IOS应用程序与CFNetwork崩溃,但找不到问题

ios - 如何将 self.parseClassName 设置为用户类?

iphone - 在 iOS 应用程序的文档文件夹中创建一个文件夹

android - 如何在 Flutter 中制作水平数字选择器小部件?

ios - NSURLRequest Null(没有编码问题)

c# - WCF 服务 - 向后兼容性问题

通过 HTTPS 在 Soap UI 中调用 Web 服务时出现 javax.net.ssl.SSLException

web-services - 面向服务架构中的集中身份验证