Võrgurakenduste protokollid 1: erinevus redaktsioonide vahel
| 71. rida: | 71. rida: | ||
* [http://www.w3schools.com/soap/ w3schools micro-tutorial] | * [http://www.w3schools.com/soap/ w3schools micro-tutorial] | ||
* [http://www.w3.org/TR/2007/REC-soap12-part0-20070427/ w3c primer] | * [http://www.w3.org/TR/2007/REC-soap12-part0-20070427/ w3c primer] | ||
Small recent example from xTee: | |||
Request: | |||
<pre> | |||
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xtee="http://x-tee.riik.ee/xsd/xtee.xsd" xmlns:ehis="http://producers.ehis.xtee.riik.ee/producer/ehis"> | |||
<soapenv:Header> | |||
<xtee:id xsi:type="xsd:string">680e0c731a244e2c91210e1540458441</xtee:id> | |||
<xtee:nimi xsi:type="xsd:string">ehis.idpilet</xtee:nimi> | |||
<xtee:isikukood xsi:type="xsd:string">10101010101</xtee:isikukood> | |||
<xtee:andmekogu xsi:type="xsd:string">ehis</xtee:andmekogu> | |||
<xtee:asutus xsi:type="xsd:string">10747013</xtee:asutus> | |||
</soapenv:Header> | |||
<soapenv:Body> | |||
<ehis:idpilet soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | |||
<keha xsi:type="ehis:EHIS_Isikukood">10101010101</keha> | |||
</ehis:idpilet> | |||
</soapenv:Body> | |||
</soapenv:Envelope> | |||
</pre> | |||
Answer: | |||
<pre> | |||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |||
<soapenv:Body> | |||
<ns1:idpiletResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://producers.ehis.xtee.riik.ee/producer/ehis"> | |||
<paring xsi:type="ns1:EHIS_Isikukood">10101010101</paring> | |||
<keha xsi:type="ns1:EHIS_Boolean">ei</keha> | |||
</ns1:idpiletResponse> | |||
</soapenv:Body> | |||
</soapenv:Envelope> | |||
</pre> | |||
== XML Schema == | == XML Schema == | ||
Redaktsioon: 23. september 2009, kell 13:28
Get and post
GET: all data sent is in the headers & URL. If your form has METHOD="GET" in its FORM tag, your CGI program will receive the encoded form input in the environment variable QUERY_STRING.
POST: when sending, after headers comes text. If your form has METHOD="POST" in its FORM tag, your CGI program will receive the encoded form input on stdin. The server will NOT send you an EOF on the end of the data, instead you should use the environment variable CONTENT_LENGTH to determine how much data you should read from stdin.
Read:
Post answer reading example:
if (getenv("CONTENT_LENGTH") == NULL ||
sscanf(getenv("CONTENT_LENGTH"), "%d", &cl) != 1) {
data_error(NULL,"bad http format or missing content length received");
return 1;
}
// Create space for content:
xmlquerybuf = malloc(cl + 1);
if (xmlquerybuf == NULL) {
data_error(NULL,"cannot malloc for http request: bad content length?");
return 1;
}
// Read content:
c='a';
for(i=0; i<cl && c!=EOF; i++) {
c=fgetc(stdin);
xmlquerybuf[i]=c;
}
xmlquerybuf[i]=0;
Json
JSON details and official spec:
JSON-RPC: http://json-rpc.org/wiki/specification
xml-rpc
Read: http://www.xmlrpc.com/
Call example:
POST /RPC2 HTTP/1.0
User-Agent: Frontier/5.1.2 (WinNT)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param> <value><i4>41</i4></value> </param>
</params>
</methodCall>
SOAP
Read in this order:
Small recent example from xTee:
Request:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xtee="http://x-tee.riik.ee/xsd/xtee.xsd" xmlns:ehis="http://producers.ehis.xtee.riik.ee/producer/ehis">
<soapenv:Header>
<xtee:id xsi:type="xsd:string">680e0c731a244e2c91210e1540458441</xtee:id>
<xtee:nimi xsi:type="xsd:string">ehis.idpilet</xtee:nimi>
<xtee:isikukood xsi:type="xsd:string">10101010101</xtee:isikukood>
<xtee:andmekogu xsi:type="xsd:string">ehis</xtee:andmekogu>
<xtee:asutus xsi:type="xsd:string">10747013</xtee:asutus>
</soapenv:Header>
<soapenv:Body>
<ehis:idpilet soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<keha xsi:type="ehis:EHIS_Isikukood">10101010101</keha>
</ehis:idpilet>
</soapenv:Body>
</soapenv:Envelope>
Answer:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:idpiletResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://producers.ehis.xtee.riik.ee/producer/ehis">
<paring xsi:type="ns1:EHIS_Isikukood">10101010101</paring>
<keha xsi:type="ns1:EHIS_Boolean">ei</keha>
</ns1:idpiletResponse>
</soapenv:Body>
</soapenv:Envelope>
XML Schema
Read in this order: