0
NSString *soapMessage = @" \
<?xml version=\"1.0\" encoding=\"UTF-8\"?> \
<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> \
<username xsi:type=\"xsd:string\">XXXX</username> \
<apiKey xsi:type=\"xsd:string\">123456</apiKey> \
</ns1:login> \
</SOAP-ENV:Body> \
</SOAP-ENV:Envelope>";
NSString *url = @"http://xxx.xxx.xx.xxx/Magento/api/soap/?wsdl";
[urlConnection urlConnection:soapMessage url:url];
[urlConnection setTarget:self withValidSelector:@selector(jsonData:) invalidSelector:@selector(error)];
In urlConnection
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",[postString length]];
[request addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"xxx.xxx.xx.xxx/magento/" forHTTPHeaderField:@"SOAPAction"];
[request addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
以上是我的代碼。它返回了很多帶有html而不是SESSION ID的XML標籤。使用IOS中的SAOP API獲取Magento的會話ID
不工作?運氣好的話? – iphonemaclover 2014-12-15 11:17:21