Solved

WSDL intergation

Posted on 2014-03-27
5
408 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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