2012-03-12 50 views
1

私はiPhoneアプリケーションで動作するようにWCF SOAPサービスを作成します。サービスクライアント "Coded Client"とVSのWCFテストクライアントツールでうまく動作しますが、働いている。安全なWCFが非ウィンドウで動作しないクライアントiPhone

<services> 
     <service behaviorConfiguration="ServiceBehavior" name="HR_Service.Service"> 
     <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="" 
      name="MexHttpsBindingEndpoint" contract="HR_Service.IService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" 
      httpsGetBinding="" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
      <dataContractSerializer maxItemsInObjectGraph="6553600" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

とASP.netセッションcompaability

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
     multipleSiteBindingsEnabled="true" /> 

をして私のiPhone: WCFそれはこの

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpEndpointBinding" maxBufferPoolSize="2147483647" 
     maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" /> 
     <security mode="TransportWithMessageCredential"> 
     <transport clientCredentialType="None" /> 
     <message clientCredentialType="UserName" negotiateServiceCredential="false" 
      establishSecurityContext="false" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

や行動などのように結合してHTTPS構成

の仕事ですこのようなもの

証明書を受け入れるには210
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host 
{ 
    return YES; // Or whatever logic 
} 

+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host 
{ 
} 

は、SOAPエンベロープ

NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns=\"http://tempuri.org/\"><soap:Body><Authenticate><userid>username</userid><password>pass</password></Authenticate></soap:Body></soap:Envelope>"]; 

その後、エンベロープ

NSURL *url = [NSURL URLWithString:@"https://mywebsite.com/Service/Service1.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: @"http://tempuri.org/IService1/Authenticate" forHTTPHeaderField:@"soapAction"]; 
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
    [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; 
    [theRequest setHTTPMethod:@"POST"];  
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

    if(theConnection) { 
     webData = [NSMutableData data] ; 
    } 
    else { 
     NSLog(@"theConnection is NULL"); 
    } 

NSURLConnectionDelegate

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 
    [webData setLength:0]; 
} 

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    [webData appendData:data]; 
} 

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 
    NSLog(@"%@",[NSString stringWithFormat:@"Connection failed: %@", [error description]]); 
} 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection { 

    NSLog(@"Data has been loaded"); 

    NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding]; 


    NSLog(@"Respose Data :%@",responseString) ; 


} 

常時接続の成功が、応答後、サーバーを構成しますデータは常に空になる

答えて

0

あなたSOAPMessageのは間違っている、あなたが文字列

soamMessageに間違ったタグ

使用「認証」タグの代わりに「テスト」タグを使用している

関連する問題