2012-11-05 2 views
1

다음 코드를 사용해 보겠습니다. 비누 웹 서비스입니다. 작동하지 않습니다.비누 웹 서비스가 iphone에서 작동하지 않습니다.

나를 도와주세요.

Link

Service

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" 
"<request xmlns=\"http://searchupc.com/GenerateBarcode\">\n" 
"<auth>5ggpf54TRghbnIvqS2XVGQQ0q6qCNuJ</auth>\n" 
"<method>FetchProductByUPC</method>" 
"<params>" 
"<upc>026274920257</upc>" 
"</params>" 
"</request>\n" 

"</soap:Body>\n" 
"</soap:Envelope>\n" 
]; 
NSLog(soapMessage); 

NSURL *url = [NSURL URLWithString:@"http://www.simpleupc.com/api/"]; 
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://searchupc.com/GenerateBarcode/" forHTTPHeaderField:@"SOAPAction"]; 
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 
NSLog(@"SOAP CONNECTED qqq%@",theRequest); 
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

답변

2

확인 http://sudzc.com/. 그것은 당신을 위해 xcode 프로젝트를 생성합니다.

1 : (보호 된 경우, 다음 사용자 이름과 암호를 입력)

2 변환 할 WSDL의 웹 주소를 입력 : 생성 코드 번들의 유형을 선택합니다 (목적 c) 및 다운로드합니다.

'Generated'폴더를 프로젝트에 끌어다 놓기 만하면 모든 SOAP 메시지에 액세스 할 수 있습니다.

시도해보십시오. 정말 쉽고 간단합니다.

+0

WSDL에서 XSD를 가져 오는 경우 생성 된 코드가 작동하지 않는다는 경고가 표시됩니다. 적어도 1 년 전쯤에이 문제가 해결되었는지는 확실하지 않습니다. – bennythemink

+0

@bennythemink : 저는 현재 프로젝트에서 이것을 사용하고 있으며 지금까지 아무런 문제가 없었습니다. 나는 그들이 언급 한 문제를 고쳤고 지적 해 주셔서 고맙다고 생각합니다. – aToz

관련 문제