【发布时间】:2014-10-16 08:53:08
【问题描述】:
如何在 magenta api 中使用“customerCustomerCreate”将数组发送到soap xml,我将以下soap 消息发送到magento api:-
这是我的目标 c 代码:
NSString *soapMessage = [NSString stringWithFormat:@"<?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:customerCustomerCreate> \
<sessionId xsi:type=\"xsd:string\">%@</sessionId> \
<customerData xsi:type=\"xsd:string\">%@</customerData> \
</ns1:customerCustomerCreate> \
</SOAP-ENV:Body> \
</SOAP-ENV:Envelope>",sessionId,newCustomerArray];
NSURL *url = [NSURL URLWithString:@"http://www.modavive.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:@"urn:Mage_Api_Model_Server_V2_HandlerAction/customerCustomerCreate" 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){
webData = [NSMutableData data];
}
else
NSLog(@"theConnection is null");
这是我的数组:-
(
{
customerCustomerEntityToCreate = {
email = "test@gmail.com";
firstname = John;
gender = 1;
"group_id" = 1;
lastname = joe;
password = 1234;
"store_id" = 1;
"website_id" = 1;
};
}
)
并得到以下错误:-
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>100</faultcode><faultstring>Customer email is required</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
我用谷歌搜索了很多,但仍然没有得到任何解决方案,请帮助我。
提前致谢
【问题讨论】:
-
到目前为止有什么解决方案吗?
标签: ios objective-c magento soap