hiii, i'm using wcf SOAP services for my app and i send the request like below.
postStr = [NSString stringWithFormat:@"<?xml version=\"1.0\"?>\n"
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<s:Body>\n"
"<InsUpdDelActivityInfo xmlns=\"http://tempuri.org/\">\n"
"<objEventsContent xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/iCampuslite.Model.ActivityStream\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
"<d4p1:ActCommentId i:nil=\"true\" />\n"
"<d4p1:ActSubTypeCd i:nil=\"true\" />\n"
"<d4p1:ActType>Status</d4p1:ActType>\n"
"<d4p1:ActTypeCd>1</d4p1:ActTypeCd>\n"
"<d4p1:ActivityAnswersList />\n"
"<d4p1:ActivityComments />\n"
"<d4p1:ActivityId i:nil=\"true\" />\n"
"<d4p1:ActivityLike />\n"
"<d4p1:ActivityName>%@</d4p1:ActivityName>\n"
"<d4p1:ActivityStreamImagesBytes>%@</d4p1:ActivityStreamImagesBytes>\n"
"<d4p1:AnswerDesc i:nil=\"true\" />\n"
"<d4p1:AnswerId>0</d4p1:AnswerId>\n"
"<d4p1:CommentDesc i:nil=\"true\" />\n"
"<d4p1:CommentId i:nil=\"true\" />\n"
"<d4p1:CreatedUserId>%@</d4p1:CreatedUserId>\n"
"<d4p1:CreatedUserName i:nil=\"true\" />\n"
"<d4p1:FileOrLinkName i:nil=\"true\" />\n"
"<d4p1:IsLiked>0</d4p1:IsLiked>\n"
"<d4p1:IsTotalSchool i:nil=\"true\" />\n"
"<d4p1:LikeCount>0</d4p1:LikeCount>\n"
"<d4p1:LinkImage i:nil=\"true\" />\n"
"<d4p1:ObjTypeCdId i:nil=\"true\" />\n"
"<d4p1:ObjTypeId i:nil=\"true\" />\n"
"<d4p1:OperationMode>I</d4p1:OperationMode>\n"
"<d4p1:OperationType i:nil=\"true\" />\n"
"<d4p1:OperationTypeId i:nil=\"true\" />\n"
"<d4p1:OrganizationId>%@</d4p1:OrganizationId>\n"
"<d4p1:OtherActivityId i:nil=\"true\" />\n"
"%@\n"
"</objEventsContent>\n"
"<ismobile>true</ismobile>\n"
"</InsUpdDelActivityInfo>\n"
"</s:Body>\n"
"</s:Envelope>", statusText, [appDelegateObj.loginUserInfoDict valueForKey:@"a:UserId"], [appDelegateObj.loginUserInfoDict valueForKey:@"a:OrgId"], workspaceStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@iCampusliteMobileService/ActivityStreamSl.svc", appDelegateObj.baseURL]]];
NSString *messageLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postStr length]];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"http://tempuri.org/IActivityStreamSl/InsUpdDelActivityInfo" forHTTPHeaderField:@"SOAPAction"];
[request addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postStr dataUsingEncoding:NSUTF8StringEncoding]];
NSError *error = nil;
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
in the above request there is an element ActivityStreamImagesBytes
which is base64binary
parameter i have to pass the image.
I've tried using many different formats.
here is wcf service screenshot
and here is the server side code
public string byteArrayToImage(byte[] byteArrayIn,string fileName)
{
if (byteArrayIn != null)
{
ActivityStreamSl.LogMsg("Byte Array Count : "+byteArrayIn.Length.ToString(), "D:\\log.txt");
var serverfile = "D:somepath\somepath\somefolder";
var getfile = HelperClass.Filesavehelper(Constants.UploadPaths.ActivityStream, "testfilename.png", serverfile);
FileStream file = new FileStream(getfile, FileMode.Create);
file.Write(byteArrayIn, 0, byteArrayIn.Length);
file.Close();
file.Dispose();
return getfile;
}
else
{
ActivityStreamSl.LogMsg("Byte array is null","D:\\log.txt");
}
return "";
}
the server is expecting a byte array and i dont know how to send it?
And i dont know what a base64binary data type is?
Do I have to send the base64 encoded string or byte array or just data of image from NSData *data = UIImageJPEGRepresentation([UIImage imageNamed:@"popular.png"], 0.7);
Any help is appreciable