O
O
OlegTar2013-12-14 14:29:13
SOAP
OlegTar, 2013-12-14 14:29:13

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);

And I get an html page in response, which can be obtained at this address rain.kassir.ru:8080
What is wrong in the code?
I asked two people who seem to understand SOAP, but they could not help me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Illivion, 2013-12-14
@OlegTar

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();
}

Unfortunately, executing this code throws a FaultException (meaning that the exception was thrown by the service logic) with the text "An error was discovered processing the header". I believe that access to the service requires credentials, which can be specified something like this:
client.ClientCredentials.UserName.UserName = "webServiceUserName";
client.ClientCredentials.UserName.Password = "webServicePassword";

See also what is on the network for this exception. For example this . There is also an implementation of its header here .

I
Ilya Glebov, 2013-12-14
@IljaGlebov

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 question

Ask a Question

731 491 924 answers to any question