c# - 为什么我在连接到 wcf 服务时看到 "HTTP Error 400. The request hostname is invalid."

标签 c# wcf wsdl

你好,帮帮我,请了解情况:

连接到wcf服务只在本地获取

http://localhost:50233/Service1.svc?wsdl

当从 LAN 上的另一台机器测试化合物时,我看到错误 400

http://computer:50233/Service1.svc?wsdl

我发现这可能是由于 MaxFieldLength 引起的信息,因此我按照此处的建议编辑了注册表,但它不会改变结果。

C: \ Users \ user> ping computer

Pinging 192.168.0.11 with 32 bytes of data:

Reply from 192.168.0.11: bytes = 32 time <1ms TTL = 127

Reply from 192.168.0.11: bytes = 32 time <1ms TTL = 127

Reply from 192.168.0.11: bytes = 32 time <1ms TTL = 127

Reply from 192.168.0.11: bytes = 32 time <1ms TTL = 127

Ping statistics for 192.168.0.11:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

当您停止服务时,远程计算机上的错误更改为

"Web page not available"

防火墙规则允许端口 50233 上的所有传入连接。

连接到本地地址时

http://computer:50233/Service1.svc?wsdl

我看到同样的错误 400。

当删除或替换 IP 上的“localhost”时

<binding protocol="http" bindingInformation="*:50233:localhost" />

文件\我的文档\IISExpress\配置\applicationhost.config

连接变得不可用。

当你添加另一个 Binding 时

<Binding Protocol="http" bindingInformation="*:50233:localhost" />

<Binding Protocol="http" bindingInformation="*:50233:192.168.0.11" />

尝试启动 swears 程序“[9632] iisexpress.exe”时的服务

失败,代码为 -1073741816 (0xc0000008)“指定了无效句柄”。

Windows 8,Visual Studio 2013,使用自带的IIS Express,两台电脑在同一个域。

最佳答案

命令执行(以管理员身份)

netsh http add urlacl url=http://computer:50233/ user=Everyone

帮助修改了 503 上的 400 错误

现在看看我的wsdl,我只是添加了一个引用

<Binding Protocol="http" bindingInformation="*:50233:computer" /> 
<Binding Protocol="http" bindingInformation="*:50233:192.168.0.11" /> 
<Binding Protocol="http" bindingInformation="*:50233:localhost" /> 

它开始工作了!

谢谢大家,这是个好地方

关于c# - 为什么我在连接到 wcf 服务时看到 "HTTP Error 400. The request hostname is invalid.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24243375/

相关文章:

c# - string.IsNullOrEmpty() 与 string.NotNullOrEmpty()

c# - 在 ASP.NET 服务器端验证 Recaptcha 2(无验证码 reCAPTCHA)

c# - 通过参数获取两个对象之间的匹配百分比

wcf - 客户端应用程序应该使用真实模型类或 DTO 对象与 WCF 服务通信吗?

c# - 无法加载文件或程序集 'System.Private.ServiceModel,版本 = 4.1.2.4

c# - 在泛型中采用任一类型的约束

c# - 如何在 WCF 中使用 net.Pipe 绑定(bind)

.net - 弃用 WCF 服务的最佳实践

web-services - WSDL 中的 targetNamespace 和命名空间

python - SOAP 水和选择标签