0
Я написал фрагмент кода, который отправляет параметр в .Net soap web service. Проблема в том, что я могу отправлять параметры как статические, что означает, что значения параметров вставляются в сообщение с мылом. Я хочу заменить встроенные значения переменной или что-то еще. Каков хороший способ сделать это?xcode динамические параметры отправки в soap webservice
вот мой код
(IBAction)buttonClick:(id)sender {
recordResults = FALSE;
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"
"<PasswordCheck xmlns=\"http://tempuri.org/\">\n"
"<user>arif</user>" // ****I want to remove this static value
"<password>arif</password>" // ****I want to remove this static value
"</PasswordCheck>"
"</soap:Body>\n"
"</soap:Envelope>\n"];
NSLog(soapMessage);
_lbl_result.text = soapMessage;
NSURL *url = [NSURL URLWithString:@"http://192.168.1.57/service1.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/PasswordCheck" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
//[nameInput resignFirstResponder];
}