调试微软WCF示例程序GettingStarted程序,总是不能成功,以此请教WCF

YangYun 2011-08-21 09:09:15
最近想学习和使用WCF,于是下载调试微软WCF示例程序GettingStarted程序,总是不能成功,以此请教WCF。
先说直接调试出现的问题:
1、远程服务器返回了意外响应:(405)Method not allowed,此错误指向Client.cs中的
static void Main()
{
// Create a client
CalculatorClient client = new CalculatorClient();

// Call the Add service operation.
double value1 = 100.00D;
double value2 = 15.99D;
double result = client.Add(value1, value2); ---错误就指向这里
Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

// Call the Subtract service operation.
value1 = 145.00D;
value2 = 76.54D;
result = client.Subtract(value1, value2);
Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);
client.Close();

Console.WriteLine();
Console.WriteLine("Press <ENTER> to terminate client.");
Console.ReadLine();
}
2、我到IIS中看了一下,有一虚拟目录:ServiceModelSample,该虚拟目录是自动生成的吧?
...全文
219 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
YangYun 2011-08-22
  • 打赏
  • 举报
回复
谢谢关注啊,继续求助中........
冰凝 2011-08-22
  • 打赏
  • 举报
回复
帮顶下,嘿嘿
YangYun 2011-08-22
  • 打赏
  • 举报
回复
不会吧,居然没人关注和回复一下么?帮顶一下也行啊
YangYun 2011-08-22
  • 打赏
  • 举报
回复
大家平时都不用WCF么?
YangYun 2011-08-21
  • 打赏
  • 举报
回复
而且,我发现,在Client项目中添加“添加 Web引用....”时,不能发现现有的Service服务,手动添加:Http://localhost/ServiceModelSample/service.svc时,提示:服务器程序不可用。
浏览“此解决方案中的WEB服务”时,提示:当前解决方案时未找到WEB服务.


这是怎样会事呢?
YangYun 2011-08-21
  • 打赏
  • 举报
回复
我到网上四处查看了一下svcutil.exe等生成客户端代理的程序。此程序生成的程序为generatedClient.cs,这个程序中是怎样生成的啊?生成的程序generatedClient.cs中有如下的代码:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculator")]
public interface ICalculator
{

[System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")]
double Add(double n1, double n2);

[System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")]
double Subtract(double n1, double n2);

[System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")]
double Multiply(double n1, double n2);

[System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")]
double Divide(double n1, double n2);
}
这里如果要手工修改,是否要将Action修改为本地的如为Http://localhost/serviceModelSample,具体怎样修改?

我发现许多讲解WCF编程的书,都没有讲清具体怎样进行配置,都是拷贝人家微软MSDN中的内容,都让人看得懂,却还是不会做的感觉啊
Apress, 2011 Windows Presentation Foundation (WPF) is a graphical computer platform built and distributed by Microsoft to create rich client applications for Windows systems. With WPF, you can build rich interfaces with animations and amazing graphical effects as easily as you can build minimalist and corporate user interfaces for line-of-business (LOB) applications. Unfortunately, because WPF is such a powerful and complex technology, it requires some initial effort to understand its mechanisms. Moreover, for a newbie, the XAML markup used to create the user interfaces can be tough to come to grips with. Creating a WPF application and, more generally, creating any type of application with a user interface is a rather convoluted task; it comprises a number of phases and the final result is likely to be of a certain complexity. A standalone application built using WPF is usually made up of various “components” that are used to encapsulate the “modules” of the software. You might have, for instance, a component to access the data, a component to include a logical function, a component to render the user interface, and so on. In this book, I will show you how to create and implement WPF, using best practices to create a realworld application. At the same time, I’ll also show you how to structure and architect a WPF application made up of different components that you’ll be able to recycle for future applications. By the end of the book, you should have a working knowledge of WPF and know how to architect a WPF application using the tools provided by Microsoft, such as SQL Server 2008 R2 Express Edition, the Entity Framework, Window Communication Foundation (WCF), and more. amazon link:http://www.amazon.com/exec/obidos/ASIN/1430234709/buythisbooks-20

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧