{"id":15637085,"url":"https://github.com/pmorelli92/soaphttpclient","last_synced_at":"2025-04-14T12:50:51.491Z","repository":{"id":9365803,"uuid":"60784895","full_name":"pmorelli92/SoapHttpClient","owner":"pmorelli92","description":"HttpClient wrapper for sending SOAP messages.","archived":false,"fork":false,"pushed_at":"2022-03-14T21:43:50.000Z","size":144,"stargazers_count":115,"open_issues_count":3,"forks_count":22,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-12T07:39:42.808Z","etag":null,"topics":["async","client","http","soap","wrapper"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmorelli92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-09T15:20:54.000Z","updated_at":"2024-12-22T14:01:32.000Z","dependencies_parsed_at":"2022-08-25T12:40:42.490Z","dependency_job_id":null,"html_url":"https://github.com/pmorelli92/SoapHttpClient","commit_stats":null,"previous_names":["pmorelli92/soapclient"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorelli92%2FSoapHttpClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorelli92%2FSoapHttpClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorelli92%2FSoapHttpClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmorelli92%2FSoapHttpClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmorelli92","download_url":"https://codeload.github.com/pmorelli92/SoapHttpClient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248884682,"owners_count":21177467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","client","http","soap","wrapper"],"created_at":"2024-10-03T11:09:52.898Z","updated_at":"2025-04-14T12:50:51.461Z","avatar_url":"https://github.com/pmorelli92.png","language":"C#","readme":"# SoapHttpClient  [![NuGet](https://img.shields.io/nuget/v/SoapHttpClient.svg)](https://www.nuget.org/packages/SoapHttpClient)\n\n\u003e A lightweight wrapper of an `HttpClient` (using `IHttpClientFactory`) for POSTing messages that allows the user to send the SOAP Body and Header (if needed) without caring about the envelope.\n\n## Changelog\n\n### 3.0.0\n- Replaced HttpClient with HttpClientFactory.\n\n### 2.2.1\n- Added support for Cancellation Tokens.\n\n### 2.2.0\n- Updated codebase.\n- Migrated test project to .net core app.\n- Fixed an error of SOAPAction not being sent.\n\n### 2.1.0\n- Updated to NetStandardLibrary 2.0\n-  Fixed a bug where an extension method was calling himself recursively\n\n### 2.0.0\n- Major refactor to the codebase.\n- Added the functionality of adding more than one header and/or body in the envelope.\n- The ctor will no longer determine the SoapVersion, since it is a message property and the API should be ignorant about this.\n- **[BREAKING CHANGE]: SoapVersion is now required for every message.**\n- **[BREAKING CHANGE]: Removed methods where the endpoint was a string instead of an uri.**\n\n## API\n\n### Constructors\n\n```csharp\nSoapClient()\n```\n\nInitializes `SoapClient` with a default `IHttpClientFactory` that implements automatic decompression.\n\n```csharp\nSoapClient(IHttpClientFactory httpClientFactory)\n```\n\nInitializes `SoapClient` with a `IHttpClientFactory` provided by the caller.\nThe `IHttpClientFactory` is the new interface used to manage HttpClient introduced on .NET Core 2.1.\n\n------------------\n\n### Methods\n\n\u003e All **Methods** and **Extension Methods** returns a Task of [`HttpResponseMessage`][msdn-httpresponsemessage]\n\nThe interface makes the client implement the following method:\n\n```csharp\nTask\u003cHttpResponseMessage\u003e PostAsync(\n\tUri endpoint,\n\tSoapVersion soapVersion,\n\tIEnumerable\u003cXElement\u003e bodies,\n\tIEnumerable\u003cXElement\u003e headers = null,\n\tstring? action = null,\n\tCancellationToken cancellationToken = CancellationToken.Default);\n```\n\nAllowing us to send the following calls:\n\n- Uri / Version / Bodies\n- Uri / Version / Bodies / Headers\n- Uri / Version / Bodies / Headers / Action\n\n------------------\n\nThen there are sugar sintax extension methods:\n\n```csharp\nTask\u003cHttpResponseMessage\u003e PostAsync(\n\tthis ISoapClient client,\n\tUri endpoint,\n\tSoapVersion soapVersion,\n\tXElement body,\n\tXElement header = null,\n\tstring? action = null,\n\tCancellationToken cancellationToken = CancellationToken.Default);\n\nTask\u003cHttpResponseMessage\u003e PostAsync(\n\tthis ISoapClient client,\n\tUri endpoint,\n\tSoapVersion soapVersion,\n\tIEnumerable\u003cXElement\u003e bodies,\n\tXElement header,\n\tstring? action = null,\n\tCancellationToken cancellationToken = CancellationToken.Default);\n\nTask\u003cHttpResponseMessage\u003e PostAsync(\n\tthis ISoapClient client,\n\tUri endpoint,\n\tSoapVersion soapVersion,\n\tXElement body,\n\tIEnumerable\u003cXElement\u003e headers,\n\tstring? action = null,\n\tCancellationToken cancellationToken = CancellationToken.Default);\n```\n\nAllowing us to send the following calls:\n\n- Uri / Version / Body\n- Uri / Version / Body / Header\n- Uri / Version / Body / Header / Action\n- Uri / Version / Bodies / Header\n- Uri / Version / Bodies / Header / Action\n- Uri / Version / Body / Headers\n- Uri / Version / Body / Headers / Action\n\n------------------\n\nWith all of these variants we can send a message with:\n\n- 1 Body - 1 Header\n- 1 Body - N Headers\n- N Bodies - 1 Header\n- N Bodies - N Headers\n\n------------------\n\nThere are also extension methods for sync calls:\n**However we always recommend using async programming when you are able**.\n\n\u003e Their method name is **Post** and their return type is [`HttpResponseMessage`][msdn-httpresponsemessage]\n\nFinally, we have extensions methods for using bodies and headers as objects and using serialization the default or a custom `IXElementSerializer` to serialize those objects to XElement.\n\n## Usage Examples\n\n### Controlling the Media Type\n\nAs the `SoapHttpClient` wraps a `HttpClient` you can control all aspects of the HTTP Request using a `HttpMessageHandler`:\n\n```csharp\npublic class ContentTypeChangingHandler : DelegatingHandler\n{\n  public ContentTypeChangingHandler(HttpMessageHandler innerHandler) : base(innerHandler) { }\n\n  protected async override Task\u003cHttpResponseMessage\u003e SendAsync(\n    HttpRequestMessage request,\n    CancellationToken cancellationToken)\n  {\n    request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(\"text/xml; charset=utf-8\");\n    return await base.SendAsync(request, cancellationToken);\n  }\n}\n```\n\n### Call NASA\n\n```csharp\nasync Task CallNasaAsync()\n{\n    var soapClient = new SoapClient();\n    var ns = XNamespace.Get(\"http://helio.spdf.gsfc.nasa.gov/\");\n\n    var result =\n        await soapClient.PostAsync(\n            new Uri(\"http://sscweb.gsfc.nasa.gov:80/WS/helio/1/HeliocentricTrajectoriesService\"),\n            SoapVersion.Soap11,\n            body: new XElement(ns.GetName(\"getAllObjects\")));\n\n    result.StatusCode.Should().Be(HttpStatusCode.OK);\n}\n```\n\n#### Result of Calling NASA Heliocentric Trajectories Service\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cS:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"\u003e\n   \u003cS:Body\u003e\n      \u003cns2:getAllObjectsResponse xmlns:ns2=\"http://helio.spdf.gsfc.nasa.gov/\"\u003e\n         \u003creturn\u003e\n            \u003cendDate\u003e1993-01-01T00:00:00Z\u003c/endDate\u003e\n            \u003cid\u003e0001\u003c/id\u003e\n            \u003cname\u003eCOMET GRIGG-SKJLP\u003c/name\u003e\n            \u003cstartDate\u003e1992-01-01T00:00:00Z\u003c/startDate\u003e\n         \u003c/return\u003e\n         \u003creturn\u003e\n            \u003cendDate\u003e1996-03-02T00:00:00Z\u003c/endDate\u003e\n            \u003cid\u003e0002\u003c/id\u003e\n            \u003cname\u003eCOMET H-M-P\u003c/name\u003e\n            \u003cstartDate\u003e1996-01-01T00:00:00Z\u003c/startDate\u003e\n         \u003c/return\u003e\n         \u003creturn\u003e\n            \u003cendDate\u003e1997-12-31T00:00:00Z\u003c/endDate\u003e\n            \u003cid\u003e0003\u003c/id\u003e\n            \u003cname\u003eCOMET HALE-BOPP\u003c/name\u003e\n            \u003cstartDate\u003e1997-01-01T00:00:00Z\u003c/startDate\u003e\n         \u003c/return\u003e\n         .\n         .\n         .\n      \u003c/ns2:getAllObjectsResponse\u003e\n   \u003c/S:Body\u003e\n\u003c/S:Envelope\u003e\n```\n\n[Soap Icon][nounproj-soap] Created by Jakob Vogel from the Noun Project\n\n[msdn-httpresponsemessage]: https://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage(v=vs.118).aspx\n[nounproj-soap]: https://thenounproject.com/icon/44504/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmorelli92%2Fsoaphttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmorelli92%2Fsoaphttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmorelli92%2Fsoaphttpclient/lists"}