Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts

    save input to db then send to a web service and add response from web service to db

    I primarily work in an MS environment doing programming in VBScript or C# and have not done much with PHP. I have a client that will consume our web service to test their job applicants. This client is in a LAMP environment. They have a web person that does not know programming so I am trying to help her.

    As the title says they will be getting input that needs to be saved to the db, that part I can do. However, they then need to send the info to our servers as http post, where our server will process and respond, and then once they receive the response from our servers they need to save this information.

    So my question is in regard to sending the data and reading the response. Does anyone have a good tutorial on this? I found a lot of info on SOAP but our service is not a SOAP service I found some other info on cURL and they do have cURL support enabled on their server, they also have json support enabled

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,536
    Thanks
    80
    Thanked 4,490 Times in 4,454 Posts
    I think it depends on WHAT you are going to respond.

    If you are going to simply respond with "OK" or "Error: missing phone #" (or whatever failure message you will give), then I see no reason to do any more than a simple Response.Write and let there server that posted the query to your server receive one line of text and do a simple interpretation of that text.

    If you are going to respond with a large set of data, then yes, you will need some structured result sent. JSON makes tons of sense for many reasons.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Yes there is quite a bit of data being sent each way.

    Do you have any tutorials you could point me to on using JSON to send and accept the data?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,536
    Thanks
    80
    Thanked 4,490 Times in 4,454 Posts
    Well, PHP has builtin functions json_decode( ) and json_encode( ), so that side is pretty easy. You can just build up an object tree and then invoke json_encode() on it to have it ready to send. When you receive a JSON result, just use json_decode() on it to recreate the object tree it came from. Note that the outermost "object" *can* be an array, if desired/needed.

    As for the C# side of things, I've never done it but see here: Working with JSON Data
    Looks pretty simple, no?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Thanks Bill, I will search for the json stuff.

    Some background on my employer. We are a provider of pre-employment assessments. We created, validated and copyrighted the first job related assessment in America. Many companies around the globe use our assessments.

    This particular company is a franchisee of a restaurant chain and that restaurant already uses the system. The restaurant sent the franchisee copies of their code but it is in VB.NET and of course they couldn't get it to work since they are on Linux.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •