远程服务器上的 WCF 托管
我在我的机器上创建了一个 WCF 服务,并将其托管在 IIS 下,它工作正常。 然后我编译我的服务,并将编译代码放在远程服务器上。我将其托管在远程服务器上的 IIS 下。但是当我尝试在我自己的机器上的客户端中使用它时,它会生成以下错误。
内容类型text/html;响应消息的 charset=utf-8 与绑定的内容类型 (application/soap+xml; charset=utf-8) 不匹配。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。响应的前 1024 个字节是:'
然后我尝试使用浏览器在远程服务器上打开它。当我单击 wsdl 的链接时,它显示错误的请求或无效的主机名。可能是什么问题。
I created a WCF service at my machine, I hosted it under IIS, it works fine.
then I compile my service , and i put the compile code at remote server. i hosted it under IIS on remote server. but when i try to consume it in my client at my own machine it generate the following error.
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
then I try to open it at remote server using browser. when i click on the link for wsdl it says bad request or invalid host name. what could be the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“内容类型”错误实际上是在客户端产生的,因为 IIS 正在向您的肥皂请求发送 HTML 响应。原因通常是 IIS 中的虚拟目录配置不正确或 WCF 无法初始化。 IIS 响应的内容有时对于调试这些问题确实很有帮助。要检查该 HTML,请使用 Fiddler 等工具拦截并检查请求期间的 HTTP 流量。
如果拦截的 HTTP 流量没有帮助,则可以通过在 WCF 服务 .svc 文件所在的文件夹中创建一个简单的纯 HTML 页面(如 test.html)来开始对 IIS 进行故障排除。尝试通过浏览器访问该页面。如果浏览器正确显示页面内容,则 IIS 正在运行,问题出在 WCF 配置中。根据您的两个错误,我认为您的服务虚拟目录中存在 IIS 配置问题。
The "content type" error is actually produced on the client side because IIS is sending an HTML response to your soap request. The cause is usually the virtual directory in IIS isn't properly configured or that WCF is failing to initialize. The contents of the IIS response can sometimes be really helpful in debugging these issues. To inspect that HTML, use a tool like Fiddler to intercept and review the HTTP traffic during your request.
If the intercepted HTTP traffic isn't helpful, then start troubleshooting IIS by creating a simple HTML only page (something like test.html) in the folder where the WCF service .svc file is located. Try acessing that page through the browser. If the browser correctly shows the page contents then IIS is working and the problem is in the WCF config. Based on your two errors, I'd say you have an IIS config issue in the virtual directory for the service.