【问题标题】:Consuming a web service using Visual Studio 10 and C#使用 Visual Studio 10 和 C# 使用 Web 服务
【发布时间】:2015-07-19 14:08:42
【问题描述】:

我需要使用 Visual Studio 和 C# 调用 Web 服务。我已经创建了一个配置文件和一个客户端来调用该服务,但我不断收到异常:

System.ServiceModel.FaultException'1:Oracle 连接不成功。

由于我没有真正使用过 ASP.NET 应用程序和 Web 服务,因此我不确定如何解决这个问题,以及这是由于我的错误还是因为创建的 Web 服务本身有问题。

我使用了以下调用服务:

ServiceReference.InformationClient client = new ServiceReference.InformationClient();
client.GetInformation("123");
client.close();

GetInformation为Web Service Name,输入参数ID为string类型,返回用户名、姓氏、年龄的数据集。

这是堆栈跟踪:

System.ServiceModel.FaultException`1 was unhandled
Message=Oracle Connection is not successful
Source=mscorlib
StackTrace:
Server stack trace: 
   at   System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ConsumingWebService.ServiceReference.IInformation.GetInformation(String ID)
   at ConsumingWebService.ServiceReference.InformationClient.GetInformation(String ID) in c:\users\user\documents\visual studio 2010\Projects\ConsumingWebService\ConsumingWebService\Service References\ServiceReference\Reference.cs:line 53
   at ConsumingWebService.Program.Main(String[] args) in c:\users\user\documents\visual studio 2010\Projects\ConsumingWebService\ConsumingWebService\Program.cs:line 13
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

【问题讨论】:

  • 你能粘贴错误的完整堆栈跟踪吗?
  • 我编辑添加了错误的完整堆栈跟踪。希望对您有所帮助。
  • 您是否尝试过调试您的服务并在您的 GetInformation 方法中放置一些断点?尝试在您的视觉工作室中将流程附加到 w3wp。您的代码中可能会出现关于连接到 Oracle 数据库的问题。
  • 问题是我无法访问 Web 服务方法,因为它是由另一位同事为我创建的。

标签: c# asp.net web-services wcf wsdl


【解决方案1】:

FaultException

WCF 世界中的 FaultExceptions 用作跨 WCF 通道传达服务器错误/异常的方法。

在您的情况下,您尝试使用的 Web 服务似乎在连接到所需数据库时出现问题。

【讨论】:

  • 我不确定这是否告诉我们任何我们不知道的事情,也不知道如何解决它
  • 这是服务器端错误。由于只能访问客户端,除了处理异常之外,我们无能为力。
  • 是的,我是这么认为的。不幸的是,我无权访问服务器端。
猜你喜欢
  • 1970-01-01
  • 2015-12-01
  • 2012-04-14
  • 2013-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多