.net 调用web service 错误

qgqchile 2018-03-14 04:34:06
各位 现用C# 调用一 WS, WS 在 SOAP UI 上测试通过,但用代码调用的时候总是有错误 提示Rejected by policy. (from client)
调用代码应该没有问题 同样的方法调用别的 WS 没什么问题 估计是安全问题,但用soap ui可以调用 把代码贴出来求高人帮下
谢谢

ServiceTGR.TransporteConsultasSoapClient obj = new ServiceTGR.TransporteConsultasSoapClient();
obj.ClientCredentials.UserName.UserName = "HEADER 用户名";
obj.ClientCredentials.UserName.Password = "HEADER 密码";
ServiceTGR.Patente objPatente = obj.consultaEstadoPatente("DA1282",2017); //异常 Rejected by policy. (from client)


多谢各位了
...全文
619 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qgqchile 2018-03-14
  • 打赏
  • 举报
回复
错误完整信息如下 An unhandled exception of type 'System.ServiceModel.FaultException' occurred in mscorlib.dll Additional information: Rejected by policy. (from client) System.ServiceModel.FaultException was unhandled HResult=-2146233087 Message=Rejected by policy. (from client) Source=mscorlib StackTrace: Server stack trace: en System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) en PruebaEnvioCorreo.ServiceTGR.TransporteConsultasSoap.consultaEstadoPatente(consultaEstadoPatenteRequest request) en PruebaEnvioCorreo.ServiceTGR.TransporteConsultasSoapClient.PruebaEnvioCorreo.ServiceTGR.TransporteConsultasSoap.consultaEstadoPatente(consultaEstadoPatenteRequest request) en D:\DesarrolloMTT\Mtt\Mtt.Sigis\PruebaEnvioCorreo\Service References\ServiceTGR\Reference.cs:línea 298 en PruebaEnvioCorreo.ServiceTGR.TransporteConsultasSoapClient.consultaEstadoPatente(String numPatente, Decimal yearTribu) en D:\DesarrolloMTT\Mtt\Mtt.Sigis\PruebaEnvioCorreo\Service References\ServiceTGR\Reference.cs:línea 306 en PruebaEnvioCorreo.Form1.btnPruebaTGR_Click(Object sender, EventArgs e) en D:\DesarrolloMTT\Mtt\Mtt.Sigis\PruebaEnvioCorreo\Form1.cs:línea 243 en System.Windows.Forms.Control.OnClick(EventArgs e) en System.Windows.Forms.Button.OnClick(EventArgs e) en System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) en System.Windows.Forms.Control.WndProc(Message& m) en System.Windows.Forms.ButtonBase.WndProc(Message& m) en System.Windows.Forms.Button.WndProc(Message& m) en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) en System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) en System.Windows.Forms.Application.Run(Form mainForm) en PruebaEnvioCorreo.Program.Main() en D:\DesarrolloMTT\Mtt\Mtt.Sigis\PruebaEnvioCorreo\Program.cs:línea 18 en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() en System.Threading.ThreadHelper.ThreadStart_Context(Object state) en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) en System.Threading.ThreadHelper.ThreadStart() InnerException:

12,166

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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