Jinget.Handlers.ExternalServiceHandlers 6.2.19-preview019

Prefix Reserved
This is a prerelease version of Jinget.Handlers.ExternalServiceHandlers.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Jinget.Handlers.ExternalServiceHandlers --version 6.2.19-preview019                
NuGet\Install-Package Jinget.Handlers.ExternalServiceHandlers -Version 6.2.19-preview019                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jinget.Handlers.ExternalServiceHandlers" Version="6.2.19-preview019" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jinget.Handlers.ExternalServiceHandlers --version 6.2.19-preview019                
#r "nuget: Jinget.Handlers.ExternalServiceHandlers, 6.2.19-preview019"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jinget.Handlers.ExternalServiceHandlers as a Cake Addin
#addin nuget:?package=Jinget.Handlers.ExternalServiceHandlers&version=6.2.19-preview019&prerelease

// Install Jinget.Handlers.ExternalServiceHandlers as a Cake Tool
#tool nuget:?package=Jinget.Handlers.ExternalServiceHandlers&version=6.2.19-preview019&prerelease                

Jinget

We are currently in the way to make Jinget an open source project, during this journey we will publish different parts of Jinget

Jinget.Handlers.ExternalServiceHandlers

The purpose of this package is to facilitate communication and use of various types of web services and Web APIs including Rest APIs and SOAP web services.

How to Use:

  1. Download the package from NuGet using Package Manager: Install-Package Jinget.Handlers.ExternalServiceHandlers You can also use other methods supported by NuGet. Check Here for more information.

  2. Create a class which defines the response model.

     public class SampleGetResponse
     {
         public int id { get; set; }
         public string name { get; set; }
         public string username { get; set; }
    }
  1. Create an object of type JingetServiceHandler<> class and pass the response model as its generic type:
var jingetServiceHandler = new JingetServiceHandler<SampleGetResponse>("https://jsonplaceholder.typicode.com");
  1. Call your endpoint:
var result = await jingetServiceHandler.GetAsync("users");

How to call SOAP web Services:

  1. For SOAP services, it would be important to create the request envelope before sending the request. To create the request envelop, You need to create classes for different parts of the request envelop. For example suppose that we need to model the following request envelop:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Add>
         <tem:intA>?</tem:intA>
         <tem:intB>?</tem:intB>
      </tem:Add>
   </soapenv:Body>
</soapenv:Envelope>

In this request envelop we have Envelop node which contains two inner nodes: Header and Body. Also for Body, this node contains a node node called Add and finally Add contains two nodes called intA and intB. Also each node belongs to some namespaces which are defined in Envelop node. With all these in mind, we need to define classes for exact this hierarchy as follow:

//This is the whole request envelop
public class SampleSOAPRequest : SOAPRequestBase<SampleSOAPRequest.Envelope, SampleSOAPRequest.SampleSOAPGet>
{
    //This method creates an envelop with the following structure
    public override (Envelope envelope, SampleSOAPGet request) CreateEnvelope()
    {
        var envelope = new Envelope
        {
            Header = new EnvelopeHeader(),
            Body = new EnvelopeBody()
        };
        return (envelope, envelope.Body.Add);
    }

    //request envelop contains the Envelop node with some namespaces
    [Serializable, XmlType(Namespace = "http://schemas.xmlsoap.org/soap/envelope/"), XmlRoot(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
    public class Envelope : SOAPEnvelopeBase
    {
	    //When calling this method, the final envelop is returned as string value
        public override string ToString()
        {
            XmlSerializerNamespaces ns = new();
            ns.Add("tem", "http://tempuri.org/");
            ns.Add("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");

            return XmlUtility.SerializeToXml(this, true, ns);
        }

        //Envelop node contains the Header node
        public EnvelopeHeader Header { get; set; }

        //Envelop node contains the Body node
        public EnvelopeBody Body { get; set; }
    }

    //The Header node has the following members. As you see it is empty. Also this node belongs to the http://schemas.xmlsoap.org/soap/envelope/ namespace
    [Serializable, XmlType(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
    public class EnvelopeHeader
    {

    }

      //The Body node has the following members. Also this node belongs to the http://schemas.xmlsoap.org/soap/envelope/ namespace
    [Serializable, XmlType(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
    public class EnvelopeBody
    {
	    //Body node contains a node called 'Add' which belongs to the http://schemas.xmlsoap.org/soap/envelope/ namespace
        [XmlElement(Namespace = "http://tempuri.org/")]
        public SampleSOAPGet Add { get; set; }
    }

     //The Add node has the following members.
    [Serializable]
    public class SampleSOAPGet
    {
        public int intA { get; set; }
        public int intB { get; set; }
    }
}
  1. Now that we have our envelop, we can easily call the SOAP web service as following:
var (envelope, request) = new SampleSOAPRequest().CreateEnvelope();
envelope.Body.Add = new SampleSOAPRequest.SampleSOAPGet { intA = 1, intB = 2 };

 var jingetServiceHandler = new JingetServiceHandler<ResponseType>("http://www.dneonline.com/calculator.asmx");

 var result = await jingetServiceHandler.PostAsync("", envelope.ToString(), true, new Dictionary<string, string>
 {
              {"Content-Type","text/xml" },
              {"SOAPAction","http://tempuri.org/Add" }
 });

In line number 2, we have our envelop and all we need to do, is to pass our parameters. In line number 6, the envelop is being send to the PostAsync method as string value. It is important to note the SOAPAction header.


How to use custom Service Handler

You can use your custom service handler instead of using JingetServiceHandler. To do this create your custom class and makes it to inherit from ServiceHandler<> class. Also create a custom class for your event management and pass it as generic argument to ServiceHandler<> class. For example suppose that we have a class called CustomHandler as below:

 public class CustomServiceHandler : ServiceHandler<CustomEvents>
 {
	...
 }

How to install

In order to install Jinget please refer to nuget.org

Further Information

Sample codes are available via Unit Test projects which are provided beside the main source codes.

Contact Me

👨‍💻 Twitter: https://twitter.com/_jinget

📧 Email: farahmandian2011@gmail.com

📣 Instagram: https://www.instagram.com/vahidfarahmandian

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Jinget.Handlers.ExternalServiceHandlers:

Package Downloads
Jinget.AzureDevOps.Connector

Using this package, you can easily connect to Azure DevOps and integrate it with your software applications

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0-preview013 70 a month ago
8.0.0-preview012 76 a month ago
8.0.0-preview011 76 a month ago
8.0.0-preview010 72 a month ago
8.0.0-preview009 65 a month ago
8.0.0-preview008 69 2 months ago
8.0.0-preview007 89 2 months ago
8.0.0-preview006 78 3 months ago
8.0.0-preview005 71 3 months ago
8.0.0-preview004 78 3 months ago
8.0.0-preview003 72 3 months ago
8.0.0-preview002 72 3 months ago
8.0.0-preview001 66 3 months ago
6.2.23-preview003 75 3 months ago
6.2.23-preview002 72 3 months ago
6.2.22 104 3 months ago
6.2.21 88 3 months ago
6.2.20 88 3 months ago
6.2.19-preview037 69 3 months ago
6.2.19-preview036 72 4 months ago
6.2.19-preview035 101 4 months ago
6.2.19-preview034 94 4 months ago
6.2.19-preview033 90 5 months ago
6.2.19-preview032 84 5 months ago
6.2.19-preview031 94 5 months ago
6.2.19-preview029 92 5 months ago
6.2.19-preview028 104 5 months ago
6.2.19-preview027 110 5 months ago
6.2.19-preview026 111 5 months ago
6.2.19-preview025 115 5 months ago
6.2.19-preview024 109 5 months ago
6.2.19-preview023 89 5 months ago
6.2.19-preview022 92 5 months ago
6.2.19-preview021 88 5 months ago
6.2.19-preview020 87 5 months ago
6.2.19-preview019 86 5 months ago
6.2.19-preview018 51 6 months ago
6.2.19-preview017 52 6 months ago
6.2.19-preview016 63 6 months ago
6.2.19-preview015 64 6 months ago
6.2.19-preview014 67 6 months ago
6.2.19-preview013 92 6 months ago
6.2.19-preview012 82 6 months ago
6.2.19-preview011 92 7 months ago
6.2.19-preview010 88 7 months ago
6.2.19-preview009 87 7 months ago
6.2.19-preview008 88 7 months ago
6.2.19-preview007 81 7 months ago
6.2.19-preview006 81 7 months ago
6.2.19-preview005 69 7 months ago
6.2.19-preview004 79 7 months ago
6.2.19-preview003 90 7 months ago
6.2.19-preview002 93 7 months ago
6.2.19-preview001 91 7 months ago
6.2.18 122 7 months ago
6.2.18-preview020 100 7 months ago
6.2.18-preview019 109 7 months ago
6.2.18-preview018 107 7 months ago
6.2.18-preview017 103 8 months ago
6.2.18-preview016 106 8 months ago
6.2.18-preview015 112 8 months ago
6.2.18-preview014 96 8 months ago
6.2.18-preview013 101 8 months ago
6.2.18-preview012 97 8 months ago
6.2.18-preview011 91 8 months ago
6.2.18-preview010 96 8 months ago
6.2.18-preview009 95 8 months ago
6.2.18-preview008 103 8 months ago
6.2.18-preview007 109 8 months ago
6.2.18-preview006 102 8 months ago
6.2.18-preview005 88 8 months ago
6.2.18-preview004 82 8 months ago
6.2.18-preview003 79 8 months ago
6.2.18-preview002 80 8 months ago
6.2.17 81 8 months ago
6.2.16 88 8 months ago
6.2.15 94 8 months ago
6.2.14 87 8 months ago
6.2.13 96 8 months ago
6.2.12 94 8 months ago
6.2.11 97 8 months ago
6.2.10 93 8 months ago
6.2.9 116 8 months ago
6.2.8 125 8 months ago
6.2.7 131 8 months ago
6.2.6 128 8 months ago
6.2.5 109 9 months ago
6.2.4 144 2/1/2024
6.2.3 115 2/1/2024
6.2.2 112 1/31/2024
6.2.1 122 1/23/2024
6.2.0 121 1/23/2024
6.2.0-preview013 105 1/19/2024
6.2.0-preview012 108 1/19/2024
6.2.0-preview011 117 1/18/2024
6.2.0-preview010 118 1/14/2024
6.2.0-preview009 122 1/11/2024
6.2.0-preview008 132 1/1/2024
6.2.0-preview007 115 1/1/2024
6.2.0-preview006 120 1/1/2024
6.2.0-preview005 125 1/1/2024
6.2.0-preview001 126 12/30/2023
6.1.0 228 12/2/2023
6.1.0-preview003 148 12/2/2023
6.1.0-preview002 139 12/2/2023
6.1.0-preview001 146 12/2/2023
6.0.2 158 11/27/2023
6.0.1 169 11/22/2023
6.0.0 140 11/22/2023
3.5.0 202 10/28/2023
3.4.0 201 10/1/2023
3.3.1 186 9/30/2023
3.3.0 165 9/28/2023
3.2.5 177 9/28/2023
3.2.4 177 9/28/2023
3.2.3 172 9/28/2023
3.2.2 176 9/28/2023
3.2.1 155 9/28/2023
3.2.0 178 9/28/2023
3.1.0 183 9/27/2023
3.0.1 162 9/27/2023
3.0.0 187 9/14/2023
3.0.0-preview001 162 9/14/2023
2.3.2 199 9/12/2023
2.3.1 240 8/20/2023
2.3.0 228 8/20/2023
2.2.0 206 8/12/2023
2.1.1 246 8/5/2023
2.1.0 221 8/5/2023
2.0.5 200 7/20/2023
2.0.4 208 7/15/2023
2.0.3 639 7/1/2023
2.0.1 213 7/1/2023
2.0.0 245 6/29/2023