0
votes

I'm getting HTML content in below format.

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><

In the below code I'm getting 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];

}

}

I want the Output as aHR0cCUzYSUyZiUyZnNjaGVtYXMubWNk.

Any ideas? Thanks in advance.

1
Yesterday You Accepted the same Answer now what ? stackoverflow.com/questions/16566129/…Buntylm
<wsse:BinarySecurityToken wsu:Id=&quot;> it has some attribute,that also printing with the token.Can you please help me to remove that?Nagarajan Karthikeyan
Use my method nd call it using NSString *token = [self stringBetweenString:@"sse:BinarySecurityToken>" andString:@"</wsse:BinarySecurityToken>"];Buntylm
stringBetweenString is not working,anyway thanks a lot BuntyNagarajan Karthikeyan
What is all about is it working for you young man ?Buntylm

1 Answers

0
votes

As you discussing you have NSString *token = @"<wsse:BinarySecurityToken>aHR0cCUzYSUyZiUyZnNjaGVtYWd0Sjk0JTNk</wsse:BinarySecurityToken>"; and what the token between tags then you can replace the unwanted character like .

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

and then

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