Answer the question
In order to leave comments, you need to log in
How to call a SOAP method?
Here is the WSDL rain.kassir.ru:8080/kassirgate/VenueService?wsdl
You need to call the getEventList method
I make the following code:
string soapEnv = @"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soapenv:Header>
<sas:BasicAuth>
<sas:Name>login</sas:Name>
<sas:Password>password</sas:Password>
</sas:BasicAuth>
</soapenv:Header>
<soap:Body>
<getEventList xmlns=""http://services.api.gate.pmisoft.ru/"">
</getEventList>
</soap:Body>
</soap:Envelope>";
//запрос
WebRequest request = HttpWebRequest.Create("http://rain.kassir.ru:8080/kassirgate/");
//
//все эти настройки можешь взять со страницы описания веб сервиса
request.Method = "POST";
request.ContentType = "text/xml; charset=utf-8";
request.ContentLength = soapEnv.Length;
request.Headers.Add("SOAPAction", "http://rain.kassir.ru:8080/kassirgate/VenueService/getEventList");
//пишем тело
StreamWriter streamWriter = new StreamWriter(request.GetRequestStream());
streamWriter.Write(soapEnv);
streamWriter.Close();
//читаем тело
WebResponse response = request.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
Answer the question
In order to leave comments, you need to log in
It is much easier and more correct to use WCF. Create a project, right click on References in the project tree, select "Add Service Reference". In the window above, specify the path to wsdl, and below the namespace in which the proxy object will be created. For example, I specified the namespace "KassirService". Then something like this:
static void Main(string[] args)
{
var client = new KassirService.VenueServiceClient();
client.Open();
var list = client.getEventList();
foreach (var evt in list)
{
Console.WriteLine(evt.name);
}
Console.ReadLine();
}
client.ClientCredentials.UserName.UserName = "webServiceUserName";
client.ClientCredentials.UserName.Password = "webServicePassword";
Error in this line
should be
WebRequest request = HttpWebRequest.Create("http://rain.kassir.ru:8080/kassirgate/VenueService/");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question