locked
HTTP Post to Web Service containing a file RRS feed

  • Question

  • User-1458727574 posted

    My understanding of web services is at best ok. In principle it is calling a function across the web to gain a service and get a response. I've had some awesome help from someone on this forum in getting the HTTP post containing XML to work, and it does. This might be a dumb question, but when doing a web service call and passing in XML in the body, is it possible to send the XML as a file rather than in the body? To me it doesn't make a great deal of sense doing it that way but the question has been asked today so I thought I'd post the query on here.

    Thursday, June 14, 2018 9:06 AM

Answers

  • User475983607 posted

    Speaking from my experience in business apps...

    My understanding of web services is at best ok. In principle it is calling a function across the web to gain a service and get a response.

    Services are real-time end points where strongly typed data is sent and received.  Usually the data is small like a record with details.

    but when doing a web service call and passing in XML in the body, is it possible to send the XML as a file rather than in the body?

    It is uncommon to pass files to a HTTP service.  Not because it a bad practice but its simply more work for both ends.  Usually files are passed using a protocol designed for transfering file like FTP, SFTP, FTPS, etc. if there is a failure then the process can continue where it left off.  Files generally have a lot of data are are handled in a batch process one both ends.

    As PatriceSC stated technically HTTP POSTing a file or HTTP POSTing xml data is pretty much the same except the HTTP format for passing files uses boundaries to to segment the files in the message body.

    I'm not sure why folks on the forum are passing large files via services.  IMHO, it seems like a very awkward and error prone approach but perhaps they have no other alternative. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 14, 2018 12:18 PM

All replies

  • User1120430333 posted

    Yes, you can upload a file to a Web service or upload a file on an HTTP Post to a Restful API. There are plenty of examples on how to do this using your friends Bing and Google.

    Thursday, June 14, 2018 10:14 AM
  • User-1458727574 posted

    Hahaa, I will check later.

    Thursday, June 14, 2018 10:15 AM
  • User753101303 posted

    Hi,

    You never really upload a "file". The file content is included as part of the body using a particular convention and it is exposed on the other side as a file content that has a name and that you can then save.

    It can be usefull if on the server side you want to process that the same way than a "manual" file upload.

    Edit: it could be best to ask the guy who askjed that what is his actual intent. Usually you try to use services in such as a way that the whole plumbing is done for you. For example you post an object on the clienr side and process an object on the server side. The serialization/deserialization could be done for you using json or xml at will etc... and you may not have to care at all about the XML level.

    Thursday, June 14, 2018 11:02 AM
  • User475983607 posted

    Speaking from my experience in business apps...

    My understanding of web services is at best ok. In principle it is calling a function across the web to gain a service and get a response.

    Services are real-time end points where strongly typed data is sent and received.  Usually the data is small like a record with details.

    but when doing a web service call and passing in XML in the body, is it possible to send the XML as a file rather than in the body?

    It is uncommon to pass files to a HTTP service.  Not because it a bad practice but its simply more work for both ends.  Usually files are passed using a protocol designed for transfering file like FTP, SFTP, FTPS, etc. if there is a failure then the process can continue where it left off.  Files generally have a lot of data are are handled in a batch process one both ends.

    As PatriceSC stated technically HTTP POSTing a file or HTTP POSTing xml data is pretty much the same except the HTTP format for passing files uses boundaries to to segment the files in the message body.

    I'm not sure why folks on the forum are passing large files via services.  IMHO, it seems like a very awkward and error prone approach but perhaps they have no other alternative. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 14, 2018 12:18 PM
  • User-1458727574 posted

    Once again, you are the voice of clarity. Had a meeting this morning to discuss this because certain people had one idea and I had mine. Seems that we will be posting in the normal way rather than a file upload method which I said when I was asked about this AM that it was not the way to do it.

    Thursday, June 14, 2018 1:27 PM