Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UPS API .Net Add Web Reference

Using the API package here: https://www.ups.com/gec/techdocs/pdf/Rates_Pkg_Gnd.zip

Added the reference to RateWS.wsdl by:

-Right click on website project -> Add Service Reference

-In the address field input: file://C:\Users\MyUser\Desktop\UPS API\RatingPACKAGE\PACKAGEWebServices\SCHEMA-WSDLs\RateWS.wsdl

Visual Studio added several reference files:

enter image description here

Using the Sample code provided in the API package, I copied the test code to my project.

The problem: The "RateService" class is not defined. Missing reference?

enter image description here

It appears the web reference was not added properly. The RateService class is unknown. Thanks for your help.

like image 532
Tomas Beblar Avatar asked Jul 13 '16 23:07

Tomas Beblar


2 Answers

I think the problem is that you are trying to add a Service Reference instead of a Web Reference:

To add a Web reference to a project In Solution Explorer, right-click the name of the project that you want to add > the service to, and then click Add Service Reference. The Add Service Reference dialog box appears. In the Add Service Reference dialog box, click the Advanced button. The Service Reference Settings dialog box appears. In the Service Reference Settings dialog box, click Add Web Reference. The Add Web Reference dialog box appears. I n the URL box, enter the URL of the Web service to use. If you do not know the URL, use the links in the browse pane to locate the Web service you want.

like image 141
paburgos Avatar answered Oct 17 '22 10:10

paburgos


UPS documentation is often out of sync with the code sample. You should modify your code like this:

FreightRatePortTypeClient Client = new FreightRatePortTypeClient();

....
....

FreightRateResponse resp = Client.ProcessFreightRate(upss, <your freight rate request object>);

This worked for me!

like image 34
Techfritters Avatar answered Oct 17 '22 11:10

Techfritters