2010-06-15 4 views
0

webservice 메소드에 비누 요청을 보내려고합니다. 이제 해당 요청에 대한 xml 입력으로 매개 변수를 보내려고합니다. 그래서 PLZ 누구나 내게 아이폰에서 할 방법에 대한 아이디어를 줄 수 있습니까? 지금은 다음과 같은 방식으로 요청을 보냅니다 :아이폰에서 soap webservice 요청에 대한 xml 매개 변수

NSString *soapMessage = 
@"<?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" 
"<GetCustomerInfoXML xmlns=\"http://qa2.alliancetek.com/phpwebservice\">\n" 
"<id><customer><id>1</id></customer></id>" 
"</GetCustomerInfoXML>" 
"</soap:Body>\n" 
"</soap:Envelope>"; 
NSLog(@"%@",soapMessage); 

NSURL *url = [NSURL URLWithString:@"http://qa2.alliancetek.com/phpwebservice/index.php"]; 
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://qa2.alliancetek.com/phpwebservice/index.php//GetCustomerInfoXML" forHTTPHeaderField:@"SOAPAction"]; 
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 

그러나 매개 변수를 xml 형식으로 보내려고합니다. 그래서 나는 그것을 어떻게합니까 ????

답변

2

CDATA 태그의 매개 변수를 <![CDATA["parameters"]]>으로 감 쌉니다. 그러면 서버가 구문 분석하지 않도록 알립니다. 그런 다음 해당 데이터를 서비스로 보내면 정규 XML로 파싱 할 수 있습니다.

관련 문제