Apo*_*los 5 c# web-services windows-phone-7
我试图在Windows手机上使用这个http://footballpool.dataaccess.eu/data/info.wso?wsdl网络服务异步.我的代码是这样的:
private void button1_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.InfoSoapTypeClient client = new ServiceReference1.InfoSoapTypeClient();
client.AllCardsCompleted += new EventHandler<ServiceReference1.AllCardsCompletedEventArgs>(GetAllPlayers);
client.AllCardsAsync(true);
}
private void GetAllPlayers(object sender, ServiceReference1.AllCardsCompletedEventArgs e)
{
textBlock1.Text = e.Result.ToString();
}
Run Code Online (Sandbox Code Playgroud)
我已经阅读过类似问题的许多类似的答案,但没有针对Windows手机.我得到的错误是:"远程服务器返回了意外的响应:(405)方法不允许."
Web服务看起来在项目之外消耗得很好.当您点击链接时,您将看不到任何内容,但如果您重新键入链接,您将获得wsdl文档.
“(405) Method Not Allowed”表示您的客户端正在使用服务器不期望的 HTTP 方法(例如,您尝试执行 GET,而服务器期望使用 POST)。时间
尝试使用fiddler或wireshark捕获http 流量,并检查应用程序发送的HTTP 请求和服务器的响应。将它们与您在 WP7 之外使用此服务时获得的正确请求/响应对进行比较(您可以为此使用WCFTestClient )。
攻击此问题的另一种方法是比较在 WP7 应用程序和标准控制台应用程序中添加 WebService 引用时生成的代理(客户端)类。也许 WP7 上的代理有一些不正确的方法签名?
另一件事:当使用 WCFTestClient 测试此服务时,我收到错误:
已超出传入消息的最大消息大小配额 (65536)。要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。
因此请确保MaxReceivedMessageSize设置正确。