OWASP O2 Platform Blog

O2 Script: consume webservices by using the WSDL’s C#

(as 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 WSDL:

var _GlobalWeather = new GlobalWeather();
_GlobalWeather.GetWeather("Porto", "Portugal");

return _GlobalWeather;

//O2File:C:\O2\_tempDir\4-3-2011\wsdl_tmpC7EC\GlobalWeather.cs
//O2Ref:System.Web.Services.dll

//Note: the GlobalWeather.cs file was created with the command:
//
//     return new DotNet_SDK_WSDL().wsdl_CreateCSharp("http://www.webservicex.net/globalweather.asmx?WSDL");
//     //O2File:DotNet_SDK_WSDL.cs
//     //using O2.XRules.Database.Languages_and_Frameworks.DotNet

Here is Bing API version, note how (when compared with this version (O2 Script: Using Reflection to Invoke Bing Search Web Service) which is reflection based) all variable references are strongly typed)

var AppID = @"C:\O2\_USERDATA\accounts.xml".credential("Bing_API").password();</pre>
var _BingService = new BingService();

var _parameters = new SearchRequest();

_parameters.AppId = AppID;
_parameters.Sources = new SourceType[] { SourceType.Web };
_parameters.Query = "OWASP";

var response = _BingService.Search(_parameters );
return response.Web.Results;

//O2File:C:\O2\_tempDir\4-3-2011\wsdl_tmp107F\BingService.cs
//O2Ref:System.Web.Services.dll
//O2File:SecretData_ExtensionMethods.cs

April 3, 2011 - Posted by | .NET, WS

1 Comment »

  1. […] O2 Script: consume webservices by using the WSDL’s C# […]

    Pingback by Script to fetch and present large number of Wordpress.com blog entries « O2Platform.com for Developers | April 16, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: