PDA

View Full Version : C# sample


AdamNaj
25th January 2008, 15:18
The documentation pages state that the APi is available from C#, which I assume implicates that someone has succesfully called them from the language.

The wsdl however is not importing correctly in VisualStudio neither 2005 (does not even import most of the methods) or 2008 (All the methods return void and have 0 parameters).

The errors listed by Visual studio while importing the WSDL are as follows
// CODEGEN: The operation binding 'ListJobs' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'ListPackages' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'CreateServer' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'DestroyServer' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'ListRunningJobs' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'ListServers' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'Login' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'RebootServer' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'StartServer' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'StopServer' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.
// CODEGEN: The operation binding 'WaitForJobs' from namespace 'urn:FlexiScale' was ignored. Each message part in an use=encoded message must specify a type.

Which is pretty obvious once you look at the insides of the WSDL that the types are not defined and thus a strong typing language will not allow for accessing those with nice calls like the samples for php and Perl show.

I've managed to modify the generated code to succesfully call Login with my credentials but not having much luck with calls returning complex structures like "ListServers()".

Could you please provide a sample for calling e.g. ListServer() from a C# code? Is there any SDK for .Net or at least the web service calls encapsulated in a way that are fairly easy for consumption?

AdamNaj
25th January 2008, 16:52
It appears that Java is also behaving similarly, we were not able to generate the classes for the "https://api.flexiscale.com/FlexiScale.wsdl" wsdl - it seems like it is missing definition of sent and received files.

Ideally having a valid wsdl would be great but at least having a working cample of how to call methods requiring providing or returning complex types would suffice.

Thanks in advance

james
25th January 2008, 17:07
Hi,

We are aware that that are problems with the wsdl file for strongly typed languages at present, this is being worked on and we hope to release an updated version which is fully compatible shortly, I will post again here when we have updates.

Regards

James

james
7th February 2008, 18:04
Hi,

The FlexiScale API has now been updated and tested and should work with strongly typed languages now including C# and Java.

Further information can be found at https://api.flexiscale.com.

We do aim to increase the documentation and examples available in the near future as well as further improvements in functionality.

James

chrisbond
17th April 2008, 14:23
Hi,

The FlexiScale API has now been updated and tested and should work with strongly typed languages now including C# and Java.

Further information can be found at https://api.flexiscale.com.

We do aim to increase the documentation and examples available in the near future as well as further improvements in functionality.

James

Hi James,

I've just opened a new web project in visual studio and pointed it at the web reference https://api.flexiscale.com/current/FlexiScale.wsdl.

I then goto my page load event and type Dim flexiscale as New com.flexiscale.api

If you examine the files it generates via the object browse it doesnt have functions for ListServers() etc in any of the object returned.

Do you have a copy of the c# example that you could email my email address is on server id #778.

Kind Regards,
Chris Bond

james
18th April 2008, 12:46
Hi,

I am looking into this at the moment and will get back to you in this thread as soon as possible.

Regards

James

james
18th April 2008, 16:11
Chris,

We do hope to release fuller examples of documentation for the API shortly to help people to use it more easily.

In your case, the function ListServers can be found within the FlexiScaleService section of the object browser.

Regards

James

chrisbond
21st April 2008, 15:06
Any luck one this just tried to regenerate the web reference from visual studio 2008 an still no luck on ListServers.

chrisbond
21st April 2008, 15:47
Firstly, sorry my fault understood your object model incorrectly.

After playing about i could see the following partially worked.

Dim flexiscale As New com.flexiscale.api.FlexiScaleService
flexiscale.Login(ConfigurationManager.AppSettings("FlexiScaleUsername"), ConfigurationManager.AppSettings("FlexiScalePassword"))
Dim list() As String
flexiscale.ListServers(list)
flexiscale.Logout()

Do you have an example of how to loop through your ListServers(list) to display the server name and status. Once I understand how ListServers works i should be able to work the rest out myself!

Thanks.

chrisbond
30th April 2008, 08:27
Anybody found a solution for this as currently I cannot use the api at all from .NET :(

james
2nd June 2008, 11:46
Hi,

Examples for C# and Java have now been posted to the API documentation at https://api.flexiscale.com/current/doc/soap.html

Regards

James

chrisbond
2nd June 2008, 12:02
Hi,

Examples for C# and Java have now been posted to the API documentation at https://api.flexiscale.com/current/doc/soap.html

Regards

James

Amazing - works a dream - will provide a sample vb.net one shortly for you to add to list as its slightly different (convertors work but dont prefered vb.net options).

Thanks!

chrisbond
2nd June 2008, 14:38
Amazing - works a dream - will provide a sample vb.net one shortly for you to add to list as its slightly different (convertors work but dont prefered vb.net options).

Thanks!

Quick question - in the ListServers array the uptime field is a long. What format is this date in as usually we use DateTime.Parse in .NET so we must have todo some type of conversion to get the correct date....

mumbajack
31st October 2008, 12:58
Hi Chris,

Don't know if this is to late to help but i got the api working in VS2008 by changing allowCookies="false" to allowCookies="true" in the app.config (or web.config). Then the following code should work:

FlexiScaleClient client = new FlexiScaleClient();
client.Login("Username", "Password");
Server[] servers = client.ListServers(new string[] {} );
client.Logout();

I'm still having a few problems with the client.StopServer api (it seems to change the status to "starting" rather that "stopping") but other than that everything else seems to work.

Let me know how you get on.

Joel

jcollins
8th November 2008, 14:20
Don't know if this is to late to help but i got the api working in VS2008 by changing allowCookies="false" to allowCookies="true" in the app.config (or web.config). Then the following code should work:

FlexiScaleClient client = new FlexiScaleClient();
client.Login("Username", "Password");


Login credentials are maintained across calls to the API using session cookies. As a result, the API documentation suggests attaching a cookie container to the web service object - see any of the C# examples at https://api.flexiscale.com/. For example:

FlexiScaleClient client = new FlexiScaleClient();
client.CookieContainer = new System.Net.CookieContainer();
client.Login("Username", "Password");


...but, as mumbajack says, this is probably too late to be of any use. Very little activity on this API forum, doubtless partly because of the stability problems Flexiscale's been having for a while now.

(If anyone wants any further information on using the API, we can supply the source code of the command-line app mentioned at http://www.matchpeg.com/brochure/misc/flexiscale.asp - and quoted on the Flexiscale blog at http://blog.flexiscale.com/2008/07/07/interesting-info/. Perhaps if more people start using the API that'll somehow magically lead to the stability problems being sorted out. It's about the only thing, other than sacrificing goats at full moon, that we haven't tried in order to make our servers more reliable.)

tonylucas
8th November 2008, 23:34
Lots of work underway in that respect, nothing I can publically comment on at the moment but I will as soon as I possibly can.

Suffice to say stability and reliability is our number one priority, well above all others.

Regards,

Tony.