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
  1. Home
  2. General Programming
  3. WCF and WF
  4. Need Some feedback on WCF

Need Some feedback on WCF

Scheduled Pinned Locked Moved WCF and WF
databasecsharpiossql-serverwcf
16 Posts 4 Posters 48 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jschell

    Software2007 wrote:

    Stream Image file as seperate methods at the moment. I

    Since you already know how to do that then why not just stream everything? So instead of trying to create additional input idioms just create a message with all of the data and then stream that. You could even use JSON to serialize the message and thus stream that.

    S Offline
    S Offline
    Software2007
    wrote on last edited by
    #4

    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.

    J 1 Reply Last reply
    0
    • 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.

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #5

      Stream is a reader that you can implement. So the stream can send anything. So 1. You have object X which includes a stream. 2. You create reader B which is a stream. 3. When B is 'read' it sends the normal properties first then it 'sends' the included stream by reading it.

      S 1 Reply Last reply
      0
      • J jschell

        Stream is a reader that you can implement. So the stream can send anything. So 1. You have object X which includes a stream. 2. You create reader B which is a stream. 3. When B is 'read' it sends the normal properties first then it 'sends' the included stream by reading it.

        S Offline
        S Offline
        Software2007
        wrote on last edited by
        #6

        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/

        J 1 Reply Last reply
        0
        • 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/

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #7

          At this point concentrate on creating a class that is suitable for delivering bytes and only bytes. It will have nothing to do with WCF nor JSON. As a suggestion look a System.IO.Stream. Derive a class from that. Override all methods that are appropriate so you can read/write a test class a binary data. Once you get that general concept down then look at BinaryReader and BinaryWriter. And look to WCF to see exactly what Stream class it expects. That will be your target implementation.

          S 1 Reply Last reply
          0
          • J jschell

            At this point concentrate on creating a class that is suitable for delivering bytes and only bytes. It will have nothing to do with WCF nor JSON. As a suggestion look a System.IO.Stream. Derive a class from that. Override all methods that are appropriate so you can read/write a test class a binary data. Once you get that general concept down then look at BinaryReader and BinaryWriter. And look to WCF to see exactly what Stream class it expects. That will be your target implementation.

            S Offline
            S Offline
            Software2007
            wrote on last edited by
            #8

            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!

            J 1 Reply Last reply
            0
            • 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!

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #9

              Software2007 wrote:

              what is the normal way of doing this,

              The normal way for WCF doesn't involve streams.

              S U 2 Replies Last reply
              0
              • J jschell

                Software2007 wrote:

                what is the normal way of doing this,

                The normal way for WCF doesn't involve streams.

                S Offline
                S Offline
                Software2007
                wrote on last edited by
                #10

                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?

                J 1 Reply Last reply
                0
                • 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?

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #11

                  Focus on your goal and ignore the details. Find a solution that works and implement it. Don't worry about whether it is "normal" or not.

                  S 1 Reply Last reply
                  0
                  • J jschell

                    Focus on your goal and ignore the details. Find a solution that works and implement it. Don't worry about whether it is "normal" or not.

                    S Offline
                    S Offline
                    Software2007
                    wrote on last edited by
                    #12

                    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
                    
                    J 1 Reply Last reply
                    0
                    • 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
                      
                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #13

                      Http 'chunks' requests over certain limits which means it breaks it into pieces. I suspect you need to do something slightly different in your WCF code to get around that.

                      S 2 Replies Last reply
                      0
                      • J jschell

                        Http 'chunks' requests over certain limits which means it breaks it into pieces. I suspect you need to do something slightly different in your WCF code to get around that.

                        S Offline
                        S Offline
                        Software2007
                        wrote on last edited by
                        #14

                        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?

                        1 Reply Last reply
                        0
                        • J jschell

                          Http 'chunks' requests over certain limits which means it breaks it into pieces. I suspect you need to do something slightly different in your WCF code to get around that.

                          S Offline
                          S Offline
                          Software2007
                          wrote on last edited by
                          #15

                          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.

                          1 Reply Last reply
                          0
                          • J jschell

                            Software2007 wrote:

                            what is the normal way of doing this,

                            The normal way for WCF doesn't involve streams.

                            U Offline
                            U Offline
                            User 8292432
                            wrote on last edited by
                            #16

                            WCF Is Windows comunication

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

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