Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Software2007

@Software2007
About
Posts
216
Topics
82
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Need Some feedback on WCF
    S Software2007

    Found it. It's my mistake, I have my WCF hosted in localhost IIS7.5, but The changes I applied to my web.config in my project were not translated to the web.config that is being consumed under IIS7.5. Thanks for the help and for hanging in with my many posts. You did steer me to the correct solution by inheriting a custom stream object to handle images and file uploads within one request, but I might rethink this approach, and stick with the 'more standard' REST approach of one stream parameter, even though this may require multiple http requests to achieve the same thing - depending on performance. But, I know both ways and I can use either. Thanks again.

    WCF and WF database csharp ios sql-server wcf

  • Need Some feedback on WCF
    S Software2007

    I would, but it doesn't even invoke the web method. I tried it with the standard one parameter Stream method as well. I see people with same problem, some at 65K, others with 2G limit, but no good answers. I think this may be a REST restriction. It looks as if my web.config may be ignored, do you know how can I make sure it is being read?

    WCF and WF database csharp ios sql-server wcf

  • Need Some feedback on WCF
    S Software2007

    Ok, got it to where I read the stream, parse it and extract text and images from it. I do have a new problem, the binary data request sent from the iPhone is posted as the body of http post request. Everything works fine as long as the request doesn't exceed 65535 bytes. When it does exceed, the Wcf method doesn't even get called or invoked at all. I am not sure to where the problem might be. Here is my web.config

     //made this # bigger, didn't work
    
    WCF and WF database csharp ios sql-server wcf

  • Problem with Writing FileStream
    S Software2007

    Thanks. I will look into it.

    C# css help question

  • Problem with Writing FileStream
    S Software2007

    This line was the problem, byte[] byteArray = new byte[10000]; I chose a randomly bigger number 20,000 and it works. But, it still doesn't make lot of sense to me. The bytesread for the image data alone is 5430. So, with extra 17 bytes string, I would think the 10000 would be still big enough? Is there a way to know how much to allocate instead of just guessing a large number? Stream.length seems to be problematic for me. Remember, this is a network stream that I don't know the size of containing image data.

    C# css help question

  • Problem with Writing FileStream
    S Software2007

    Yes, it same exact image being generated, its sitting in my project folder. I tried dealing with static numbers to debug it easier. From iphone:

    NSData *strData = ["name=tony&image=" datausingencoding:NSFTU8StringEncoding]
    NSData *imageData = NSDATA(myImage)....raw binary representation of an image.....
    [body appendData:strData];
    [body appendData:imageData];
    [request setHTTP body]

    The WCF code in my original post works for any string <= 16 chars. If add an extra charcter and make it 17 chars "

    "name=tony1&image="

    , it stops working (of course I change the offset when I do that by one. Something is special aboutt he 16 char length here, may be it has to do with Encoding or something.

    C# css help question

  • Problem with Writing FileStream
    S Software2007

    Luc: The image doesn't open up on disk, meaning I can't view the image. I have split the stream based on '&'. The bytes array apparently is full of them when it comes to image raw binary data. So, I decided to parse the string to the left of "image=". This is not where the problem is, the problem is after parsing, for the remaining image bytes, why can't I open the image correctly if the preceding string happens to be more than 16 chars long? The code above is only psuedo code, in reality this will be much longer string.

    C# css help question

  • Problem with Writing FileStream
    S Software2007

    I have a stream object coming from mobile client in binary fromat as follows

    name=tony&image=....raw binary representation of an image.....

    I would like to extract the image out of the stream. I can extract the image and show it fine as long as string size preceding the binary image data is 16 chars or less! ("name=tony&image=") is 16 chars long

    bool PostData(Stream stream)
    {
    using (FileStream filetoUpload = new FileStream(filePath + "ImageFromBytes.jpg", FileMode.Create))
    {
    byte[] byteArray = new byte[10000];
    int bytesRead = 0;
    bytesRead = stream.Read(byteArray, 0, byteArray.Length);

    //write image data, ignore the preceding string
    if (bytesRead > 0)
    filetoUpload.Write(byteArray, 16, bytesRead-16);
    ....
    }
    }

    If I do("name=randy&image=") = 17 chars long, it doesn't work, the image shows the right size, but can't be opened.

    name=randy&image=....raw binary representation of an image.....

    filetoUpload.Write(byteArray, 17, bytesRead-17);

    Any ideas what in the world is going on?

    C# css help question

  • Need Some feedback on WCF
    S Software2007

    Well, What is normal to send streams? The goal is to send data from iphone to SQL database on some windows server including files, images and other primitive types. Should I be thinking sockets as opposed to WCF? When I googled such thing, everything seemed to point to webservices, I realized that classic webservice doesn't work well with JSON. So, I tried WCF, only to find out it accepts one Stream parameter! So, let me ask this: Basically I want to send some parameters mostly strings, couple of images, txt file, and audio file from iphone app to SQL database. I would like to send one http post request with all that, but how much of performance hit would it be if I do 3 or 4 http requests as in post parameters, then post image, then post file since WCF is built to handle one Stream parameter at a time?

    WCF and WF database csharp ios sql-server wcf

  • How to read bytes from Stream into Objects?
    S Software2007

    Can you elaborate a bit. So, I have a stream

    "firstname=Mike&lastname=Smith&..binary represenation for the image here.."

    in binary format.

    [Serializable]
    public class Employee {
    Serialize()..
    Deserialize()..
    }

    This sounds like I need a file for the serialization, but I thought this was memory data type of thing. Anyways, what after this, how do I read it in to the class members what I don't get? How do I go from Stream type which is sent to me to Employee? Note, stream comes from iphone app.

    C# mobile data-structures json tutorial question

  • How to read bytes from Stream into Objects?
    S Software2007

    OriginalGriff is correct that the image section is raw binary. So, what to do again?

    C# mobile data-structures json tutorial question

  • How to read bytes from Stream into Objects?
    S Software2007

    I am sending data from mobile app to REST in binary format like this:

    "firstname=Mike&lastname=Smith&..binary represenation for the image here.."

    class Employee{
    string firstname;
    string lastname;
    Stream photo;
    }

    public string PostMethod(Stream streamObj)
    {
    using (FileStream filetoUpload = new FileStream(filePath + filename, FileMode.Create))
    {
    byte[] byteArray = new byte[10000];
    int bytesRead = 0;

               do
               {
                   bytesRead = streamObj.Read(byteArray, 0, byteArray.Length);
                   if (bytesRead > 0)
                   {
                       filetoUpload.Write(byteArray, 0, bytesRead);
                   }
               }
    
               while (bytesRead > 0);
           }
    
           return "Uploaded " + filePath + filename;
       }
    

    I do know how to get the contents of the Stream into a byte array. What do I need to do to be able to read the bytes from the StreamObj into the class? Some pseudo code would be helpful. employee.firstname = ... employee.lastname=... employee.photo=....

    C# mobile data-structures json tutorial question

  • Need Some feedback on WCF
    S Software2007

    Great. I will do that. I was just wondering what is the normal way of doing this, I would think this is common thing to be sending objects like this between mobile apps and WCF. Are there more user friendly technologies, I am willing to use the appropriate thing whenever necessary!

    WCF and WF database csharp ios sql-server wcf

  • Need Some feedback on WCF
    S Software2007

    I am sorry, I can't follow. Could you comment based on the following psuedo code? for Image: (Stream mode transfer)

    from iphone: I send the image in bytes posted to the body of HTTP request.
    On WCF: void Upload(Stream imageData)
    {
    //Open the stream, turn into bytes and form the image
    }

    For ObjSomething:{string first, string last, int ID}

    In iPhone: I build a Dictionary with the object structure, attach it HTTP Request Posbody as JSON object.

    In WCF: void postData(ObjectSomething obj)
    {
    obj.first =
    obj.last =
    ...
    }

    The above works fine. Now, I need to send ObjX{string first, string last, Stream imageData} Did you mean I could do this?

    iphone: Somehow attach Json and image data to request?
    AND

    WCF: void PostObjectX(ObjX obj)
    {
    first=obj.first, last=obj.last,...
    Stream stm = obj.ImageData;
    }

    See the respons in this link, suggests that only the Stream can be in the body and other parameters may go in the heading. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/30557078-6499-42d5-8847-cad584ceb4dc/

    WCF and WF database csharp ios sql-server wcf

  • Need Some feedback on WCF
    S Software2007

    Well, I am still confused. This is the kinda of the object I would like to send over from iOS to WCF eventually.

    ObjectToSend{
    string firstname;
    string lastname;
    int ID;
    string Notes
    Stream Image;
    Stream AudioFile;
    Stream textfile;
    etc...
    }

    • Will I able able to send an object like this where it does have Stream datatype members?

    Right now, I am able to send JSON objects like this one because its easy to represent it as JSON
    ObjectToSend{
    string firstname;
    string lastname;
    int ID;
    string Notes
    }

    And I can upload image using stream mode as
    void uploadImage(Stream image).

    I am just not quite sure if and how I can have the Stream as member of an object, when WCF allows only Single Stream input/output parameter. I feel like there is a way, I just can't wrap my head around it.

    WCF and WF database csharp ios sql-server wcf

  • Need some general feedback on my WCF
    S Software2007

    I posted this on WCF. How do I remove this out of here?

    C# database csharp ios sql-server wcf

  • Need Some feedback on WCF
    S Software2007

    I am in the the process of building an iphone app that would access MSSQL database through a RESTful WCF. At the heart of my iphone app, customer will plug their info, take a pic, maybe audio file and small txt file along with some other simple info to update database. I was thinking, I would bundle all that up in some object and post it via HTTP into WCF, which then updates the db. I have some doubts about this as WCF expects One Stream parameter, and nothing else along in same method, So Stream parameter can't be part of the object. I would like to deal with JSON. Does anyone have an idea of what's the best way to do this? Note, I am able to post txt file, Stream Image file as seperate methods at the moment. I am hoping to bundle that up and make one post request to get that done. Thanks

    WCF and WF database csharp ios sql-server wcf

  • Need some general feedback on my WCF
    S Software2007

    I am in the the process of building an iphone app that would access MSSQL database through a RESTful WCF. At the heart of my iphone app, customer will plug their info, take a pic, maybe audio file and small txt file along with some other simple info to update database. I was thinking, I would bundle all that up in some object and post it via HTTP into WCF, which then updates the db. I have some doubts about this as WCF expects One Stream parameter, and nothing else along in same method, So Stream parameter can't be part of the object. I would like to deal with JSON. Does anyone have an idea of what's the best way to do this? Note, I am able to post txt file, Stream Image file as seperate methods at the moment. I am hoping to bundle that up and make one post request to get that done. Thanks

    C# database csharp ios sql-server wcf

  • Hwo to post an image to RESTful WCF via WebClient.
    S Software2007

    I have been wrestling with this for 2 days.:mad: I would like to post a very simple and small 5KB image "myImage.jpg" through my WCF service. I keep getting this error:"The remote server returned an error: (400) Bad Request". I know the problem is with this one method only as all other methods in my service work just fine. This method has a Stream parameter. //Service Code

    //Upload Image
    [OperationContract]
    [WebInvoke(Method = "POST",
    BodyStyle = WebMessageBodyStyle.Bare,
    UriTemplate = "json/UploadImage")]
    void UploadImage(Stream stream);

    void UploadImage(Stream data)
    {
    //Can't seem to get Here Ever!
    }

    //Web.Config

    //Client Code

    //Image file
    WebClient wc = new WebClient();
    // wc.Headers.Add("Content-Type", "octet-stream");
    byte[] rtn = wc.UploadData("http://localhost:2987/GetEmployees.svc/json/Upload", "POST", File.ReadAllBytes("myImage.jpg"));
    Console.WriteLine(System.Text.Encoding.ASCII.GetString(rtn));

    C# help csharp wcf sysadmin json

  • Upload image to WCF
    S Software2007

    I am having trouble uploading simple image to WCF. I would like to get to it from iOS, but I think my WCF isn't correct. The other methods I have in in my contract work fine, just this one that have to do with the Stream parameter. Can anyone see if there is anything wrong in web.config that would prevent me from uploading into the service?

    [ServiceContract]
    public interface IGetEmployees
    {
    // ....

        //Insert Image
        \[OperationContract\]
        \[WebInvoke(Method = "POST",UriTemplate = "json/UploadImage")\]
        void UploadImage(Stream data);
    

    }

    public void UploadImage(Stream stream)
    {
    //Implement here - stream is always null??????
    }

    WCF and WF csharp ios wcf json question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups