Solved

WSDL intergation

Posted on 2014-03-27
5
406 Views
Last Modified: 2014-05-29
Hi guy

i need some help getting the total cost of delivery from the below WSDL

http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc

please can you asisted with helping me code in c# to connect to this web server and get the total cost.

i am totally lost and do not know what to do.

i have spoken to the campany and they gave me the below feedback which does not help:

1.      The sample code at aramex.com covers ASP.net C# and PHP only .
2.      For you reference I have attached the WSDL file as well
3.      The WSDL you need to reference is http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc
0
Comment
Question by:JCWEBHOST
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39960092
In your project right-click on "References" and choose "Add Service Reference". Paste that URL into the "Address" field and click "Go". Visual Studio should then interrogate the service and generate a proxy class that you can use to talk to the service.

The you need something like the following to call it:
            ServiceReference1.Service_1_0Client client = new ServiceReference1.Service_1_0Client();
            ServiceReference1.RateCalculatorRequest request = new ServiceReference1.RateCalculatorRequest();

            ServiceReference1.ClientInfo clientInfo = new ServiceReference1.ClientInfo();
            ServiceReference1.Transaction transaction = new ServiceReference1.Transaction();
            ServiceReference1.Address originAddress = new ServiceReference1.Address();
            ServiceReference1.Address destinationAddress = new ServiceReference1.Address();
            ServiceReference1.ShipmentDetails shipmentDetails = new ServiceReference1.ShipmentDetails();

            /* Populate all of the objects created above */

            ServiceReference1.Money totalAmount;
            bool hasErrors;

            // send request to service
            client.CalculateRate(
                clientInfo,
                ref transaction,
                originAddress,
                destinationAddress,
                shipmentDetails,
                out hasErrors,
                out totalAmount
            );

            client.Close();

Open in new window

0
 

Accepted Solution

by:
JCWEBHOST earned 0 total points
ID: 39963382
Hi Sorry

i went far thanks just suck getting the value back, please see code below:

        ServiceReference1.Service_1_0Client client = new ServiceReference1.Service_1_0Client();
        ServiceReference1.RateCalculatorRequest request = new ServiceReference1.RateCalculatorRequest();

        ServiceReference1.ClientInfo clientInfo = new ServiceReference1.ClientInfo();
        ServiceReference1.Transaction transaction = new ServiceReference1.Transaction();
        ServiceReference1.Address originAddress = new ServiceReference1.Address();
        ServiceReference1.Address destinationAddress = new ServiceReference1.Address();
        ServiceReference1.ShipmentDetails shipmentDetails = new ServiceReference1.ShipmentDetails();
        ServiceReference1.Weight shipmentWeight = new ServiceReference1.Weight();

        /* Populate all of the objects created above */

        clientInfo.AccountCountryCode = string.Empty;
        clientInfo.AccountEntity = string.Empty;
        clientInfo.AccountNumber = string.Empty;
        clientInfo.AccountPin = string.Empty;
        clientInfo.UserName = "reem@reem.com";
        clientInfo.Password = "123456789";
        clientInfo.Version = "v1.0";

        transaction.Reference1 = "001";

        originAddress.City = "Dubai";
        originAddress.CountryCode = "AE";

        destinationAddress.PostCode = "SL1 0NS";
        destinationAddress.CountryCode = "GB";

        shipmentDetails.ProductGroup = "EXP";
        shipmentDetails.ProductType = "PDX";
        shipmentDetails.PaymentType = "P";

        shipmentDetails.ActualWeight = new ServiceReference1.Weight();
        shipmentDetails.ActualWeight.Value = 00.5;
        shipmentDetails.ActualWeight.Unit = "KG";

        shipmentDetails.ChargeableWeight = new ServiceReference1.Weight();
        shipmentDetails.ChargeableWeight.Value = Convert.ToDouble(5);
        shipmentDetails.ChargeableWeight.Unit = "LB";

        ServiceReference1.Money totalAmount;
        bool hasErrors;

        // send request to service

        client.CalculateRate(clientInfo, ref transaction, originAddress, destinationAddress, shipmentDetails, out hasErrors, out totalAmount);

        client.Close();
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39963700
Having played around with your code, i think you are just missing the "NumberOfPieces" value from the shipping details:
shipmentDetails.NumberOfPieces = 1;

Open in new window

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40088211
If my comment was the solution, or at least assisted in finding a solution then you should really accept that as the answer, rather than your own comment.
0
 

Author Closing Comment

by:JCWEBHOST
ID: 40097759
works fine
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now