Tag: web services

.NET Core中的SOAP?

你如何在.NET Core中使用SOAP? .Net Core中是否有Apache CXF的等价物(不只是简单的SOAP客户端,而是全function堆栈)? 对不起,如果这是一个非常基本的问题,到目前为止,我的搜索没有给出任何明确的答案。

使用.NET framework 3.5在C#中调用Web API

我试图找到最近的商店给出一个邮政编码。 我开始知道yelp和foursquare提供了执行此操作所需的API。 我使用的是.NET 3.5框架。 你如何制作http请求并处理响应。网上的大部分解决方案都为.NET 4.5以上提供了包括HTTPClient类的使用。

具有可选参数的Web服务方法

可能重复: 我是否可以为ASP.NET SOAP Web服务提供可选参数 我试过四处寻找,但我真的找不到合适的解决方案。 很抱歉重复,因为我知道之前有人问过这个问题。 我有一个Web服务方法,我想在其中有一个可选参数,例如: public void MyMethod(int a, int b, int c = -3) 我已经知道我不能使用可空参数,所以我只想尝试使用默认值。 问题是,当我调用此方法而不提供参数时,c仍然会获得exception。 有什么地方我必须指定它实际上是可选的吗? Thanksю

如何访问SOAP响应

(如果有任何需要澄清/更多细节请告诉我。) 我有一个应用程序(C#,2. *框架),它使用SOAP与第三方Web服务连接。 我使用thinktecture的WSCF加载项来提供WSDL来创建客户端实现。 由于我无法控制的原因,SOAP消息交换使用WSE2.0来实现安全性(必须修改thinctecture实现以包含WSE2.0引用)。 除了“普通”数据包之外,我还将先前调用的存储X509证书和二进制安全令牌附加到其他Web服务。 我们正在使用某种SSL加密 – 我不知道细节。 所有必要的序列化/反序列化都包含在Web服务客户端中 – 这意味着在调用客户端之后将控制权返回给我时,SOAP响应中包含的整个XML字符串对我来说是不可用的 – 只是反序列化的组件。 不要误解我的意思 – 我认为这很好,因为这意味着我不必自己做。 但是,为了让我有值得存储/存档的东西,我不得不在根元素处重新序列化数据。 这似乎是浪费资源,因为我的结果是在SOAP响应中。 现在我的问题是:如何访问SOAP响应的“清晰”版本,以便我不必重新序列化存储/存档的所有内容? 编辑 – 我的应用程序是一个“无形”的Windows应用程序,作为网络服务运行 – 由WebsphereMQ客户端触发器监视器触发。 我不认为 ASP.NET解决方案会适用。 编辑 – 由于到目前为止的共识是,我的应用程序是否是ASP.NET无关紧要,然后我将给CodeMelt(以及扩展Chris的)解决方案一个镜头。

使用自定义ClientCredentials的WCF身份validation:要使用的clientCredentialType是什么?

我不得不放弃基本的WCF UserName / Pwd安全性并实现我自己的自定义客户端凭据,以保留超出默认提供的更多信息。 我参与了这篇MSDN文章 ,但我遗漏了一些东西,因为它不起作用。 首先,我有一些自定义ClientCredentials,它们提供自定义ClientCredentialsSecurityTokenManager: public class CentralAuthCredentials : ClientCredentials { public override System.IdentityModel.Selectors.SecurityTokenManager CreateSecurityTokenManager() { return new CentralAuthTokenManager(this); } } public class CentralAuthTokenManager : ClientCredentialsSecurityTokenManager { private CentralAuthCredentials credentials; public CentralAuthTokenManager(CentralAuthCredentials creds) : base(creds) { this.credentials = creds; } public override SecurityTokenProvider CreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement) { if (this.IsIssuedSecurityTokenRequirement(tokenRequirement) || tokenRequirement.TokenType == CentralAuthToken.TOKEN_TYPE) return […]

如何使用C#发送/接收SOAP请求和响应?

private static string WebServiceCall(string methodName) { WebRequest webRequest = WebRequest.Create(“http://localhost/AccountSvc/DataInquiry.asmx”); HttpWebRequest httpRequest = (HttpWebRequest)webRequest; httpRequest.Method = “POST”; httpRequest.ContentType = “text/xml; charset=utf-8”; httpRequest.Headers.Add(“SOAPAction: http://tempuri.org/” + methodName); httpRequest.ProtocolVersion = HttpVersion.Version11; httpRequest.Credentials = CredentialCache.DefaultCredentials; Stream requestStream = httpRequest.GetRequestStream(); //Create Stream and Complete Request StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.ASCII); StringBuilder soapRequest = new StringBuilder(“”); soapRequest.Append(“Sam”); soapRequest.Append(“”); streamWriter.Write(soapRequest.ToString()); streamWriter.Close(); […]

HttpClient和Windows Auth:将用户的消费者登录到服务

我正在努力理解并建立一个服务和消费者,服务将在用户登录消费者时运行。 我的消费者是一个MVC应用程序。 我的服务是一个Web Api应用程序。 两者都在同一域内的不同服务器上运行。 两者都设置为使用Windows身份validation。 我的消费者代码是: private T GenericGet(string p) { T result = default(T); HttpClientHandler handler = new HttpClientHandler() { PreAuthenticate = true, UseDefaultCredentials = true }; using (HttpClient client = new HttpClient(handler)) { client.BaseAddress = new Uri(serviceEndPoint); HttpResponseMessage response = client.GetAsync(p).Result; if (response.IsSuccessStatusCode) result = response.Content.ReadAsAsync().Result; } return result; } 在我的服务中,我调用User.Identity.Name来获取调用者ID,但这总是作为消费者应用程序池ID返回,而不是登录用户。 消费者应用程序池作为网络服务运行,服务器本身受信任以进行委派。 […]

使用REST XML Web服务

我正在尝试使用以下Web服务http://ipinfodb.com/ip_location_api.php此Web服务返回xml响应,下面的代码获取XML响应,但不知何故,当从XML响应中定相值时,它不会工作。 我的代码出了什么问题? using System; using System.Collections.Generic; using System.Text; using System.Web; using System.IO; using System.Net; using System.Xml; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { HttpWebRequest request = null; HttpWebResponse response = null; String Xml; // Create the web request request = WebRequest.Create(“http://api.ipinfodb.com/v2/ip_query.php?key=&ip=74.125.45.100&timezone=true”) as HttpWebRequest; // Get response using (response = request.GetResponse() as […]

如何从Web服务获取通知到ASP.NET MVC视图

任务: 将一些数据添加到数据库 – 大约5分钟 向客户端发送通知“添加到数据库的数据” 过程数据 – 大约15分钟 向客户发送通知“数据已处理” 在代码中: ASMX Web服务 [SoapDocumentMethod(OneWay = true)] [WebMethod] public void AddAndProcess(DataSet _DataToProcess) { //inserts data to DB SendNotification(“Data added to database”); ProcessData(_DataToProcess); } [SoapDocumentMethod(OneWay = true)] [WebMethod] public void ProcessData(DataSet _DataToProcess) { //Process data SendNotification(“The data is processed”); } public void SendNotification(string NotificationMessage) { //do something to […]

C#SpeechSynthesizer使服务无响应

我有以下代码 [WebMethod] public byte[] stringToWav(string text) { SpeechSynthesizer ss = new SpeechSynthesizer(); MemoryStream ms = new MemoryStream(); ss.SetOutputToWaveStream(ms); ss.Speak(text); return ms.ToArray(); } 并且该服务什么都不返回。 知道为什么会这样吗?