我一直试图让我的 iPhone 应用程序与 WCF 服务通信。我的应用程序成功连接/找到了 Web 服务,但似乎从来没有得到非错误响应。当我使用视觉工作室 wcf 测试仪时,它工作正常。
xml格式:<mAccess><user></user><pwd></pwd></mAccess>
我的头部/身体结构有问题吗?
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:website]];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-type"];
NSString *soapMessage = [[NSString alloc] initWithFormat:@"<SOAP-ENV:Envelope
xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body>
<MobileAccess xmlns=\"http://tempuri.org/\"><mAccess><user>user</user><pwd>pwd</pwd><custID>0</custID></mAccess>
</MobileAccess></SOAP-ENV:Body></SOAP-ENV:Envelope>"];
[request setValue:[NSString stringWithFormat:@"%d",[soapMessage length]] forHTTPHeaderField:@"Content-length"];
[request addValue:@"http://tempuri.org/IProviderDataService/MobileAccess" forHTTPHeaderField:@"Soapaction"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];