Ios 如何使用objective c和webservice返回字节数组下载文件

Ios 如何使用objective c和webservice返回字节数组下载文件,ios,iphone,objective-c,bytearray,file-transfer,Ios,Iphone,Objective C,Bytearray,File Transfer,我有一个iPhone应用程序。在登录视图中,我将用户名和密码发送到ASP.NET Web服务,Web服务返回JSON。如果用户成功登录,我可以从webservice调用另一个方法,您可以在下面看到: [WebMethod] public Byte[] GetDocument(string DocumentName) { string strdocPath; strdocPath = "path" + DocumentName; FileStream objfilestr

我有一个iPhone应用程序。在登录视图中,我将用户名和密码发送到ASP.NET Web服务,Web服务返回JSON。如果用户成功登录,我可以从webservice调用另一个方法,您可以在下面看到:

[WebMethod]
public Byte[] GetDocument(string DocumentName)
{
    string strdocPath;
    strdocPath = "path" + DocumentName;

    FileStream objfilestream = new FileStream(strdocPath,FileMode.Open,FileAccess.Read);
    int len = (int)objfilestream.Length;            
    Byte[] documentcontents  = new Byte[len];
    objfilestream.Read(documentcontents,0,len);
    objfilestream.Close();

    return documentcontents;    
} 
现在我的问题是:如何从iPhone应用程序调用此方法并将其保存到documents目录中,作为
.sqlite
.db
文件

NSOutputStream *fileOutputStream;
NSString *databasePath = [NSString stringWithFormat:@"%@/Documents/%@",NSHomeDirectory(),@"database.sqlite"];
    fileOutputStream = nil;
    fileOutputStream = [[NSOutputStream alloc] initToFileAtPath:databasePath append:NO];
    [fileOutputStream open];


- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{

   int bytesWritten  = [fileOutputStream write:[data bytes] maxLength:[data length]];
    NSLog(@" %s bytesWritten == %d  error == %@",__FUNCTION__,bytesWritten,[fileOutputStream streamError]);
}

但是如何调用我的web服务例如,服务路径是http://test.com/myservice.asmx,它获取字符串参数。如何从ios调用它?字符串参数表示文件下载url,例如: