Merhabalar,

bazı webservis lerini Visual Studio da "Add Reference" ile projemize ekleyince, genellikle tür dönüşümlerinden kaynaklı Reference.cs de otomatik üretilen kodlar dogru olmuyor ve WS e veri yollamak veya almakta sorunlar olabiliyor.

Bu aşagıda kod ile VS2015 ve VS2017 de web servisini projemize referans olarak eklemeden methodları çağırabiliyoruz.

  public XmlDocument CallWs_xxx(string URL, string SoapAction)

        {

            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(urlofws); //?wsdl i unutma

            wr.ContentType = "application/soap+xml;charset=UTF-8;action=\"" + SoapAction + "\"";

            wr.Method = "POST";

            //HttpWebRequest request = CreateWebRequest("http://ssaspanorama.com/integrationwebservice.asmx?wsdl", "IntegrationSendEntitySetWithLogin");

            XmlDocument soapEnvelopeXml = new XmlDocument();

            soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>

<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:int=""http://integration.univera.com.tr"">

   <soap:Header/>

   <soap:Body>

      <int:IntegrationSendEntitySetWithLogin>

         <!--Optional:-->

         <!--Optional:-->

         <!--Optional:-->

      </int:IntegrationSendEntitySetWithLogin>

   </soap:Body>

</soap:Envelope>");

            using (Stream stream = wr.GetRequestStream())

            {

                soapEnvelopeXml.Save(stream);

            }

            using (WebResponse response = wr.GetResponse())

            {

                using (StreamReader rd = new StreamReader(response.GetResponseStream()))

                {

                    string SoapResults = rd.ReadToEnd();

                    return new XmlDocument().LoadXml(SoapResults);

                }

            }

        }