atlassian.net-sdk-v2.0 /Atlassian.Jira/Remote/JiraRemoteServiceFactory.cs

Language C# Lines 63
MD5 Hash 0e19269567519c4390228642c31bca80 Estimated Cost $1,114 (why?)
Repository https://bitbucket.org/yyo/atlassian.net-sdk-v2.0.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Xml;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.IO;

namespace Atlassian.Jira.Remote
{
    /// <summary>
    /// Factory for JiraSoapServiceClient proxy
    /// </summary>
    public static class JiraRemoteServiceFactory
    {
        /// <summary>
        /// Creates and configures a JiraSoapServiceClient
        /// </summary>
        /// <param name="jiraBaseUrl">Base url to JIRA server</param>
        /// <returns>JiraSoapServiceClient</returns>
        public static JiraSoapServiceClient Create(string jiraBaseUrl)
        {
            if (!jiraBaseUrl.EndsWith("/"))
            {
                jiraBaseUrl += "/";
            }

            var endPointUri = new Uri(jiraBaseUrl + "rpc/soap/jirasoapservice-v2");

            BasicHttpBinding binding = null;
            if (endPointUri.Scheme == "https")
            {
                binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            }
            else
            {
                binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            }
            binding.TransferMode = TransferMode.Buffered;
            binding.UseDefaultWebProxy = true;
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.SendTimeout = new TimeSpan(0, 10, 0);
            binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
            binding.ReaderQuotas = new XmlDictionaryReaderQuotas() 
            { 
                MaxStringContentLength = int.MaxValue,
                MaxNameTableCharCount = int.MaxValue,
            };
            binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

            var endpoint = new EndpointAddress(endPointUri);
            var jiraSoapServiceClient = new JiraSoapServiceClient(binding, endpoint);

            jiraSoapServiceClient.Endpoint.Behaviors.Add(new RemoteWorklogPatchBehavior());

            return jiraSoapServiceClient;
        }
    }
}
Back to Top