简体   繁体   English

在为客户端控制台应用程序使用WCF服务创建代理类时出错

[英]Getting Error in creating proxy classes for Client Console application to Consume WCF Service

I am working on WCF simple example of helloWorld and I can consume this service using WCF Test Client, however I am getting error while creating proxy classes for client application to consume this service 我正在使用helloWorld的WCF简单示例,并且可以使用WCF Test Client使用此服务,但是在为客户端应用程序使用此服务创建代理类时出现错误

C:\My Work\My Development\WCFTestAPP\HelloWorldClient>  http://localhost:63859/HostDevServer/HelloWorldService.svc?wsdl /out:HelloWorldServiceRef.cs /config:app.config
'http:' is not recognized as an internal or external command,
 operable program or batch file.

Service 服务

 [ServiceContract]
interface IHelloWorldService
{
    [OperationContract]
    string GetMessage(string name);
}

Service Side Implementation 服务端实施

public class HelloWorldService : IHelloWorldService
{
    public string GetMessage(string name)
    {
        return "Hello world from " + name + "!";
    }
}

I have added asp.net webpage in project and update it web.config as 我在项目中添加了asp.net网页,并将其更新为

<configuration>

 <system.web>
  <compilation debug="true" targetFramework="4.5.2" />
  <httpRuntime targetFramework="4.5.2" />
</system.web>
<system.serviceModel>
 <serviceHostingEnvironment >
  <serviceActivations>
    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="~/HostDevServer/HelloWorldService.svc" service="HelloWorldService.HelloWorldService"/>
  </serviceActivations>
</serviceHostingEnvironment>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
 </behaviors>
</system.serviceModel>

You have missed out the name of the program to run to generate the proxy - svcutil. 您已经错过了要运行以生成代理的程序的名称-svcutil。 From a developer command prompt, try 在开发人员命令提示符下,尝试

svcutil http://localhost:63859/HostDevServer/HelloWorldService.svc?wsdl /out:HelloWorldServiceRef.cs /config:app.config

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

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