在这里使用 API 包:https://www.ups.com/gec/techdocs/pdf/Rates_Pkg_Gnd.zip
通过以下方式添加对 RateWS.wsdl 的引用:
-右键点击网站项目->添加服务引用
-在地址栏输入:file://C:\Users\MyUser\Desktop\UPS API\RatingPACKAGE\PACKAGEWebServices\SCHEMA-WSDLs\RateWS.wsdl
Visual Studio 添加了几个引用文件:
使用API包中提供的示例代码,我将测试代码复制到我的项目中。
问题:未定义“RateService”类。缺少引用?
似乎未正确添加 Web 引用。 RateService 类是未知的。感谢您的帮助。
最佳答案
我认为问题在于您正在尝试添加服务引用而不是 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.
关于c# - UPS API .Net 添加 Web 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38363503/