-1

How to create client server application in dart. My aim is to create a program to extract parameters form URL and store them in session on variable and connect the dart to .net web service and in below code i shows The built-in library 'dart:io' is not available on Dartium.

import 'dart:core'; 
import 'dart:io';// import the dart:io library

main() {
  HttpServer server; // create the server
  server.listen("127.0.0.1", 8080); // and start listening
}
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
unlimitederrors
  • 93
  • 2
  • 11

1 Answers1

3

When I understand your question correctly, the server part of your client server application is a .NET web service. So you try to write the client side in Dart (the part that runs in the browser)?

You don't need to import dart.core.
If you want to run an app in the browser you must not import dart:io. dart:io is for Dart applications that run locally like commands you execute on the command line or launch using an icon on your desktop or that run as a background service.

In Browser applications you normally import dart:html instead. dart:html doesn't provide a lot of functionality that dart:io has. This is because the browser doesn't allow for example to access the local file system due to security reasons. Imagine you browse to a website and the code in this website could read, delete or upload to any server any file on your computer ...

When you have imported dart:html you can use the class HttpRequest to connect to the server.

Did you develop the .NET web service yourself? You can easily access web services that provide a REST or JSON API. I don't know how to access .NET SOAP webservice with Dart though?

You can find basic instructions how to make a request to the server here https://www.dartlang.org/articles/json-web-service/

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • what are _ and .. in any dart program what does they do – unlimitederrors May 23 '14 at 13:29
  • At the beginning of a field or method to make the field or method private. In the argument list like `(_)` it is used as a variable name like 'a', 'index', ... but the convention is to use '_' as variable name to indicate that the value is ignored. The '..' is used like 'with' in Visual Basic it is named continuation operator. `var a = new A()..x = 50..y=30` assignes a new 'A' instance to `a` and sets `a.x = 50` and `a.y = 30`. – Günter Zöchbauer May 23 '14 at 13:59
  • how to extract url paramenter and store them in session variables – unlimitederrors May 23 '14 at 14:27
  • I don't know what to do with your last comment. – Günter Zöchbauer May 23 '14 at 14:37
  • hey how to write client part for .net server webservice can you give me any sample – unlimitederrors May 24 '14 at 08:35
  • It's about 5 years I worked with .NET the last time. I think you should ask a new question with a .NET tag. Why don't you want (or can't) write the server in Dart? – Günter Zöchbauer May 24 '14 at 09:44