How to use FedEx Web Services in flutter

344

WSDL isn't something you import into your app, or at least not with dart. It describes the requests that can be made to the various endpoints their server supports.

Fedex's documentation does a better job explaining than I could:

A SOAP request to, or response from a service is generated according to the service’s WSDL definition.

A WSDL is an XML document that provides information about what the service does, the methods that are available, their parameters, and parameter types. It describes how to communicate with the service in order to generate a request to, or decipher a response from, the service.

The purpose of a WSDL is to completely describe a web service to a client. A WSDL generally defines where the service is available and which communication protocol is used to talk to the service. It defines everything required to write a program that will work with an XML web service.

There's a good chance that the endpoint actually uses SOAP for the communication, which dart doesn't currently fully support. You're going to have to use something like dart:xml to generate requests that match the description in the WSDL, and then you can send them with the http.Client the same way as you have done for the other API.

Share:
344
Jerry Kou
Author by

Jerry Kou

Updated on December 11, 2022

Comments

  • Jerry Kou
    Jerry Kou over 1 year

    I'm developing an APP to track FedEx packages using flutter. Where should I integrate FedEx web service WSDL into my code so that I can send my tracking request to FedEx and get the response back?

    Currently I'm testing with another api and able to get response by sending request directly to the url of this api. But FedEx web service does not work that way and I have to use their WSDL to set the url.

    Beer.fromJSON(Map<String, dynamic> jsonMap) :
            id = jsonMap['id'],
            name = jsonMap['name'],
            tagline = jsonMap['tagline'],
            description = jsonMap['description'],
            image_url = jsonMap['image_url'];
    }
    
    Future<Stream<Beer>> getBeers() async {
      final String url = 'https://api.punkapi.com/v2/beers';
    
      final client = new http.Client();
      final streamedRest = await client.send(
          http.Request('get', Uri.parse(url))
      );
    
      return streamedRest.stream
          .transform(utf8.decoder)
          .transform(json.decoder)
          .expand((data) => (data as List))
          .map((data) => Beer.fromJSON(data));
    }
    
  • Jerry Kou
    Jerry Kou almost 5 years
    Thank you for your answers! But I'm still struggling with which url I should send my request to. Back to the FedEx example, it does not provide an exact url where I can send my request through http.Client. All I have is this WSDL and I can only rely on it to set up my request. In the Java code they provide, there is a package that does all the set up for the user but I don't have such thing in dart.