iPhoneアプリケーションでMagento Webサービス(Magento ver。1.6.0.0)に問題があります。実際、私はこのコード(製品リストコード)を製品リストにログインして持つことができます -Magento Web Service "product.info"エラー:製品が存在しません
NSMutableString *parameters = [NSMutableString stringWithFormat:@"<sessionId>%@</sessionId><resourcePath>%@</resourcePath>", session, @"product.list"];
NSString *operation=[NSString stringWithString:@"call"];
NSString *xmlNamespace=[NSString stringWithString:storeWsdlLink];
NSString *adress=[NSString stringWithString:storeURL];
NSString *operatorTag = [NSString stringWithFormat:@"<%@ xmlns=\"%@\">%@</%@>\n", operation, xmlNamespace, parameters, operation];
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/adressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\n"
" <s:Header>\n"
" <To xmlns=\"http://www.w3.org/2005/08/adressing\">%@</To>\n"
" <a:Action>http://tempuri.org/IService1/%@</a:Action>\n"
" </s:Header>\n"
" <s:Body>\n"
" %@"
" </s:Body>\n"
"</s:Envelope>\n", adress, operation, operatorTag
];
ASIHTTPRequest *asiRequest = [[ASIHTTPRequest alloc]initWithURL:[NSURL URLWithString:adress]];
[asiRequest setDelegate:self];
[asiRequest setURL:[NSURL URLWithString:adress]];
[asiRequest setTimeOutSeconds:30];
[asiRequest addRequestHeader:@"application/soap+xml; charset=utf-8" value:@"Content-Type"];
[asiRequest setRequestMethod:@"POST"];
[asiRequest setPostBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[asiRequest startAsynchronous];
私はこれを「parameters
」を交換する場合、これは動作しません: - 私は
parameters = [NSMutableString stringWithFormat:@"<sessionId>%@</sessionId><resourcePath>%@</resourcePath><sku>%i</sku>", session, @"product.info", 12345];
「Product not exists.
」というエラーメッセージが表示され、「101
」というコードエラーが発生しました。
フォーラムの中には、「12345」(SKU of Product)の後ろにスペースを追加するようにアドバイスするものもありますが、これは機能しません。
ありがとうございました。
編集: -
私はMagentoのWebサービスを呼び出すためにPHPを使用して、それが動作します: -
$proxy = new SoapClient('xxx/api/?wsdl');
$sessionId = $proxy->login('userName', 'apiKey');
echo json_encode($proxy->call($sessionId, 'product.info', 111));
だから今、私はこの問題は私のコードであることを確信しています。 この部分を削除しても同じエラーが発生するので、問題(私は思う)は引数部分( - ><sku>%i</sku>
< - )です。
アイデア?
再生していただきありがとうございますが、私はこれを試してみましたが、動作しません。PHPでは文字列で動作しますが、SKU(SKU。 '')thatsにスペースを追加する必要があります。 idではない。 他の提案がある場合は教えてください。 –
@MalekRadhouani - SKUは、データ型が 'string'の各Productの一意の識別子です。ですから、そのような各SKUに ''(スペース)の接尾辞を追加する場合は、コードに別の問題があるはずです。私が何を意味しているかを理解していただければ幸いです –
はい、私は知っているが、私は他のフォーラムや他の人からこの解決策を得て、他の人は同じバージョンのmagento(1.6)で私と同じ問題を抱えている そしてmagento apiサイトで与えられたコードは、問題はmagentoのこのバージョンからです、私は、Magentoサイトでバグが宣言されている場合は検索し、そうでない場合はコードを検索し、解決策を提供します。 ありがとうございます。 –