Thanks for the help Mark. I was able to get the Google api working, so
I'm just posting in case anyone is interested:
I compiled the google wsdl into google.dll using your instructions.
Then in Powershell:
$k = [reflection.assembly]::loadfrom("c:\tools\googleapi\google.dll")
$s = new-object googlesearchservice
$r = new-object googlesearchresult
$r = $s.doGoogleSearch("##GOOGLE KEY##", $search_string, 0, 10,
$false, "", $false, "", "", "")
foreach ($result in $r.resultelements) {
write-host $result.title -foregroundcolor magenta
write-host $result.snippet
write-host $result.url -foregroundcolor gray
write-host
}
Or, if there is a proxy add in:
$proxy = new-object system.net.webproxy("##PROXY IP##",proxy port)
$proxy.usedefaultcredentials = $true
$s.proxy = $proxy
I never got the microsoft live search working, here's my code though:
[reflection.assembly]::loadfrom("c:\tools\msnsearch.dll")
$s = new-object msnsearchservice
$searchrequest = new-object searchrequest
[sourcerequest[]]$sr2 = new-object sourcerequest
$sr2[0].source = [sourcetype]::web
$searchrequest.query = "web services"
$searchrequest.requests = $sr2
$searchrequest.appid = "##appi##"
$searchresponse = new-object searchresponse
$searchresponse = $s.search($searchrequest)
But I always get:
Exception calling "Search" with "1" argument(s): "Client Error"
At line:1 char:28
+ $searchresponse = $s.search( <<<< $searchrequest)
I'm not so concerned with this since Google works, but if anyone has
any ideas please let me know.
thanks again.
On Oct 24, 6:56 pm, Mark [exmsft] <MarkInga...@nospam.nospam> wrote:
> Hello Matt,
>
> Here's one way to achive this; it assumes you have the .NET 2.0 SDK installed
> for the first step..
>
> 1. Using wsdl.exe (part of the .NET SDK), you can generate a c# or vb.net
> proxy class for calling the webservice. You need to know the name/location
> of the WSDL file that describes what methods the service provides. I'll
> be using the dictionary service provided athttp://services.aonaware.com/DictService/DictService.asmx.
>
> example:
>
> wsdl /out
ictService.cshttp://services.aonaware.com/DictService/DictService.asmx?WSDL
>
> 2. Using csc.exe, compile the source file into a library (dll) to use:
>
> csc /t:library DictService.cs
>
> 3. Load that library into PS (I do this in my profile):
>
> if ([System.IO.File]::Exists('c:\temp\DictService.dll')) {
> [Reflection.Assembly]::LoadFrom("c:\temp\DictService.dll")
>
> }(I check to see if the file exists because I use this profile on a few machines
> and not all of them have the dll available on them).
>
> 3a. (optional) Create a function (again, I do this in my profile) to call
> the method(s) on the webservice that you are interested in.
>
> $global
ict = new-object DictService
> function Def ($word)
> {
> $x = $Dict.Define($word)
> for ($i = 0; $i -lt $x.Definitions.Count; $i++) {
> write-host $x.Definitions[$i].Word
> write-host $x.Definitions[$i].WordDefinition
> }
> }
>
> If you already have the source code in c# or vb.net, you could just use csc.exe
> or vbc.exe (which can be found in $nev:windir\Microsoft.NET\Framework\v2.0.50727)
> to compile it and skip step #1.
>
> thanks,
> mark
>
> > Hi,
>
> > All the examples I've seen are where people download xml from a url:
> > like abishek's weather function:
>
> > $url="http://xml.weather.yahoo.com/forecastrss?p=10036"
> > $web = new-object system.net.webclient
> > $weather = [xml]$web.downloadstring($url)
> > These are relatively simple. But is it possible to access soap apis?
> > I'd like to access google or live search and those examples are only
> > provided for vb.net and c# usually.
>
> > If someone could point me in the right direction I'd appreciate it.