Objective-C iOS에서 Maginto SOAP API를 사용하려고합니다. 로그인 API를 호출하고 SessionID를 얻을 수 있지만 동일한 SessionID를 가진 다른 API를 호출하려고하면 다음 오류가 발생합니다.Objective-C에서 Magento SOAP API를 호출 할 때 오류 발생
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>5</faultcode><faultstring>Session expired. Try to relogin.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
왜이 오류 메시지가 표시되는지 알 수 없습니다. 누구든지 해결책을 알고 있다면 저를 도우십시오.
미리 감사드립니다. 사람이 다음 솔루션이 있으면 알려주세요
-(void)make_call_to_maginto_api_login{
NSString *soapMessage = @" \
<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"urn:Magento\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> \
<SOAP-ENV:Body> \
<ns1:login> \
<apiUser xsi:type=\"xsd:string\">UserName</apiUser> \
<apiKey xsi:type=\"xsd:string\">Password</apiKey> \
</ns1:login> \
</SOAP-ENV:Body> \
</SOAP-ENV:Envelope>";
NSURL *url = [NSURL URLWithString:@"http://www.hostname.com/index.php/api/v2_soap/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu",(unsigned long)[soapMessage length]];
[request addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"http://www.hostname.com/login" forHTTPHeaderField:@"SOAPAction"];
[request addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(connection)
{
self.webData = [NSMutableData data];
}
else
{
NSLog(@"theConnection is null");
}}
, 그것은 나에게 정말 좋은 것 -
여기 내 로그인 코드입니다. 고마워요 :)
어떻게해야합니까? 그리고 세션 ID API를 가져 오는 방법을 알려주세요. – iphonemaclover
이전에는 SOAP 요청에 문제가 있었기 때문에 변경 작업을 수행하면됩니다. – RJ168
감사합니다. 비누를 사용하여 .svc 서비스를 호출 할 수 있습니까? – iphonemaclover