我正在从iPhone上的图像上传到C#web服务。下面是iPhone的代码缓冲区不能为空参数:缓冲区
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];
但是当我访问服务器我收到此错误信息。但是,当我直接复制并粘贴图像字符串在web服务中,我得到的图像。它只是从iPhone上抛出错误。
请帮
您是否试图通过使用例如HTTP请求来找出HTTP请求之间的差异?一个调试HTTP代理或一个HTTP嗅探器? –