11 Replies - 403 Views - Last Post: 15 July 2014 - 10:11 AM

#1 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Properly Using an external API

Posted 07 July 2014 - 01:13 PM

Hi All,

I hope this question isn't too simple for you all, but I've found it difficult to find useful information with my mentor (google.com).


I'm diving into my first web project that requires the use of an external web service.

I have the xml schemas in hand, and all the goods.


Can someone direct me to a source that gives the overview of how to actually use the xml schemas? how to connect to the service, send requests, process responses?

Maybe I'm googling the wrong thing here, but I'm not finding this anywhere. It seems like this would be a fairly basic thing, but Maybe I'm way wrong about how I'm approaching this.



I'm making a travel booking site, and the hotel data, availability data, cart, booking, etc etc.. will all come through these API requests/responses.


I'm also interested to see what you all think is the best language to tackle something like this. You can compare other sites like the big boys expedia and whatnot.. but this will be a smaller site, that focuses basically on the Caribbean and particular resorts that we choose to add to the list of properties.


Thanks for the help, Much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Properly Using an external API

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,290
  • Joined: 12-June 08

Re: Properly Using an external API

Posted 07 July 2014 - 01:23 PM

So like this?

http://www.dreaminco...9432-simplexml/
Was This Post Helpful? 0
  • +
  • -

#3 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 07 July 2014 - 01:40 PM

Well, not really. I found the W3Schools XML "class" to be very informative, and the link you shared was very good as well.

I do understand the usage of the XML, in regard to loading and parsing the responses to get the information that I need. I am struggling to learn how to send the request to the external service.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,290
  • Joined: 12-June 08

Re: Properly Using an external API

Posted 07 July 2014 - 01:46 PM

Okay.. then the other is this one where it shows you how to create a basic API for distribution and then create a front end to call/consume the API response. You get to view it from both ends.

http://code.tutsplus...tion--net-23417
Was This Post Helpful? 1
  • +
  • -

#5 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 07 July 2014 - 01:54 PM

Thanks, that looks to be a good source. I'll start there. Thanks a ton!!

Hopefully that gets me going!! :)

Thanks again.
Was This Post Helpful? 0
  • +
  • -

#6 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 08 July 2014 - 05:31 AM

So, basically the idea is to build your xml, create a httpwebrequest (or whatever you can send to a url in any particular language)...


So, after seeing various api's, the one i'm dealing with here is not extremely complicated and probably a bit less expansive than most.

knowing that, would anyone be able to suggest a language to use? or is there more info that is needed to make that call?
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,290
  • Joined: 12-June 08

Re: Properly Using an external API

Posted 08 July 2014 - 07:01 AM

I would imagine any server side language would do.. php, ruby, python, perl, ASP.NET, etc.
Was This Post Helpful? 0
  • +
  • -

#8 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 08 July 2014 - 07:13 AM

View Postmodi123_1, on 08 July 2014 - 07:01 AM, said:

I would imagine any server side language would do.. php, ruby, python, perl, ASP.NET, etc.



So at this point it's really just a matter of personal preference.

Ok, good stuff.. here we go!!

Since I have a Unix server without mono, I'll probably not use asp.net that I was considering..

there seem to be decent php examples out there, so I'll probably start there..

Thanks again guys! That's what I needed, a good starting point!
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,290
  • Joined: 12-June 08

Re: Properly Using an external API

Posted 08 July 2014 - 07:23 AM

Happy coding!

Let us know how it goes!
Was This Post Helpful? 0
  • +
  • -

#10 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 08 July 2014 - 07:24 AM

Thanks! Will do. and by "happy" you must mean "frustrating + rewarding" LOL
Was This Post Helpful? 0
  • +
  • -

#11 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 15 July 2014 - 09:37 AM

I've hit a bit of a snag, and thought you guys may have a suggestion.

in my code I have an XMLrequestBuilder class for all of my xml requests.. each are Public Shared Functions so I can call them from anywhere.. they return a string including the entirity of the request including the soap headers.
            Dim oHttpReq As HttpWebRequest = DirectCast(WebRequest.CreateDefault(New Uri(ENVURL)), HttpWebRequest)
            oHttpReq.ContentType = "text/xml; charset=utf-8"
            oHttpReq.Method = "POST"
            oHttpReq.Accept = "text/xml; charset=utf-8"
            Dim oReqStream As New StreamWriter(oHttpReq.GetRequestStream(), Encoding.UTF8)   'UNABLE TO CONNECT HERE
            oReqStream.Write(XMLStr)  'XMLstr = entire xml string
            oReqStream.Flush()
            oReqStream.Close()


Facts:
0) the ENVURL = the asmx file for the web service.
1) when i debug and copy the text within the "" of the XMLStr variable, and send it via SOAPUI to the ENVURL, it works like a charm.
2) when I debug this and run it locally, I get a "can not connect to remote server" error on the StreamWriter line.
3) when i publish this to my server, i get a 500 error.

Any ideas?
Was This Post Helpful? 0
  • +
  • -

#12 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 07-July 14

Re: Properly Using an external API

Posted 15 July 2014 - 10:11 AM

OK, I've blown my own mind here.

Update: The errors persist UNLESS I am running Fiddler 2 to watch the traffic..
When running Fiddler2 all of my requests work JUST FINE..
but when I close Fiddler2, I go back to errors on all requests..

How strange is this?? i've tested this 10 times or more.. and it's true.. ???

what the hell is going on LOL

Ok.. Working this out in my head here..

could it be, that Fiddler2 provides an alternative "proxy" to the stated proxy in the browser setting?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1