[英]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.