I'm new on developing IOS using web service. Can anyone help me on how to create a request with array parameter in SOAP Web Service. In PHP I can create a request by doing this:
$params = array(
"authuserid" => "454",
"authpassword" => "");
$result = $client->call("EC_LOGON",$params);
please help me I'm having a hard time to find a good example how to apply that code in objective c programming.
The SOAP message with parameters should be as follows,
NSString *soapMessage = [NSString stringWithFormat:
@"<?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"
"<TestSoap xmlns=\"http://testsoap.com/\">\n"
"<parameterOne>%@</parameterOne >\n"
"<parameterTwo>%@</parameterTwo >\n"
"</TestSoap >\n"
"</soap:Body>\n"
"</soap:Envelope>\n", valueOne, valueTwo];
From your app's code, you can post an string by appending all the objects of an array one after each other and separate them by any special character (like *), now in your PHP code you can make array with the same logic.
You can convert array to string from below code:
NSString *stringToPass;
for (int i = 0; i < [yourArray count]; i++) {
if ([stringToPass length])
{
stringToPass = [stringToPass stringByAppendingFormat:@"*%@",[yourArray objectAtIndex:i]integerValue]]];
}
else
{
stringToPass = [NSString stringWithFormat:@"%@",[yourArray objectAtIndex:i]integerValue]]];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.