NOTE: This page has been translated automatically from Russian to English. Original page.



Simple POST-search.

Simple Post-query that most simply allows the server to send data and receive an answer.

The network, and including on this site, a lot of topics on this subject. The contents of most of them are cumbersome and confusing. Among other things, referred to the encoding of data sent in Base64, use dividers to send a variety of data in a single request, etc. The attached processing all simplified to a minimum and "jungle" is not considered. Designed for use as a universal blanks for implementing more complex functionality. As an example, using the well-known service is a transport company. In the post-query recovers the invoice number in the xml response is returned with information about her condition. In the screen shot is a real bill (thanks to Google), which tested the performance.

Bob's not necessarily spread all of the code module form:


KnopkaVypolnitNazhatie Procedure (Button)
Attempt
WinHttp = New COMObekt ( "WinHttp.WinHttpRequest.5.1");
WinHttp Option (2, "utf-8").;
WinHttp Open ( "POST", " http://public.services.dellin.ru/tracker/XML/", 0).;
WinHttp SetRequestHeader ( "Accept-Language" , "ru").;
WinHttp SetRequestHeader ( "Accept-Charset" , "utf- 8").;
WinHttp setRequestHeader ( "Content-Language" , "ru").;
WinHttp setRequestHeader ( "Content-Charset" , "utf- 8").;
WinHttp setRequestHeader ( "Content-type" , "application / x-www-form-urlencoded; charset = utf- 8").;
ParametryPOST = "rwID =" + SokrLP (NomerNakladnoy);
WinHttp Send (ParametryPOST).;
. TekstOtveta = WinHttp ResponseText ();
An exception
Report (OpisanieOshibki ());
KonetsPopytki;
KonetsProtsedury

Where "NomerNakladnoy" - is a string input field on the form, which enter the invoice number (for example, Xu-00090170085) and "TekstOtveta" - is a multi-line string field where the results.

After comments Den_D decided to add the same, only the built-in tools. Note the ampersand in front of the - save time and hassle. This is a common "feature" 1C, which decided that no matter how much you have options there - ALWAYS put the ampersand because we so want.

Treatment updated.

Well, the code for the unwilling spread swing. I hope at the same time on your social "plyusootvetstvennost".


OsnovnyeDeystviyaFormyVypolnit2 Procedure (Button)
Server = "public.services.dellin.ru";
Resource = "/ tracker / XML /" ;
HTTP = New HTTPSoedinenie (server);
FaylZaprosa PoluchitImyaVremennogoFayla = ();
TekstovyyFayl = New TextDocument;
TekstovyyFayl UstanovitTekst ( "& rwID =" + SokrLP (NomerNakladnoy)).;
. TekstovyyFayl Record (FaylZaprosa, TextEncoding UTF8.);
FaylRezultata PoluchitImyaVremennogoFayla = ();
ZagolovokHTTP = New Value ();
ZagolovokHTTP Paste ( "Content-Type", " application / x-www-form-urlencoded").;
. Insert ZagolovokHTTP ( "Accept-Language", " ru");
ZagolovokHTTP Paste ( "Accept-Charset", " utf- 8").;
ZagolovokHTTP Paste ( "Content-Language", " ru").;
ZagolovokHTTP Paste ( "Content-Charset", " utf- 8").;
. HTTP OtpravitDlyaObrabotki (FaylZaprosa, resource FaylRezultata, ZagolovokHTTP);
A = New TextDocument ();
A Read (FaylRezultata, TextEncoding UTF8.).;
TekstOtveta PoluchitTekst = A ().;
UdalitFayly (FaylZaprosa);
UdalitFayly (FaylRezultata);
KonetsProtsedury

Exceptions were too lazy to write ... But check availability.

1C:Enterprise Developer's Community