I am planning to use WSLD2OBJC in an enterprise application to consume SOAP based services. But last update for wsdl2objc was on 2010.
NSXMLParse
for my needs?First and foremost, WSLD2OBJC is too bloated to be used
1) In general, SOAP itself is not safe if the message is not encrypted. Considering this SOAP body from someSOAPmethod if you use attribute [WebMethod]
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>
the %@ must be pass with encryped data to secure SOAP. You can use whatever type of encryption but I prefer AES. To secure even more add HTTPS connection (RSA encryption).
2) You can built your own parsing instead using WSLD2OBJC. From 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 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 3rd-party library that you like to bind SOAP request or unbind SOAP response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With