Solved

WSDL intergation

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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