2013-02-16 2 views
1

I referred this link & 매우 유용하다고 생각했지만 가능한 모든 것을 시도하기 시작했을 때 나는 원하는 출력을 얻지 못했습니다.SVC webservice - objective-c

NSString *soapMessage = [NSString stringWithFormat: 
         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
         "<SOAP:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" 
         "<SOAP:Body>\n" 
         "<BindCategory xmlns=\"http://tempuri.org/\">\n" 
         "</SOAP:Body>\n" 
         "</SOAP:Envelope>\n" 
         ]; 

NSLog(@"soapMessage: \n%@",soapMessage); 

NSURL *url = [NSURL URLWithString:@"http://assetwebservice.sudesi.in/Service/"]; 

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/IService/BindCategory" forHTTPHeaderField:@"SOAPAction"]; 
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

나는 약간의 실수를해야한다고 생각합니다. 나는 다음과 같은 결과를 얻고있다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>404 (Page Not Found) Error - Ever feel like you're in the wrong place?</title> 
<link href="http://p3nlhclust404.shr.prod.phx3.secureserver.net/SharedContent/404-etc-styles.css" rel="stylesheet" type="text/css" media="screen" /> 
</head> 
<body> 
    <div class="body-404"> 
     <h1> 
      <span>Ever feel you're in the wrong place</span> 
     </h1> 
     <div class="info-container"> 
      <div class="inner-border clear-fix"> 
       <h2 class="info-top"> 
        404 (Page Not Found) Error 
       </h2> 
       <div class="site-owner-404"> 
        <h3>If you're the <strong>site owner,</strong> one of two things happened:</h3> 
        <ol> 
         <li> 
          1) You entered an incorrect URL into your browser's address bar, or 
         </li> 
         <li> 
          2) You haven't uploaded content. 
         </li> 
        </ol> 
       </div>  
       <div class="site-visitor-404"> 
        <h3>If you're a <strong>visitor</strong> and not sure what happened:</h3> 
        <ol> 
         <li> 
          1) You entered or copied the URL incorrectly or 
         </li> 
         <li> 
          2) The link you used to get here is faulty. 
         </li> 
         <li class="last"> 
          (It's an excellent idea to let the link owner know.) 
         </li> 
        </ol> 
       </div> 
      </div> 
     </div> 
    </div> 
</body> 
</html> 

내가 뭘 잘못하고 있는지 이해하는 데 도움을 줄 수 있습니까? 도움을 주시면 감사하겠습니다.

답변

3

안녕 얘들 아 솔루션을 발견. 비누 메시지의 두 번째 줄이 수정되었습니다.

"<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/\">\n" 
       "<soap:Body>\n" 

또한 URL 문자열 .svc 확장자가 누락되었습니다. 나는 그 진술로 그것을 바로 잡았다. http://assetwebservice.sudesi.in/service.svc soapaction 매개 변수는 대문자 인 반면 service.svc의 s는 소문자입니다.

다음은 http 헤더 매개 변수가있는 전체 비누 메시지입니다. 아직도 날 혼란

NSString *soapMessage = [NSString stringWithFormat: 
         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
          "<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/\">\n" 
         "<soap:Body>\n" 
         "<BindCategory xmlns=\"http://tempuri.org/\">\n" 
         "</BindCategory>\n" 
         "</soap:Body>\n" 
         "</soap:Envelope>\n" 
         ]; 
NSLog(@"soapMessage: \n%@",soapMessage); 

NSURL *url = [NSURL URLWithString:@"http://assetwebservice.sudesi.in/service.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/IService/BindCategory" forHTTPHeaderField:@"soapaction"]; 
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

한 가지는 그것이 나를 던져 GET 요청 "연결 오류"경우에도 나는이 게시물에 대한

+1

감사를 POST로 변경하는 경우 NSLog &이 성공한다는 것입니다. 코드 작동 +1 – Pramesh

+0

@Pramesh 안녕하세요, 감사합니다. –