简体   繁体   中英

Soap request with NSData and base64 encoding

I'm using a sudzc soap classes to communicate with a remote web service. Most of requests works but i'm experiencing problem trasferring data:

i've to send some data encoded in base64, i allocate a NsData object this way:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"little_amount_of_data" ofType:@"dat"];  
NSData* dummy = [NSData dataWithContentsOfFile:filePath];
[service sendAudioFile:self action:@selector(sendAudioFileHandler:) username: self.username password: self.password fileBytes: dummy numBytes: [dummy base64Encoding].length audioTimestamp: [NSString stringWithFormat:@"%0.f",[[NSDate date]timeIntervalSince1970]]];

The SOAP request looks right (data correctly encoded, right length) but i'm receiving this response from the server (iis7 i think, i don't have access to it):

Impossibile elaborare la richiesta. ---> Offset e lunghezza eccedono i limiti della matrice o il conteggio è maggiore del numero di elementi presenti dall'indice alla fine dell'insieme di origine.

translated:

Unable to process request. ---> Offset and length exceed the limits of the array or the count is greater than the number of items from the index at the end of the source.

if client sends a void base64 string (lenght=0), server replies with a success statement.

The WSDL describe the field as base64Binary I'm using NSData+Base64.h/NSData+Base64.m

Any hints? Is client or server fault?

solved, problem was on lenght. I was sending the lenght of the encoded file, the webservice wants the lenght of the original file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM