First of all, WSLD2OBJC is too bloated to use
1) In general, SOAP itself is unsafe if the message is not encrypted. Given this SOAP body from someSOAPmethod , if you use the [WebMethod] attribute in .NET with SOAP v1.0:
POST /WebService/Common.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://example.com/someSOAPmethod" <?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> <SomeSOAPmethod xmlns=\"http://example.com/\"> <encryptedMessage>%@</encryptedMessage> //<-- this is vary, depends on your parameter </SomeSOAPmethod> </soap:Body> </soap:Envelope>
% @ must pass with encrypted data to protect SOAP. You can use any type of encryption, but I prefer AES . To provide even greater addition of HTTPS connection (RSA encryption).
2) Instead, you can use your own parsing using WSLD2OBJC. From the example of someSOAPmethod .
-(NSMutableURLRequest *)encapsulateSOAP:(NSString *)encryptedMessage withSoapMethod:(NSString *)soapMethod andBaseURL:(NSURL *)baseURL { NSString* soapMessage = [NSString stringWithFormat:@"<?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><%@ xmlns=\"http://example.com/\"><encryptedMessage>%@</encryptedMessage></%@></soap:Body></soap:Envelope>", soapMethod, encryptedMessage, soapMethod]; NSString* msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; NSMutableURLRequest* theRequest = [NSMutableURLRequest requestWithURL:baseURLl]; [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:[NSString stringWithFormat:@"%@%@", @"http://example.com/", soapMethod ] forHTTPHeaderField:@"SOAPAction"]; [theRequest setHTTPMethod:@"POST"]; [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; [theRequest setTimeoutInterval:10]; return theRequest; }
How to use the above method:
NSString *encryptedMessage = //some encrypted message NSString *soapMethod = @"someSOAPmethod"; NSURL *baseURL = [NSURL urlWithString:@"http://example.com"]; NSMutableURLRequest *requestQueue = [self encapsulateSOAPRequest:encryptedMessage withSoapMethod:soapMethod andBaseURL:baseURL]; //then request using AFNetworking, ASIHTTP or your own networking library
3) Yes, you can use NSXMLParse or any third-party library that you want to link to the SOAP request or cancel the SOAP response.
N sham
source share