Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9370

Re: Web Service Calls

From "Albert D. Kallal" <PleaseNOSpamkallal@msn.com>
Newsgroups comp.databases.ms-access
References <66c36ddc-c8fd-4d16-a629-168e2d61a47a@googlegroups.com>
Subject Re: Web Service Calls
Message-ID <MRccv.25636$6A3.9155@fx29.iad> (permalink)
Date 2014-05-12 17:32 -0600

Show all headers | View raw


"musicloverlch"  wrote in message 
news:66c36ddc-c8fd-4d16-a629-168e2d61a47a@googlegroups.com...

>Has anyone every used Access to perform web service calls?  Are there any 
>write-ups on the web I could read somewhere to get a feel for how it works?
>
>Thanks,
>Laura

Back in Access 2003 there was a web services add in for Access (the SOAP 
toolkit). Sadly few used the tool and even worse the add in is not avaialble 
for later editions.

So there are two approaches I recommed.

for a "simple" or easy web service then I use the MSXML lbirary.  the reason 
for this choice is the MSXML library is installed on near all mahcines since 
the web browser uses that library.

So a web service call can look like this:

Public Sub GetQuote2()

   Dim objXML           As Object
   Dim strSymbol        As String
   Dim strURL           As String
   Dim strWFormat       As String

   Set objXML = CreateObject("MSXML2.XMLHTTP")

   strURL = "http://ca.finance.yahoo.com/d/quotes.csv?s="
   strWFormat = "&f=sl1d1t1c1ohgv&e=.csv"

   strSymbol = "MSFT"

   objXML.Open "GET", strURL & strSymbol & strWFormat, False
   objXML.Send

   Debug.Print "Symbol = " & Split(objXML.ResponseText, ",")(0)
   Debug.Print "Trade  = " & Split(objXML.ResponseText, ",")(1)
   Debug.Print "Date   = " & Split(objXML.ResponseText, ",")(2)

End Sub

So if the web service only has a "few" methods, then MSXML is a great choice 
(and means you don't have to install any additional software).

The down side is you need to correctly format the XML by hand. Most web 
services definitions (WSDL) will provide the correct get/put headers and 
thus you only need to get confortable using the MSXML library (you need/want 
to get confortable pulling out "node" data with the //select statement. 
Again, a learning curve here, but the efforts are well worth it.

Here is some smale use of MSXML
http://www.sitepoint.com/microsoft-developers-1/

However, "if" you have Visual Studio and vb.net skills, then it is a real 
breeze to use Visual Studio to create a "COM" object that can be consumed by 
Access. visual studio can (and will) generate a class object for you with 
all of the properties + methods of the web service for you. So you don't 
mess around with XML.

Remember a web service is "similar" in concept of when using VBA and you set 
a reference to Excel or Word. When you do this, then the "features" (the 
properties and methods) of the Word object are now available in Access VBA.

When you set a reference to a "web service" in Visual Studio then the effect 
is very similar to that of using COM objects in Access. So now all of those 
"features" of the web site are available in your code editor.  Thus this 
this ability, you then create a class object and compile it down to a "COM" 
object.

This object can then be "referenced" from Access in the VBA editor and you 
off to the races.

The downside of this approach is two fold:
You Access application and distribution becomes complex since now you must 
distribute that .net COM object and register it on each machine for Access 
to use.
You have to Adopt Visual Studio and a whole new additional development 
platform.

Visual Studio is not a small platform and adopting this "just" this one 
issue is much overkill. However ASSUMING one has Visual Studio Skills, then 
this approach is a a breeze.

Best regards,

-- 
Albert D. Kallal  (Access MVP)
Edmonton, Alberta Canada
PleaseNoSpam_kallal@msn.com 

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Web Service Calls musicloverlch <lhowey@gmail.com> - 2014-05-06 14:15 -0700
  Re: Web Service Calls "Albert D. Kallal" <PleaseNOSpamkallal@msn.com> - 2014-05-12 17:32 -0600
    Re: Web Service Calls musicloverlch <lhowey@gmail.com> - 2014-05-15 07:12 -0700

csiph-web