Tag: asmx

有没有办法从ASP.NET WebMethod中获取原始SOAP请求?

例: public class Service1 : System.Web.Services.WebService { [WebMethod] public int Add(int x, int y) { string request = getRawSOAPRequest();//How could you implement this part? //.. do something with complete soap request int sum = x + y; return sum; } }

inheritance的属性不会出现在asmx文件的soap示例中

我有两个类,WebServiceRequest和OrderRequest。 每个类都有属性。 OrderRequestinheritance自WebServiceRequest – 如下所示: public class WebServiceRequest { private string mAuthenticationToken; public string AuthenticationToken { get { return mAuthenticationToken; } set { mAuthenticationToken = value; } } … } public class OrderRequest : WebServiceRequest { private string mVendorId; public string VendorId { get { return mVendorId; } set { mVendorId = value; } } […]

“在此上下文中不允许异步操作”

我在调用他自动生成的异步webmethods时会得到以下exception,我在这篇文章中询问过 在此上下文中不允许异步操作。 启动异步操作的页面必须将Async属性设置为true,并且只能在之前的页面上启动异步操作 Google搜索结果在页面指令中添加了Async = True ,但是不同的人都注意到这会使页面“阻塞” (这不是真正的异步操作)。 那么我如何在调用webservice方法时实现异步操作。

在运行时设置服务URL

当我添加“Web引用”时,我们将asmx页面的地址提供给visual studio。 我怎样才能在运行时设置它?

拦截来自客户端的Web服务的SOAP消息

我有一个与Web服务通信的客户端。 我与之通信的类是通过wsdl.exe生成的C#类。 我现在想记录所有传入和传出的消息。 到目前为止我所做的是编写一个inheritance自动生成的C#类的类,并重写了GetReaderForMessage方法。 这样我可以或多或少地像这样访问传入的消息: protected override XmlReader GetReaderForMessage(SoapClientMessage message, int bufferSize) { System.Xml.XmlReader aReader = base.GetReaderForMessage(message, bufferSize); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(aReader); string content = doc.InnerXml.ToString(); System.Xml.XmlReader aReader2 = System.Xml.XmlReader.Create(new System.IO.StringReader(content)); return aReader2; } 显然我对这个解决方案不太满意,因为基本上我正在创建两个xml读者。 一个用于读取SOAP消息的内容,另一个用于返回方法调用方。 另外,我不能用GetWriterForMessage方法做同样的事情。 但可能我只是做起来太困难了。 例如,是否可以直接读取SoapClientMessage对象的内容? 我已经阅读了一些文章,建议我应该在这里使用SoapExtensions,但是从我能理解的情况来看,这只有在我创建的’客户端’本身就是一个Web服务时才会起作用,在这种情况下它不是。 有什么建议?

将ASMX转换为WCF Web服务需要多少工作量?

我有2个Web服务,共有大约6个Web方法,大多数代码都是以任何方式放在程序集中,而web服务asmx实际上只是调用这些程序集方法并返回它们的返回类型。 将Web服务从ASMX转换为WCF需要付出多少努力? 我几乎在这个阶段控制着唯一的 – 连接到Web服务的非基于Web的客户端,所以这不是一个真正的问题,产品在预启动。

应修改哪些内容以更改C#中的Web服务的URL?

我有一个问题,就在不久前我通过复制所有生成的代码(复制粘贴.cs内容的文本)将Webservice代理类添加到我的应用程序中。 它奏效了! 但现在我需要更改此Web服务代理类使用的URL,我不确定代码中的更改内容和位置。 我很感激,如果你能给我一个线索,可以指导我找到合适的地方,以便我可以更新网络服务的url。

为什么静态方法不能用作ASMX Web服务中的Web服务操作?

我只是想知道为什么我不能在Web服务中使用静态Web方法? 为什么限制? 有些遗体可以给我简明扼要的解释。

Asmx web服务如何返回JSON而不是XML?

我的服务方式: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string getDataFromTrainingMaster() { List results = new DAL().GetDataFromTrainingMaster(); JavaScriptSerializer js = new JavaScriptSerializer(); return js.Serialize(results).ToString(); } 我的.net Web服务返回包含在XML中的JSON,如下所示: [{“Training_Code”:”1234 “,”Training_Duration”:”2hrs “,”Training_Startdate”:”2/14/2013 3:00:00 PM”,”Training_Enddate”:”2/14/2013 5:00:00 PM”,”Trainer_ID”:1,”Training_Location”:”B-Wing Training room-4″,”Comments”:”C# training”,”Keyword”:”C#1234″,”NumberofDays”:1},{“Training_Code”:”4321 “,”Training_Duration”:”16 “,”Training_Startdate”:”2/17/2013 10:30:00 AM”,”Training_Enddate”:”2/17/2013 5:30:00 PM”,”Trainer_ID”:2,”Training_Location”:”A-Wing Training Room-6″,”Comments”:”Objective-C”,”Keyword”:”Obj-C4321″,”NumberofDays”:2}] 我需要它采用以下格式: “Training”:[{“Training_Code”:”1234 “,”Training_Duration”:”2hrs “,”Training_Startdate”:”2/14/2013 3:00:00 PM”,”Training_Enddate”:”2/14/2013 5:00:00 PM”,”Trainer_ID”:1,”Training_Location”:”B-Wing Training room-4″,”Comments”:”C# training”,”Keyword”:”C#1234″,”NumberofDays”:1},{“Training_Code”:”4321 “,”Training_Duration”:”16 “,”Training_Startdate”:”2/17/2013 […]

如何从3.5 asmx Web服务获取JSON响应

我有以下方法: using System.Web.Services; using System.Web.Script.Services; using System.Web.Script.Serialization; using Newtonsoft.Json; using System.Collections; [WebService(Namespace = “http://tempuri.org/”)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] //[System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] // [System.Web.Script.Services.ScriptService] public class Tripadvisor : System.Web.Services.WebService { public Tripadvisor () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string HotelAvailability(string api) { JavaScriptSerializer js = new JavaScriptSerializer(); […]