zoukankan      html  css  js  c++  java
  • web服务相关的问题或技巧

    1.wcf怎么记录详细错误日志?

    调用wcf时日志记录如下:

    System.ServiceModel.FaultException: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

    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.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最上层方法名称

    at最上层方法路径

    这些提示不能准确的判断出是哪里出了问题

    解决办法是修改下wcf站点的配置文件

        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
    

    includeExceptionDetailInFaults="true",可以返回错误详情

    2.webservice中wse加密

    调用webservice时出错信息:

    System.Web.Services.Protocols.SoapHeaderException: Header http://schemas.xmlsoap.org/ws/2004/08/addressing:Action for ultimate recipient is required but not present in the message. 在 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) 

    原因是webservice加密了,调用时需要传token

    2.1 Install-Package Microsoft.Web.Services3

    2.2 public partial class WebService : System.Web.Services.Protocols.SoapHttpClientProtocol

    修改为public partial class WebService : WebServicesClientProtocol

    2.3代码示例:

            private static void Main(string[] args)
            {
                WebService webService = new WebService();
                UsernameToken token = new UsernameToken("testaccount", "123456", PasswordOption.SendNone);
                webService.RequestSoapContext.Security.Tokens.Add(token);
                string[] ret = webService.GetAccountInfo("000");            
                Console.ReadKey();
            }
  • 相关阅读:
    使用LR编写windows sockets协议xml报文格式脚本实战
    使用LR编写HTTP协议Json报文格式接口脚本实战
    web类协议脚本-飞机订票系统示例
    使用LR编写下载类脚本
    python算法-选择排序
    python算法-冒泡排序
    用户在浏览器中输入一个url发生的奥秘
    浅谈cookie和session
    selenium加载配置参数,让chrome浏览器不出现‘Chrome正在受到自动软件的控制’的提示语,以及后台静默模式启动自动化测试,不占用桌面的方法
    Python之文件和目录操作
  • 原文地址:https://www.cnblogs.com/doujiaomifan/p/3986153.html
Copyright © 2011-2022 走看看