English 中文(简体)
网上服务
原标题:iPhone UIImage upload to web service

今天,我工作了几个小时,我很接近解决办法,但显然需要有人帮助。 我试图把图像张贴到一个网上服务站。 我说,这部法律首先解释了我所尝试的一切:

NSData *imageData = UIImageJPEGRepresentation(barCodePic, .9);


NSString *soapMsg = 
[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/"><soap:Body><WriteImage xmlns="http://myserver/imagewebservice/"><ImgIn>%@</ImgIn></WriteImage></soap:Body></soap:Envelope>",  [NSData dataWithData:imageData]
 ];


NSURL *url = [NSURL URLWithString:@"http://myserver/imagewebservice/service1.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];

NSString *msgLength = 
[NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://myserver/imagewebservice/WriteImage" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];

conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
    webData = [[NSMutableData data] retain];
}    

首先,这部法律对除图像外的任何东西都做了罚款。 网络服务在我的地方网络上运行,我可以随意改变来源代码,如果我把“ImgIn”参数改为插图和通过插图,那么所有东西都会奏效,我就没有问题获得回报价值。 因此,根本不存在连接问题,我可以在这个服务器上从这个网络服务站打电话和获取数据,但没有任何问题。 但是,我需要通过ImgIn paraile将图像上载到这一网络服务,因此,到目前为止,上述代码是我最直射的。 我也做了验收反应,的确是收发的,的确是FailWith Error, 等等都在处理中。 每次都发生上述火力。 然而, 数据从未发射,它像网络服务公司本身一样从未运行。 当我对网络服务本身进行ug击时,当我使用直截了当的参数,但用图像参数,它甚至连我称之为网络时,就永远不会减弱。 它几乎像ImgIn参数那样长(在我向屏幕投射时,其巨大)和网络服务只是cho。 我在谈到在使用这种方法时必须编码到第64号基地,但我无法找到这样做的良好联系。 如果说我做错的话,那么,你能够就这样做的方法提供法典,而不仅仅是“你需要使用基地64”,我真心赞赏它,因为我可以找到一个例子来说明如何执行这一点。 除此以外,我还损失了几类,似乎像我这样做一切事。 请帮助!

增 编

最佳回答

之所以失败,是因为百分比“格式”的投机者将物体和电话(NSString*)作为说明。 - [NSData打字]回报,如@“<31 32 33 65 66 67>” for (ASCII)“123abc”, 因此,你重新提出和修改;31 32 33 65 66 67> 这显然是有效的XML。 聚在一起的 Don光(除别的外,还容易受到XML注射的伤害)。

我会放弃《SOAP》和公正使用

[req addValue:@"image/jpeg" forHTTPHeaderField:@"Content-Type"];
[req setHTTPBody:imgData]

如果你想要使用SOAP,那么很可能有一个目标-CSOAP图书馆,为你们包装。 如果无法做到这一点,你可以人工确定Xs:base64 缩略语(我想)和使用基64编码数据。 两者都不理想,因为它使数据达到33%。 如果你退约,一个SOAP图书馆将制作20000%

问题回答

暂无回答




相关问题
Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView) Everything displays fine The button simply takes a snapshot using the following simple ...

Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Transform rectangular image into trapezoid

In .NET how can I transform an image into a trapezoid. The Matrix class supports rotation, shear, etc, but I can t see a trapezoidal transformation. I m using the usual System.Drawing.* API, but I m ...

Rotate image through Y-axis on web page

What are my options for rotating an image on a web page through the Y-axis? I m not sure if I even have the terminology right. Is this called a rotate or a transform. Most of the searches that I ve ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it s colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it s "...

热门标签