エンタープライズ アプリケーションでWSLD2OBJCを使用して、SOAP ベースのサービスを利用することを計画しています。しかし、wsdl2objc の最後の更新は 2010 年でした。
- wsdl2objcはエンタープライズ アプリで安全に使用できますか?
- 石鹸の解析に使用する信頼できるコンポーネントは他にありますか?
- または、必要に応じてプレーンな XML リクエストを使用でき
NSXMLParse
ますか?
エンタープライズ アプリケーションでWSLD2OBJCを使用して、SOAP ベースのサービスを利用することを計画しています。しかし、wsdl2objc の最後の更新は 2010 年でした。
NSXMLParse
ますか?何よりもまず、WSLD2OBJC が肥大化して使用できない
1) 一般に、メッセージが暗号化されていない場合、SOAP 自体は安全ではありません。SOAP v1.0 を使用して .NET で属性を使用する場合、 someSOAPmethodからのこの SOAP 本体を考慮します。[WebMethod]
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>
%@ は、SOAP を保護するために暗号化されたデータと共に渡す必要があります。どのタイプの暗号化も使用できますが、私はAESを好みます。さらに安全を確保するには、HTTPS 接続 (RSA 暗号化) を追加します。
2) WSLD2OBJC を使用する代わりに、独自の解析を構築できます。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;
}
上記の方法の使用方法:
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) はい、 NSXMLParse
SOAP 要求をバインドしたり、SOAP 応答をバインド解除したりするために、または任意のサードパーティ ライブラリを使用できます。