0

以下の形式で HTML コンテンツを取得しています。

wsse:BinarySecurityToken wsu:Id="uuid:07747f2a-4be4-48fa-9654-5e12235f6040" ValueType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
aHR0cCUzYSUyZiUyZnNjaGVtYXMubWNk</wsse:BinarySecurityToken><

以下のコードでは、wsu:Id="uuid:07747f2a-4be4-48fa-9654-5e12235f6040" ValueType=" http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-を取得しています。 1.0 " ; EncodingType=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary " ; xmlns:wsu=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd " ; xmlns:wsse=" http://docs.oasis- open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd " ;> aHR0cCUzYSUyZiUyZnNjaGVtYXMubWNk

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if(_data)
{
    NSString* content = [[NSString alloc] initWithData:_data
                                              encoding:NSUTF8StringEncoding];
    NSLog(@"Content  :%@",content);

    NSRange divRange = [content rangeOfString:@"wsse:BinarySecurityToken" options:NSCaseInsensitiveSearch];

    if (divRange.location != NSNotFound)
    {
        NSRange endDivRange;

        endDivRange.location = divRange.length + divRange.location;
        endDivRange.length   = [content length] - endDivRange.location;
        endDivRange = [content rangeOfString:@"=<" options:NSCaseInsensitiveSearch range:endDivRange];

        if (endDivRange.location != NSNotFound)
        {
            divRange.location += divRange.length;
            divRange.length  = endDivRange.location - divRange.location;


            NSLog(@"BinarySecurityToken : %@",[content substringWithRange:divRange]);
        }
    }

    [webView loadHTMLString:content baseURL:_url];

}

}

出力をaHR0cCUzYSUyZiUyZnNjaGVtYXMubWNkとして欲しい。

何か案は?前もって感謝します。

4

1 に答える 1

0

あなたが持っNSString *token = @"<wsse:BinarySecurityToken>aHR0cCUzYSUyZiUyZnNjaGVtYWd0Sjk0JTNk</wsse:BinarySecurityToken>"; ているものとタグ間のトークンについて話し合うとき、不要な文字を のように置き換えることができます。

NSString *str = [token stringByReplacingOccurrencesOfString:@"<wsse:BinarySecurityToken>" withString:@""];;

その後

NSString *correctToken = [str stringByReplacingOccurrencesOfString:@"</wsse:BinarySecurityToken>" withString:@""];;

于 2013-05-16T06:40:05.440 に答える