어. 나는 SOF에서 비슷한 질문을 몇 개 읽었지만 지금까지는 그 해결책 중 어느 것도 나를 위해 일해 오지 않았다.iOS에서 WCF에 연결
iOS7 클라이언트를 WCF 웹 서비스에 연결하려고합니다. 먼저 WCF 서비스를 작성하지 않았으며 하나도 작성하지 않았 음을 지적하겠습니다. 그래서 저는 꽤 WCF 바보입니다. 내가 이해하는 것처럼, 아이디어는 기본적으로 SOAP xml 패킷을 만들어서 보내고, XML 응답을 기다린다. .NET에서 실행되는 테스트 클라이언트가 제대로 작동하므로, Fiddler를 켜고 작성한 사람이 xml 및 요청 헤더가 어떻게 보이는지 확인할 수있었습니다. 광산은 이제 자신의 동일, 그러나 나는 서버에서 소집 할 수있는 유일한 응답은 : 그 이후
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action 'http://www.tempuri.org/IFoolSpoon_SoWo_Service/Check_Item_test' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault></s:Body></s:Envelope>
는 화면 밖으로 WAY 스크롤됩니다 - 그것은 ContractMismatch 오류입니다 - 그 사실을 의미 뭐든간에. 문제 : 위의 오류 메시지를 찾기 위해 "계약"이라는 단어를 사용하지 않고 누구나 "계약"이라는 용어를 설명하는 것은 불가능한 것처럼 보입니다. ;) 내가 본 모든 설명은 기본적으로 "계약과 같습니다. 클라이언트와 서버 간의 계약처럼 ... 계약과 같습니다." :(
어쨌든, 여기에 이름과 관련 OBJ-C 코드입니다/URL은 유죄 보호하기 위해 변경 :. 위의 코드에 대해
// construct a URL that will ask the service for what we want
NSURL *url = [NSURL URLWithString:@"http://mymachine.myisp.com/SOWO/MyService.svc"];
// build the SOAP envelope
NSString *soapMessage = [NSString stringWithFormat:
@"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<s:Body >\n"
"<Check_Item_test xmlns=\"http://derp.org/\">\n"
"<UPC>1090000021</UPC>\n"
"</Check_Item_test>\n"
"</s:Body>\n"
"</s:Envelope>\n"];
soapMessage = [soapMessage stringByReplacingOccurrencesOfString:@"\n" withString:@"\r\n"];
// put URL into a NSURLRequest
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
NSLog(@"length = %@", msgLength);
[req addValue: @"text/xml" forHTTPHeaderField:@"Content-type"];
[req addValue: @"http://www.tempuri.org/IServiceInterface/Check_Item_test"
forHTTPHeaderField:@"SOAPAction"];
[req addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[req addValue:@"100-continue" forHTTPHeaderField:@"Expect"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
일부 노트에서 동일한 서비스를 호출하는 다른 개발자가있다 루비와 그는 몇 가지 언급했는데, 라인 엔딩을 \ n \ n에서 \ n으로 바꾸는 것이 그의 제안이었습니다. 그게 문제 였음을 알았고, SOAPAction에 대한 SOAPaction, 이제는 xml/헤더도 정확히 일치하지만 행운은 없습니다.
내 요청은 다음과 같습니다 (OSX Fiddler와 동일).
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body >
<Check_Item_test xmlns="http://derp.org/">
<UPC>1090000021</UPC>
</Check_Item_test>
</s:Body>
</s:Envelope>
다른 모든 클라이언트와 일치하는 것으로 보입니다. 모든 클라이언트가 내 작업을 저장합니다. 그럼 네? 도와 주실 래요? 나는 한 번 서비스에 대한 web.config에서 오전 및 서버에 .svclog 액세스 할 수 있습니다. 흥미롭게도 충분히 - 내 요청이 기록되지 않습니다. 심지어 logMalformedRequests가 true로 설정되어 있습니다. 내 요청이 들어오는 bitbucket이 무엇인지 확인해야 할 부분에 대한 제안은 감사하겠습니다.
그래, 짜증이 나고, 좌절하고, 피곤하다. 너무 단순해야만하는 것을 위해, 이것은 거대한 고통으로 밝혀졌습니다. 어쩌면 어리석은 일일 것입니다. 그래서 아마도 저는 제 자신보다 더 많은 눈이 필요합니다.
TIA.
휴가를 보내는 군중에게이 사실을 알려주세요. – MonkRocker