Calling REST services in C#

zenrast

Client
Регистрация
20.03.2013
Сообщения
57
Благодарностей
1
Баллы
8
Hi,

How would be the best way to call a REST
type web service in Zennoposter C# code?

How to do it?
 

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113
Usually the simplest way is to use ZennoPoster.HttpGet/Post and parse the result.
Also if service suggest REST API, it often provide a C# DLL that you can use in your application.
 

zenrast

Client
Регистрация
20.03.2013
Сообщения
57
Благодарностей
1
Баллы
8
Actually the REST API is my own service written in PHP.
Currently im consuming the service by a GET block in ZennoPoser and a
new block of C# code that parses the XMl in the received message(variable).

But im not sure this is the correct/best way according to REST architecture.
Im not sure, but form Zenno side I would probably need to return a correct status code
with some XML in body of a response(successfuly received, error etc.).

As you can see Im still developing the PHP and the Zennopart...the C# word is new
for me but im learning it quickly(have Java and PHP background)...so im trying
to come up with a robust architecture to make this work.

Some questions that go trough my mind:
Could this be done inside C# block? Do i need to write some C# code in visual studio
and compile it as DLL and add it to Zennoposter(how?)? I have read some stuff about
WFC (Windows Communication Foundation), can this be used inside Zennoposter to
accomplish my goals?
 

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113
Could this be done inside C# block?
Yes, you can replace http get with ZennoPoster.HttpGet
Please do not use internal C# methods like WebClient or HttpRequest because this can cause the instability of the ZennoPoster.
I think Get request and xml parsing will be the best option for your situation.

Do i need to write some C# code in visual studio and compile it as DLL and add it to Zennoposter(how?)?
You do not need to use Visual Studio in your case. If you want to make a separete dll. You have to make a class library with public methods and reference you dll to the ZennoPoster Project to be able to invoke methods from your dll.

I have read some stuff about WFC (Windows Communication Foundation), can this be used inside Zennoposter to accomplish my goals?
It is actual only if you are using ASP.NET as you server platform. If you are on PHP platform REST is the best choise in your case.
 

zenrast

Client
Регистрация
20.03.2013
Сообщения
57
Благодарностей
1
Баллы
8
Is it possible to set the appropriate headers like "Content-Type: application/xml" with ZennoPoster.HttpGet / ZennoPoster.HttpPost ?
 

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113
  • Спасибо
Реакции: bigcajones

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)