服务参考:HTTP 状态 404 - 元数据包含无法解析的参考

Service Reference: HTTP Status 404- Metadata contains a reference that cannot be resolved

我正在尝试在我的 C# 控制台应用程序中连接到加利福尼亚税率 public API 并收到以下服务引用错误。我已经成功使用了大约 9 个月。我试图在新应用程序中重新创建引用,但收到相同的错误。我不确定要采取哪些故障排除步骤。如果我能提供更多有用的信息,请告诉我。

服务位于此处,正在public进行测试:http://services.gis.boe.ca.gov/api/taxrates/Rates.svc

There was an error downloading 'http://services.gis.boe.ca.gov/api/taxrates/Rates.svc/$metadata'. The request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: 'http://services.gis.boe.ca.gov/api/taxrates/Rates.svc'. The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error. If the service is defined in the current solution, try building the solution and adding the service reference again.

您从端点获取的 wsdl 无效。

<xs:element name="TestResponse">
  <xs:element minOccurs="0" maxOccurs="1" name="TestResult" type="xs:string"/>          
</xs:element>

应该是

<xs:element name="TestResponse">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" name="TestResult" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

也一样
<xs:element name="GetRateResponse">
    <xs:element minOccurs="0" maxOccurs="1" name="GetRateResult" type="tns:CARateResponseCollection"/>
</xs:element>

还有

<wsdl:message name="ISoapService_Test_OutputMessage">
    <wsdl:part name="parameters" element="tns:String"/>
</wsdl:message>

应该是

<wsdl:message name="ISoapService_Test_OutputMessage">
  <wsdl:part name="parameters" element="tns:TestResponse"/>
</wsdl:message>

最后

<wsdl:message name="ISoapService_GetRate_OutputMessage">
    <wsdl:part name="parameters" element="tns:CARateResponseCollection"/>
</wsdl:message>

必须是

<wsdl:message name="ISoapService_GetRate_OutputMessage">
        <wsdl:part name="parameters" element="tns:GetRateResponse/>
</wsdl:message>