简体   繁体   English

WCF教程出现错误400(错误请求)?

[英]Error 400 (Bad Request) with WCF Tutorial?

I began using WCF last night to setup a simple client server that will allow me to send game information to the client at the beginning of a session. 昨晚我开始使用WCF来设置一个简单的客户端服务器,该服务器允许我在会话开始时将游戏信息发送给客户端。

I followed the microsoft tutorial on WCF and used the VS2008 "WcfSerivce" template to begin and added my methods. 我遵循了有关WCF的Microsoft教程,并使用VS2008“ WcfSerivce”模板开始并添加了我的方法。 I then copied and pasted the address it gives me into the service reference dialog in my client project and added the code to get data from the server. 然后,我将它给我的地址复制并粘贴到客户端项目中的服务引用对话框中,并添加了从服务器获取数据的代码。 However the problem is now, no matter what it always returns error 400 when I request data. 但是现在的问题是,无论什么时候我请求数据时总是返回错误400。

I googled this error and found many people had a problem with a certain message size limit was exceeded, but I get this error even when the method only returns a single character. 我搜索了此错误,发现许多人都遇到了超出特定邮件大小限制的问题,但是即使该方法仅返回单个字符,我仍然收到此错误。

The only thing I can think of is that the URI or namespace address is wrong, what value should they be instead? 我唯一能想到的是URI或名称空间地址错误,应该改为什么值? Thanks 谢谢

EDIT: Here is the code I am using in the service and client, I'm not sure what the rule on post huge amounts of text so I put it on Pastebin, but if its allowed here I will edit again 编辑:这是我在服务和客户端中使用的代码,我不确定发布大量文本的规则,所以我将其放在Pastebin上,但是如果允许,我将再次编辑

http://pastebin.ca/1401443 http://pastebin.ca/1401443

In case anyone else had/has this problem, it is a Windows 7 compatibility issue. 如果其他任何人有/有此问题,则是Windows 7兼容性问题。 I tried on the RTM, and it works. 我尝试了RTM,它可以工作。

You should be able to hit "play" on the service project, and it will navigate to the screen that shows the available methods etc. This is the url you need to use in the client. 您应该能够在服务项目上点击“播放”,它将导航到显示可用方法等的屏幕。这是您需要在客户端中使用的URL。

Is this what you are doing already? 这是您已经在做的吗? Or are you using the url from the sample? 还是使用示例中的网址? In particular, if you are using the integrated development web server (rather than IIS), the port numbers are likely to be random. 特别是,如果您使用的是集成开发Web服务器(而不是IIS),则端口号可能是随机的。

A working WCF service project will generate a page something like: 一个正在运行的WCF服务项目将生成一个类似于以下内容的页面:

{YourService} Service {YourService}服务

You have created a service. 您已创建服务。

To test this service, you will need to create a client and use it to call the service. 要测试此服务,您将需要创建一个客户端并使用它来调用该服务。 You > can do this using the svcutil.exe tool from the command line with the following syntax: 您可以使用以下语法从命令行使用svcutil.exe工具执行此操作:

... ...

If you can get that working, then try adding the client reference. 如果你可以得到的工作,然后尝试添加客户参考。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM