Search code examples
c#web-servicessoapwsdlsoap-client

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


I am trying to connect to the California tax rate public API in my C# console application and receiving the service reference error below. I have been using it successfully for about 9 months. I tried to recreate the reference in a new application but receive the same error. I am unsure what troubleshooting steps to take. Please let me know if I can provide any more useful information.

The service is located here and is public to test: 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.


Solution

  • the wsdl that you get from the endpoint is invalid.

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

    should be

    <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>
    

    and the same for

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

    also

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

    should be

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

    and last

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

    must be

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