Przede wszystkim WSLD2OBJC jest zbyt nadęty być stosowane
1) W ogóle, sama SOAP nie jest bezpieczne, jeśli wiadomość nie jest szyfrowana. Biorąc pod uwagę to ciało SOAP z someSOAPmethod jeśli używasz atrybut [WebMethod]
w .NET z 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>
gdy% @ musi przekazać dane Zakodowane zabezpieczyć mydłem. Możesz użyć dowolnego rodzaju szyfrowania, ale wolę AES. Aby jeszcze bardziej zabezpieczyć, dodaj połączenie HTTPS (szyfrowanie RSA).
2) Można zbudować własne przetwarzanie zamiast używania WSLD2OBJC. Na przykład z 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;
}
Jak korzystać powyżej metody:
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) Tak, można użyć NSXMLParse
lub dowolną bibliotekę 3rd firmy, który chcesz powiązać żądania SOAP lub rozpiąć odpowiedź SOAP.
Czy zamierzasz używać .NET, PHP lub ruby w backend? Dlaczego chcesz używać SOAP zamiast REST? –
koniec jest w .NET. –