UPS WSDL / C#示例编译错误

时间:2013-02-02 18:56:55

标签: c# web-services wsdl ups

我有一个C#ASP.NET该网站我试图添加UPS报价。我使用了示例中的代码并导入了包含的WSDL,所有对象都正确映射到除RateService类之外的wsdl。

This is the code sample and WSDL that I am working from

这是包含错误的代码段:

RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();

编译错误是找不到RateService

我很确定WSDL是导入的,因为其余的类编译得很好。自样本以来UPS是否更改了API?有人有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您的WSDL文件包含以下块:

<wsdl:service name="RateService">
    <wsdl:port name="RatePort" binding="tns:RateBinding">
        <!-- Production URL -->
            <!-- <soap:address location="https://onlinetools.ups.com/webservices/Rate"/> -->
            <!-- CIE (Customer Integration Environment) URL -->
            <soap:address location="https://wwwcie.ups.com/webservices/Rate"/>
    </wsdl:port>
</wsdl:service>

看起来RateService serice已定义。你确定它输入正确吗?

示例代码(在您的zip中)还显示了生成的Web引用 - 它具有RateService类。

要将此引用添加到项目中,请转到Add Service Reference,在对话框的底部选择Advanced,然后选择第二个对话框底部的Add Web Reference。输入WSDL文件的URL,然后添加引用。

确保在代码文件中添加正确的using语句,以使用WSDL中的类型。

(这适用于VS 2008和VS 2010。)