Reputation:
i am using SOAP services to get the data from the servrer to my ios app. now i need to upload some data from the app to server.how can i do it from the SOAP message. here is my SOAP service.
POST /NoteService.asmx HTTP/1.1
Host: ios.myurl.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.myurl.com/CreateNoteUsingXMl"
<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<CreateNoteUsingXMl xmlns="http://www.myurl.com">
<AccountID>string</AccountID>
<Username>string</Username>
<Mypass>string</Mypass>
<NoteXML>string</NoteXML>
<isSign>int</isSign>
<noteID>long</noteID>
</CreateNoteUsingXMl>
</soap:Body>
</soap:Envelope>
How can i pass accountid,username etc. parameter in POST.
Upvotes: 0
Views: 1241
Reputation: 14477
This is easy create an NSString
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"
"<CreateNoteUsingXMl xmlns="http://www.myurl.com">\n"
" <Username>%@</Username>\n"
"<Mypass>%@</Mypass>\n"
"<NoteXML>%@</NoteXML>\n"
"</CreateNoteUsingXMl>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"
,username
, mypassword
, notexml
];
Now create NSURL
NSURL *url = [NSURL URLWithString:@"What Ever"];
Create NSMutableURLRequest
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]
Do rest of things you want ...
Upvotes: 1