Solved

WSDL intergation

Posted on 2014-03-27
5
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

740 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