当我通过SOAP UI测试Web服务(json服务)时,我得到了正确的响应,但我没有使用c#进行管理。
您能否告诉我如何通过c#访问此Web服务?
SOAP UI中的服务查询raw看起来像这样
GET https://ws.teias.gov.tr/apigateway/prod/yanhizmetler/YanHizmetlerServiceRest/getBaraDegerleri?gecerlilikTrh=2018-02-20 HTTP/1.1
Accept-Encoding: gzip,deflate
password: XXXXX
username: 40X000000005030W
Host: ws.teias.gov.tr
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
答案 0 :(得分:0)
我写了这个但是有500个内部错误 var webRequest = WebRequest.Create(“https://ws.teias.gov.tr/apigateway/prod/yanhizmetler/YanHizmetlerServiceRest/getBaraDegerleri?gecerlilikTrh=2018-02-17”); webRequest.Credentials = new System.Net.NetworkCredential(“40X000000005030W”,“4gHjLa9nS”); webRequest.Headers [“Authorization”] =“Basic”+ Convert.ToBase64String(Encoding.Default.GetBytes(“40X000000005030W”+“:”+“****”)); // webRequest.Headers.Add(“40X000000005030W”,“****”);
webRequest.Method = "Get";
webRequest.ContentType = @"application/json";
HttpWebResponse resp = webRequest.GetResponse() as HttpWebResponse;