我谦卑地请求你在这个主题上的帮助,总是收到0字节
这是我遇到的输出:
TestWCFCalls[94830:f803] didReceiveResponse
2011-12-14 17:11:37.054 TestWCFCalls[94830:f803] connectionDidFinishLoading
2011-1214 17:11:37.055 TestWCFCalls[94830:f803] DONE. Received Bytes: 0
(IBAction)buttonClicked:(id)sender {
//Variables used
NSMutableData *webData;
NSString *soapMessage = NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap12:Envelope \n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n"
"xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"> \n"
"<soap12:Body> \n"
"<MobileLogOn xmlns=\"http://tempuri.org/\"> \n"
"<userID>test</userID><PWD>test</PWD></MobileLogOn> \n"
"</soap12:Body> \n"
"</soap12:Envelope>"];
NSLog(soapMessage);
NSURL *url = [NSURL URLWithString:@"http://10.10.10.75:8731/Design_Time_Addresses/MobileWCFService.WCFServices/UserLogOnServ/"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/iUserLogOnServ/MobileLogOn" forHTTPHeaderField:@"Soapaction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection) {
NSLog(@"test");
webData = [[NSMutableData data] retain];
}
else {
NSLog(@"theConnection is NULL");
}
}
-Web配置 -
<service behaviorConfiguration="MobileWCFService.WCFServices.MobileUserLogOnServBehavior"
name="MobileWCFService.WCFServices.MobileUserLogOnServ">
<endpoint address="" binding="wsHttpBinding" bindingName="MobileLogOnBinding"
contract="MobileWCFService.WCFServices.IMobileUserLogOnServ">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://10.10.10.75:8731/Design_Time_Addresses/MobileWCFService.WCFServices/MobileUserLogOnServ/" />
</baseAddresses>
</host>
</service>
我不确定我错过了哪一部分,但我很确定我错过了一些观点,虽然我可以拨打服务部分,但我没有收到任何数据。
亲切的谢谢, SEL
答案 0 :(得分:0)
对于从iOS使用,WCF绑定应该是BasicHttpBinding。在你的情况下,它是wsHttpBinding。这可能是原因。