A
A
Anton2019-07-12 19:34:16
SOAP
Anton, 2019-07-12 19:34:16

What is wrong with my SOAP request?

I create a request in C# with the following code

public void SOAP2()
        {
            string postData = File.ReadAllText("GetInfo.xml", Encoding.UTF8).Replace("\n", " ");

            WebRequest request = WebRequest.Create("https://tracking.russianpost.ru/rtm34?wsdl");
            request.ContentType = "text/xml;charset=\"utf-8\"";
            request.Method = "POST";

            StreamWriter sw = new StreamWriter(request.GetRequestStream());
            sw.WriteLine(postData);
            sw.Close();

            WebResponse response = request.GetResponse();

            XDocument loaded = XDocument.Load(response.GetResponseStream());

            richTextBox1.Text = loaded.ToString();
            //// разбираем ответ
            loaded.Save("GetInfo2.xml");
        }

Here is the request code
<?xml version="1.0" encoding="utf-8"?>
<head>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:oper="http://russianpost.org/operationhistory" xmlns:data="http://russianpost.org/operationhistory/data" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header/>
   <soap:Body>
      <oper:getOperationHistory>
         <!--Optional:-->
         <data:OperationHistoryRequest>
            <data:Barcode>18501634020406</data:Barcode>
            <data:MessageType>0</data:MessageType>
            <!--Optional:-->
            <data:Language>RUS</data:Language>
         </data:OperationHistoryRequest>
         <!--Optional:-->
         <data:AuthorizationHeader soapenv:mustUnderstand="?">
            <data:login>login</data:login>
            <data:password>pass</data:password>
         </data:AuthorizationHeader>
      </oper:getOperationHistory>
   </soap:Body>
</soap:Envelope>
</head>

As a result, the server responds, but the answer is completely different from what it should be. The answer should be only a few lines, but instead I get 12Kb mura. With the request itself, everything is in order, I checked it in a specialized program. The question is, what is wrong with the C# code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2019-07-12
@petermzg

So you make a request to receive a WSDL file ( https://tracking.russianpost.ru/rtm34?wsdl) and you get it.
On the page https://tracking.pochta.ru/specification, it is indicated that the address of the service is https://tracking.russianpost.ru/rtm34
Yes, and the request should be without an xml header and a strange head tag, that is, it should start with soap: Envelope

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question