控制台应用程序使用wcf服务 [英] Console application consuming wcf service

查看:75
本文介绍了控制台应用程序使用wcf服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行良好的c#asp.net web应用程序/项目。后来我添加了一个wcf服务作为这个项目的新项目。然后我向此解决方案添加一个新的简单控制台应用程序以使用wcf。它在我的本地工作正常。 (我的本地服务器名称为A.使用http://A/MyProjName/wcfSendRpt.svc或http://localhost/MyProjName/wcfSendRpt.svc两者都可以)。



然后我将我的web应用程序(带有wcf服务)发布到实时服务器B.(B只托管这个唯一的web应用程序。)http:// B /wcfSendRpt.svc或http://localhost/wcfSendRpt.svc工作正常。

然后我将我的控制台应用程序部署到服务器B.(我只是将exe和配置文件复制到服务器B)。我将配置文件中的端点地址从http://A/MyProjName/wcfSendRpt.svc更改为http://B/wcfSendRpt.svc,如下所示

I have a c# asp.net web application/projct which is working well. Later I added a wcf service as new item to this proj. Then I add a new simple Console application to this solution to consume the wcf. It works fine in my local. (My local server name is A. Using http://A/MyProjName/wcfSendRpt.svc OR http://localhost/MyProjName/wcfSendRpt.svc both Okay).

Then I published my web application( with the wcf service) to live server B. (B just host this only web-application. ) Both http://B/wcfSendRpt.svc OR http://localhost/wcfSendRpt.svc works fine.
Then I deployed my Console application to server B. ( I just copyed the exe and config files to sever B). I changed the endpoint address in config file from "http://A/MyProjName/wcfSendRpt.svc" to "http://B/wcfSendRpt.svc" like below

<endpoint address="http://B/wcfSendRpt.svc" 
	binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IwcfSendRpt"
        contract="nsSendRpt.IwcfSendRpt" name="BasicHttpBinding_IwcfSendRpt" /> 



但它不起作用。事件视图中的错误如下所示:


But it doesn''t work. The error from event view is like below,

 Unhandled Exception: System.ServiceModel.FaultException`1[System.ServiceModel.Ex
ceptionDetail]: An error occurred while executing the command definition. See th
e inner exception for details.

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message
 reply, MessageFault fault, String action, MessageVersion version, FaultConverte
r faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRunt
ime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at CAScheduledService.nsSendRpt.IwcfSendRpt.SendRpt(String statementdate)
   at CAScheduledService.Program.Main(String[] args)





我的控制台应用程序非常简单:代码如下所示



My console application is very simple: the code is like below

class Program
    {
        static void Main(string[] args)
        {
            nsSendRpt.IwcfSendRptClient ss = new IwcfSendRptClient();
            string a = ss.SendRpt(System.DateTime.Now.ToString("yyyyMMdd"));
            ss.Close();
        }
    }



我需要你的帮助来解决这个问题。我在wcf中很新。我的网络应用程序中的这个wcf服务是否安静?



非常感谢


I need your help to solve this. And I am pretty new in wcf. Is this wcf service in my web application is restful?

Thanks a lot

推荐答案

毕竟,我自己想通了。问题是表的列名与实时列不同。但没有追踪我就找不到问题了。所以我把它添加到配置文件

After all, I figured it by myself. The problem is that there is table''s column name different from the live one. But without tracing I can''t find the problem. So I add this to config file
<system.diagnostics>
    <sources>
      <source name="System.ServiceModel">
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
        <listeners>
             <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
            <add name="xml" />
        </listeners>
      </source>
      <source name="myUserTraceSource">
              switchValue="Information, ActivityTracing">
        <listeners>
            <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedlisteners>
        <add name="xml">
             type="System.Diagnostics.XmlWriterTraceListener"
             initializeData="Error.svclog" />
    </add></sharedlisteners>
  </system.diagnostics>


这篇关于控制台应用程序使用wcf服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆