我需要使用Visual Studio和C#调用Web服务。我已经创建了一个配置文件和一个客户端来调用该服务,但我一直得到一个异常:
System.ServiceModel.FaultException'1:Oracle Connection未成功。
由于我没有真正使用ASP.NET应用程序和Web服务,我不知道如何解决这个问题,以及是由于我的错误还是因为创建的Web服务本身出了问题。
我已使用以下内容来调用该服务:
ServiceReference.InformationClient client = new ServiceReference.InformationClient();
client.GetInformation("123");
client.close();
GetInformation
是Web服务名称,输入参数ID类型为字符串,并返回用户名,姓氏和年龄的数据集。
这是堆栈跟踪:
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()
答案 0 :(得分:0)