All Projects → pmorelli92 → SoapHttpClient

pmorelli92 / SoapHttpClient

Licence: GPL-3.0 license
HttpClient wrapper for sending SOAP messages.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to SoapHttpClient

atomix
Simple and easy wrappers for Go sync/atomic package.
Stars: ✭ 26 (-67.5%)
Mutual labels:  wrapper
alpine-shellcheck
Docker image for Alpine Linux with latest ShellCheck, a static analysis tool for shell scripts.
Stars: ✭ 12 (-85%)
Mutual labels:  wrapper
cablecuttr
An R wrapper for CanIStream.It API
Stars: ✭ 17 (-78.75%)
Mutual labels:  wrapper
RxCamera2
Rx Java 2 wrapper for Camera2 google API
Stars: ✭ 27 (-66.25%)
Mutual labels:  wrapper
Pyblox
An API wrapper for Roblox written in Python. (Receives Updates)
Stars: ✭ 30 (-62.5%)
Mutual labels:  wrapper
voxpopuli
Python wrapper for Espeak and Mbrola, for simple local TTS
Stars: ✭ 21 (-73.75%)
Mutual labels:  wrapper
dinputto8
A dll module that is designed to improve compatibility in games using DirectInput 1-7 (dinput.dll) by converting all API calls to their equivalent DirectInput 8 (dinput8.dll) ones. This allows older games to be able to use newer tools and wrappers written for DirectInput 8.
Stars: ✭ 42 (-47.5%)
Mutual labels:  wrapper
snow-ctp
Node CTP Wrapper
Stars: ✭ 15 (-81.25%)
Mutual labels:  wrapper
material-yew
Yew wrapper for Material Web Components
Stars: ✭ 116 (+45%)
Mutual labels:  wrapper
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-61.25%)
Mutual labels:  wrapper
ftx-api-wrapper-python3
FTX Exchange API wrapper in python3
Stars: ✭ 31 (-61.25%)
Mutual labels:  wrapper
pbwrap
Pastebin API wrapper for Python
Stars: ✭ 19 (-76.25%)
Mutual labels:  wrapper
xsdata
Naive XML & JSON Bindings for python
Stars: ✭ 144 (+80%)
Mutual labels:  soap
discord.bat
🗑️ the BEST discord lib
Stars: ✭ 38 (-52.5%)
Mutual labels:  wrapper
eet-client
Client and library for #EET communication - http://www.etrzby.cz/ , written in Java
Stars: ✭ 49 (-38.75%)
Mutual labels:  soap
A-song-of-ice-and-fire-API
Javascript wrapper for the A song of ice and fire API
Stars: ✭ 15 (-81.25%)
Mutual labels:  wrapper
hypixel-api-reborn
Feature-rich Hypixel API wrapper for Node.js
Stars: ✭ 80 (+0%)
Mutual labels:  wrapper
python-makefun
Dynamically create python functions with a proper signature.
Stars: ✭ 62 (-22.5%)
Mutual labels:  wrapper
hcloud-js
A Node.js module for the Hetzner Cloud API
Stars: ✭ 40 (-50%)
Mutual labels:  wrapper
GodotDiscordSDK
A Discord Game SDK wrapper for Godot, written in C.
Stars: ✭ 40 (-50%)
Mutual labels:  wrapper

SoapHttpClient NuGet

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.

Changelog

3.0.0

  • Replaced HttpClient with HttpClientFactory.

2.2.1

  • Added support for Cancellation Tokens.

2.2.0

  • Updated codebase.
  • Migrated test project to .net core app.
  • Fixed an error of SOAPAction not being sent.

2.1.0

  • Updated to NetStandardLibrary 2.0
  • Fixed a bug where an extension method was calling himself recursively

2.0.0

  • Major refactor to the codebase.
  • Added the functionality of adding more than one header and/or body in the envelope.
  • The ctor will no longer determine the SoapVersion, since it is a message property and the API should be ignorant about this.
  • [BREAKING CHANGE]: SoapVersion is now required for every message.
  • [BREAKING CHANGE]: Removed methods where the endpoint was a string instead of an uri.

API

Constructors

SoapClient()

Initializes SoapClient with a default IHttpClientFactory that implements automatic decompression.

SoapClient(IHttpClientFactory httpClientFactory)

Initializes SoapClient with a IHttpClientFactory provided by the caller. The IHttpClientFactory is the new interface used to manage HttpClient introduced on .NET Core 2.1.


Methods

All Methods and Extension Methods returns a Task of HttpResponseMessage

The interface makes the client implement the following method:

Task<HttpResponseMessage> PostAsync(
	Uri endpoint,
	SoapVersion soapVersion,
	IEnumerable<XElement> bodies,
	IEnumerable<XElement> headers = null,
	string? action = null,
	CancellationToken cancellationToken = CancellationToken.Default);

Allowing us to send the following calls:

  • Uri / Version / Bodies
  • Uri / Version / Bodies / Headers
  • Uri / Version / Bodies / Headers / Action

Then there are sugar sintax extension methods:

Task<HttpResponseMessage> PostAsync(
	this ISoapClient client,
	Uri endpoint,
	SoapVersion soapVersion,
	XElement body,
	XElement header = null,
	string? action = null,
	CancellationToken cancellationToken = CancellationToken.Default);

Task<HttpResponseMessage> PostAsync(
	this ISoapClient client,
	Uri endpoint,
	SoapVersion soapVersion,
	IEnumerable<XElement> bodies,
	XElement header,
	string? action = null,
	CancellationToken cancellationToken = CancellationToken.Default);

Task<HttpResponseMessage> PostAsync(
	this ISoapClient client,
	Uri endpoint,
	SoapVersion soapVersion,
	XElement body,
	IEnumerable<XElement> headers,
	string? action = null,
	CancellationToken cancellationToken = CancellationToken.Default);

Allowing us to send the following calls:

  • Uri / Version / Body
  • Uri / Version / Body / Header
  • Uri / Version / Body / Header / Action
  • Uri / Version / Bodies / Header
  • Uri / Version / Bodies / Header / Action
  • Uri / Version / Body / Headers
  • Uri / Version / Body / Headers / Action

With all of these variants we can send a message with:

  • 1 Body - 1 Header
  • 1 Body - N Headers
  • N Bodies - 1 Header
  • N Bodies - N Headers

There are also extension methods for sync calls: However we always recommend using async programming when you are able.

Their method name is Post and their return type is HttpResponseMessage

Finally, 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.

Usage Examples

Controlling the Media Type

As the SoapHttpClient wraps a HttpClient you can control all aspects of the HTTP Request using a HttpMessageHandler:

public class ContentTypeChangingHandler : DelegatingHandler
{
  public ContentTypeChangingHandler(HttpMessageHandler innerHandler) : base(innerHandler) { }

  protected async override Task<HttpResponseMessage> SendAsync(
    HttpRequestMessage request,
    CancellationToken cancellationToken)
  {
    request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("text/xml; charset=utf-8");
    return await base.SendAsync(request, cancellationToken);
  }
}

Call NASA

async Task CallNasaAsync()
{
    var soapClient = new SoapClient();
    var ns = XNamespace.Get("http://helio.spdf.gsfc.nasa.gov/");

    var result =
        await soapClient.PostAsync(
            new Uri("http://sscweb.gsfc.nasa.gov:80/WS/helio/1/HeliocentricTrajectoriesService"),
            SoapVersion.Soap11,
            body: new XElement(ns.GetName("getAllObjects")));

    result.StatusCode.Should().Be(HttpStatusCode.OK);
}

Result of Calling NASA Heliocentric Trajectories Service

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:getAllObjectsResponse xmlns:ns2="http://helio.spdf.gsfc.nasa.gov/">
         <return>
            <endDate>1993-01-01T00:00:00Z</endDate>
            <id>0001</id>
            <name>COMET GRIGG-SKJLP</name>
            <startDate>1992-01-01T00:00:00Z</startDate>
         </return>
         <return>
            <endDate>1996-03-02T00:00:00Z</endDate>
            <id>0002</id>
            <name>COMET H-M-P</name>
            <startDate>1996-01-01T00:00:00Z</startDate>
         </return>
         <return>
            <endDate>1997-12-31T00:00:00Z</endDate>
            <id>0003</id>
            <name>COMET HALE-BOPP</name>
            <startDate>1997-01-01T00:00:00Z</startDate>
         </return>
         .
         .
         .
      </ns2:getAllObjectsResponse>
   </S:Body>
</S:Envelope>

Soap Icon Created by Jakob Vogel from the Noun Project

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].