- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 SoapExtension,用于记录所有 SOAP 请求和响应。对于来自使用 MS Soap Toolkit(OnBase 工作流)的应用程序的调用,它工作得很好。但它不适用于 html 页面上的 $.ajax() 调用。这是一个例子:
$.ajax({
type: "POST",
url: url,
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json"
});
它正在调用标有 WebService 和 ScriptService 属性的 ASP.NET 3.5 WebService:
[WebService(Namespace = XmlSerializationService.DefaultNamespace)]
[ScriptService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DepartmentAssigneeService : WebService
{
private readonly DepartmentAssigneeController _controller = new DepartmentAssigneeController();
/// <summary>
/// Fetches the role items.
/// </summary>
/// <returns></returns>
[WebMethod]
[SoapLog]
public ListItem[] FetchDepartmentItems()
{
return CreateListItems(_controller.FetchDepartments());
}
}
以下是 SoapExtension 和 SoapExtensionAttribute 的基础知识:
public class LoggingSoapExtension : SoapExtension, IDisposable { /*...*/ }
[AttributeUsage(AttributeTargets.Method)]
public sealed class SoapLogAttribute : SoapExtensionAttribute { /*...*/ }
我是否缺少一些允许 LoggingSoapExtension 在 $.ajax() 请求上执行的内容?
更新
@克里斯·布兰德斯玛
It might be because you are requesting Json results instead of XML via your web service (dataType: "json"). So the ScriptService attribute is being activated, but you are not sending SOAP messages.
这就解释了为什么 SoapExtension 不起作用。对于使用 ScriptService 进行跟踪有什么建议吗?唯一想到的是 ScriptService 基类,它提供了记录请求的方法。但随后我必须在每个 ScriptService WebService 的每个 WebMethod 中调用该方法(我有很多)。如果可能的话,我想使用像 SoapExtension 属性这样干净简单的东西。
最佳答案
我找到了解决方案。通过使用 IHttpModule,我可以记录来自任何内容(SOAP、JSON、表单等)的请求。在下面的实现中,我选择记录所有 .asmx 和 .ashx 请求。这替换了问题中的 LoggingSoapExtension。
public class ServiceLogModule : IHttpModule
{
private HttpApplication _application;
private bool _isWebService;
private int _requestId;
private string _actionUrl;
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
_application = context;
_application.BeginRequest += ContextBeginRequest;
_application.PreRequestHandlerExecute += ContextPreRequestHandlerExecute;
_application.PreSendRequestContent += ContextPreSendRequestContent;
}
#endregion
private void ContextPreRequestHandlerExecute(object sender, EventArgs e)
{
_application.Response.Filter = new CapturedStream(_application.Response.Filter,
_application.Response.ContentEncoding);
}
private void ContextBeginRequest(object sender, EventArgs e)
{
string ext = VirtualPathUtility.GetExtension(_application.Request.FilePath).ToLower();
_isWebService = ext == ".asmx" || ext == ".ashx";
if (_isWebService)
{
ITraceLog traceLog = TraceLogFactory.Create();
_actionUrl = _application.Request.Url.PathAndQuery;
StreamReader reader = new StreamReader(_application.Request.InputStream);
string message = reader.ReadToEnd();
_application.Request.InputStream.Position = 0;
_requestId = traceLog.LogRequest(_actionUrl, message);
}
}
private void ContextPreSendRequestContent(object sender, EventArgs e)
{
if (_isWebService)
{
CapturedStream stream = _application.Response.Filter as CapturedStream;
if (stream != null)
{
ITraceLog traceLog = TraceLogFactory.Create();
traceLog.LogResponse(_actionUrl, stream.StreamContent, _requestId);
}
}
}
}
关于asp.net - 如何跟踪 ScriptService WebService 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1020045/
WebService 依赖: org.springframework.boot spring-boot-starter-web-services org.apache.cxf cxf-rt-fr
我需要在我的项目中使用 Web 服务。我使用 NetBeans,因此右键单击我的项目并尝试添加新的“Web 服务客户端”。上次我检查过,这是创建 Web 服务客户端的方法。但它导致了一个断言错误,说:
我在 Netbeans 中创建了两个 Java SOAP Web 服务。基本上每个服务都是一个不同的 Web 应用程序,有自己的 war 文件。我从 Java 客户端调用第一个 WS,并从第一个服务调
有没有一种有效的工具可以将 .Net C# webservice 转换为 java webservice。是否有任何开源工具可以提供帮助? 最佳答案 不要浪费时间寻找过渡工具。如果您使用的是 Java
情况是这样的。我从某人那里收到了由 Apache/Tomcat 服务器 (Java) 生成的 WSDL(包括 XSD)。我为其做一个项目的公司更喜欢 .NET,因此我使用 wsdl.exe 生成部分类
我正在使用 java 开发 axis2 网络服务,用于将记录插入数据库。我正在测试 web 服务客户端,它返回空响应代码,实际上我在 web 服务中返回整数值但我成功地将记录插入数据库,我可以在执行客
您好,我正在尝试使用 json 在钛中调用 webService。该 webService 不接受任何参数,所以我只需要调用它。 这是我的代码: var xhr = Titanium.Network.
我正在尝试将基本的Web服务模板部署到tomee,我尝试了Windows 7 64位和Windows 8 64位以及java版本1.8.0_25(64位),1.8.0_91(64位)(此java版本用
我正在尝试使用包含 web 服务参数的 get 方法调用 web 服务。但我无法在互联网上找到答案,请任何人帮助我。下面给出我的网络服务 http://api.crmseries.com/user/V
调用 Web 服务时出现以下抛出错误。除了人们问同样的问题外,用谷歌搜索没有任何结果。 Server was unable to process request. ---> The surrogate
我正在尝试使用 Yahoo 查询语言找到一种通过 Yahoo Weather 获取一些天气信息的方法。 因为我住在法国的一个叫尼斯的城市,下面的查询返回一个错误: select * from weat
我需要知道是否可以从后台调用 json webservices,当用户按下主页按钮时,我从后台执行调用此方法 - (void) runTimer { [NSThread detachNewTh
我有一个 Web 服务,它位于这样的反向代理后面: 现在发生的情况是,当我尝试添加 Web 引用来测试 Web 服务时,它说无法下载 wsdl 文件。那是因为当请求被发送时它是 https://uat
我需要创建一个Web服务,该服务用于通过输入一个字符串ID从服务器下载音频(wav)文件。如果服务器上不存在音频文件,则需要以json格式发送错误回传。 现在的问题是-如何为下载文件提供扩展名。我不知
我编写了一个 C# WebService。问题是,在我将其发布到 IIS 后,除非调用其任何方法,否则它不会自动启动。这是非常令人沮丧的,因为这个 WebService 必须在启动(其构造函数执行)后
simple spring example demoServiceImpl org.apache.axis2.extensions.spring.
我使用 reSTLet 为我的应用程序构建了 Java Web 服务。它是纯 Java 且独立的。有没有免费的云服务可以托管我的网络服务? 它的要求确实很低。其中之一是静态 IP。 最佳答案 使用 j
我正在研究基于 SOAP 的 Web 服务。我需要测试一个场景,如果由于任何网络问题或登录问题而发生 Web 服务连接错误。 apache cxf 的问题是无论 web 服务抛出什么异常 "java
如何在没有datamapper的情况下在mule中调用soap webservice并且输入是xml。我正在使用社区添加。 & 我的输入是 xml 而不是肥皂信封。 我的 wsdl 位置是 - htt
我知道 php webservice SOAP、json、rest 等,但我是 java webservice 的新手。现在我想让 php 客户端连接到 java webservice。最好的方法是什
我是一名优秀的程序员,十分优秀!