首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Buffer不能为空参数:Buffer

Buffer不能为空参数:Buffer
EN

Stack Overflow用户
提问于 2009-12-12 14:46:51
回答 2查看 4.7K关注 0票数 0

我正在处理一张从iphone上传到C#网络服务的图片。下面是iPhone代码

代码语言:javascript
复制
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/\">\n"
                       "<soap:Body>\n"
                       "<PutImage xmlns=\"http://tempuri.org/\">\n"
                       "<ImgInputString>%@</ImgInputString>\n"
                       "</PutImage>\n"
                       "</soap:Body>\n"
"</soap:Envelope>\n",imageString];

NSLog(soapMessage);
NSURL *url=[NSURL URLWithString:@"http://192.168.2.7/ImageWebService/Service1.asmx"];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMessage length]];

[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://tempuri.org/PutImage" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

但是当我访问服务器时,我收到了这个错误消息。但是,当我直接将图像字符串复制并粘贴到get服务中时,我得到了图像。它只是从iPhone中抛出了错误。

请帮帮忙

EN

回答 2

Stack Overflow用户

发布于 2009-12-13 07:45:24

我在这方面也遇到了问题,我相信是编码的问题,(特定于MS服务器?)这是我的建议。

代码语言:javascript
复制
 [theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
票数 0
EN

Stack Overflow用户

发布于 2009-12-13 09:49:39

我把这事解决了。我已经将我的服务器端输入更改为字符串(一个bas64字符串),但我访问的web服务不是更新后的web服务,而是以前的byte[]输入。因此,我将我的web服务的dll挂在inetpub/wwwroot/bin中,指向新更改的web服务.dll。现在它就像一个护身符一样起作用。

和NWCoder,您可以将字符串加密为base64编码,并将其作为字符串发送到您的c# web服务,然后将i转换为byte[]。这对我来说很顺利。任何方式都需要你的建议。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1892591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档