简体   繁体   English

ASP.NET Web 服务 - 400 错误请求

[英]ASP.NET Web service - 400 bad request

I have a web service that gets a string as parameter and returns string .我有一个 web 服务,它获取一个string作为参数并返回string This service is located on server1.此服务位于 server1 上。 On server2 I have a little (2 line) console application to test this web service and everything works ok.在 server2 上,我有一个小(2 行)控制台应用程序来测试这个 web 服务,一切正常。 When I call the same web service (using the same settings - no settings, url is the same, everything about web service part is the same) I get "400 bad request" error.当我调用相同的 web 服务时(使用相同的设置 - 没有设置,url 是一样的,关于 web 服务部分的一切都是一样的)我得到“40”错误。 In the same function I have something like this:在同一个 function 我有这样的东西:

using(var ctx = ClientContext(siteUrl)) //  sharepoint client object model
{
   using(var db = SomeEntitiesContext()) // entities context
   {
       ...
       var webservice = MyService.MyServiceClass();

       foreach(var item in items)
       {
           var res = webservice.MyMethod(myinput); //here I get 400 bad request error
       }
   }
}

Is it possible that other contexts have mixed up something?有没有可能是其他上下文混淆了某些东西? It's strange that a console based testing app is working.奇怪的是,基于控制台的测试应用程序正在运行。

It was something with the string that I get from DB vs hardcoded (the same string from DB)... I changed web service so it gets byte array insted of string and now it works.这是我从 DB 获得的字符串与硬编码的字符串(来自 DB 的相同字符串)...我更改了 web 服务,因此它获取了字符串的字节数组,现在它可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Web API HTTP 400错误请求 - ASP.NET Web API HTTP 400 Bad Request 部署到测试服务器时,POST请求上的ASP.NET Web API“ 400错误请求” - ASP.NET Web API “400 Bad Request” on POST Request When Deploying to Test Server 400 错误请求 | 从 ASP.NET Web API 接收自定义错误消息或模型 - 400 Bad Request | Receive custom error message or model from ASP.NET Web API 从远程计算机调用Web api core asp.net总是收到400错误请求 - Calling web api core asp.net from remote computer always gets 400 bad request ASP.NET Web API OAuth Cors导致400错误的请求 - Asp.net web api oauth cors results in 400 bad request 如何在生产环境中禁用 Asp.Net Core web API 中的 400 Bad request 的消息正文? - how to disable 400 Bad request's message body in Asp.Net Core web API in production environment? 网络服务-400错误的请求 - web service - 400 bad request ASP.NET HttpHandler可以处理http 400 - 错误请求吗? - Can an ASP.NET HttpHandler handle an http 400 - Bad Request? Facebook登录asp.net 400错误的请求 - facebook login in asp.net 400 bad request 400 对 PUT 调用的错误请求 Asp Net Web Api 2.2 - 400 Bad Request for PUT calls Asp Net Web Api 2.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM