C# SoapSample credentials (ID Password)

using System.Xml;
using System.Net;
using System.IO;
using System.Text;

namespace UniRecord
{
    public class SoapClass
    {
        public static string CallWebService()
        {
            var _url = "https://test.com/B2BGateway/connect/uAPI";
            var _action = "https://test.com/uAPI/UniversalRecordService"; //EndPoint

            XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
            HttpWebRequest webRequest = CreateWebRequest(_url, _action);
            InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);

            // begin async call to web request.
            IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);

            // suspend this thread until call is complete. You might want to
            // do something usefull here like update your UI.
            asyncResult.AsyncWaitHandle.WaitOne();

            // get the response from the completed web request.
            string soapResult;
            using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
            {
                using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
                {
                    soapResult = rd.ReadToEnd();
                }
            }
            return soapResult;
        }

        private static HttpWebRequest CreateWebRequest(string url, string action)
        {
            string credentials = "ID:Password";
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(action); //action 사용
            webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials)));
            webRequest.ContentType = "text/xml;charset=\"utf-8\"";
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";

            return webRequest;
        }

        private static XmlDocument CreateSoapEnvelope()
        {
            XmlDocument soapEnvelop = new XmlDocument();
            soapEnvelop.LoadXml(@"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:univ='http://www.travelport.com/schema/universal_v31_0' xmlns:com='http://www.travelport.com/schema/common_v31_0'>" +
                                               "<soapenv:Header>" +
                                                  "<univ:SupportedVersions/>" +
                                               "</soapenv:Header>" +
                                               "<soapenv:Body>" +
                                                  "<univ:UniversalRecordRetrieveReq TraceId='trace' AuthorizedBy='user' TargetBranch='ID'  RetrieveProviderReservationDetails='false' ViewOnlyInd='false'>" +
                                                     "<com:BillingPointOfSaleInfo OriginApplication='UAPI'/>" +
                                                     "<univ:UniversalRecordLocatorCode>PNR001</univ:UniversalRecordLocatorCode>" +
                                                  "</univ:UniversalRecordRetrieveReq>" +
                                               "</soapenv:Body>" +
                                            "</soapenv:Envelope>");
            return soapEnvelop;
        }

        private static void InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)
        {
            using (Stream stream = webRequest.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }
        }


    }
}

참조 : http://stackoverflow.com/questions/4791794/client-to-send-soap-request-and-received-respons