O2 Script: Using Reflection to Invoke Bing Search Web Service
These script makes extensive use of O2′s reflection APIs to dynamically consume and invoke an WSDL.
var wsdlToLoad = @"http://www.webservicex.net/globalweather.asmx?WSDL";
var wsdlAssembly = new DotNet_SDK_WSDL().wsdl_CreateAssembly(wsdlToLoad);
var wsdlMethods = wsdlAssembly.webService_SoapMethods();
var getCitiesByCountry = assembly.type("GlobalWeather").method("GetCitiesByCountry") ;
//.method("GetCitiesByCountry"); var globalWeather = assembly.type("GlobalWeather").ctor();
return globalWeather.invoke("GetCitiesByCountry", "Portugal");
//return globalWeather.invoke("GetWeather", "Lisboa", "Portugal");
//O2File:DotNet_SDK_WSDL.cs
//using O2.XRules.Database.Languages_and_Frameworks.DotNet
Here is Bing’s search API:
var wsdlToLoad = "http://api.search.live.net/search.wsdl";
var assembly = new DotNet_SDK_WSDL().wsdl_CreateAssembly(wsdlToLoad); //cache the created assembly to make it faster
//var assembly = @"C:\Users\o2\AppData\Local\Temp\f3kx9cxv.dll".assembly();
var searchBingFor = "OWASP";
var currentType = "BingService";
var currentMethod = "Search";
var AppID = @"C:\O2\_USERDATA\accounts.xml".credential("Bing_API").password();
var searchRequest = assembly.type("SearchRequest").ctor();
searchRequest.property("Query", searchBingFor);
searchRequest.property("AppId", AppID);
var sourceType = assembly.type("SourceType");
var webEnum = sourceType.enumValue("Web");
var sources = sourceType.createArray(webEnum);
var methodParameters = assembly.type(currentType).method(currentMethod).create_LiveObject_From_MethodInfo_Parameters();
searchRequest.property("Sources", sources);
methodParameters.property("parameters",searchRequest);
var response = assembly.type(currentType).ctor()
.invoke(currentMethod, methodParameters.getProperties_AsArray());
return response.property("Web").property("Results") ;
//using System.Reflection
//using O2.XRules.Database.Languages_and_Frameworks.DotNet
//O2File:DynamicTypes.cs
//O2File:DotNet_SDK_WSDL.cs
//O2File:SecretData_ExtensionMethods.cs


[...] a follow from O2 Script: Using Reflection to Invoke Bing Search Web Service) Here is how one can consume webservices by using a (previously created) C# of the [...]
[...] O2 Script: Using Reflection to Invoke Bing Search Web Service [...]