gpt4 book ai didi

iphone - WCF 服务不适用于 iPhone

转载 作者:行者123 更新时间:2023-11-29 04:10:23 25 4
gpt4 key购买 nike

我有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com