Microsoft WCF和iOS之间的可靠信息互操作性

如何从iOS Objective-C代码调用WCF wsHttpBinding启用可靠会话的Web服务..我写了一个访问该服务的通用代码,但出现此错误“The action http://tempuri.org/MyService/AuthneticateUser不受此端点支持,只有WS-ReliableMessaging 2005年2月的消息由此端点处理“。

在这里我的代码

<NSString *stringAuthenticateUsr=@"<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
   <a:Action s:mustUnderstand="1">tempuri.org/MyService/AuthneticateUser
       </… xmlns:h="tempuri.org">1</h:ApplicationID>
         <h:DeviceID xmlns:h="tempuri.org">1</h:DeviceID>
         <h:Password xmlns:h="tempuri.org">Password1</h:Password>
        <a:MessageID>urn:uuid:041b‌​65a7-4ab2-4da9-ba3b-05d5cccfe074</a:MessageID> 
        <a:ReplyTo><a:Address>w3.org/2005/08/addressing/anonymous</a:Address>
      </… s:mustUnderstand="1">MySvcUrl
   </a:To>
  </s:Header>
  <s:Body />
</s:Envelope>";

NSURL * url = [NSURL URLWithString:MySvcUrl];

NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:0];
[theRequest setCachePolicy:NSURLCacheStorageNotAllowed];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[stringAuthenticateUsr length]];
[theRequest addValue: @"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/MyService/AuthneticateUser" forHTTPHeaderField:@"Soapaction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPShouldHandleCookies:YES];
[theRequest setHTTPBody: [stringAuthenticateUsr dataUsingEncoding:NSUTF8StringEncoding]];

NSHTTPURLResponse *响应; NSError * error = nil; NSData * resultData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error]; NSString * result = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding]; 的NSLog(@ “的结果 - %@”,结果);

链接地址: http://www.djcxy.com/p/68091.html

上一篇: ReliableMessaging interoperability between Microsoft WCF and iOS

下一篇: setbackground loading with do while loop