Reputation: 662
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.
Upvotes: 0
Views: 1193
Reputation: 662
Here is the code I used @Rihab Berrich. I don't recall exactly what the issue was but hoping this will help you and anyone else who stumbles across this.
string apiParams = $"?address={AddressLine1.Replace(' ', '+')}&city={City.Replace(' ', '+')}&zip={PostalCode.Replace(' ', '+')}";
string endPoint = $"https://services.maps.cdtfa.ca.gov/api/taxrate/GetRateByAddress{apiParams}";
RestClient client = new(endPoint) { Timeout = 30000 };
RestRequest request = new();
request.AddHeader("Cookie", "TiPMix=28.368612388085868; x-ms-routing-name=self");
IRestResponse response = client.Execute(request);
CATax cATax = JsonConvert.DeserializeObject<CATax>(response.Content);
And here is the CATax data model class
public class CATaxModel
{
public class CATax
{
public Taxrateinfo[] TaxRateInfo { get; set; }
public Geocodeinfo GeocodeInfo { get; set; }
public string TermsOfUse { get; set; }
public string Disclaimer { get; set; }
}
public class Geocodeinfo
{
public string[] MatchCodes { get; set; }
public string FormattedAddress { get; set; }
public string Confidence { get; set; }
public string CalcMethod { get; set; }
public int BufferDistance { get; set; }
}
public class Taxrateinfo
{
public decimal Rate { get; set; }
public string Jurisdiction { get; set; }
public string City { get; set; }
public string County { get; set; }
public string Tac { get; set; }
}
}
Upvotes: 0
Reputation: 495
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>
Upvotes: 1