常使用的技术有:SOAP,HTTP GET
, HTTP POST 三种方式
(一) SOAP(简单对象访问协议)方式
当你使用 SOAP 时,必须用到 POST 方式
(1) SOAP 1.1
以下是请求实例:
1
POST /WebServices/WeatherWebService.asmx HTTP/1.1
2
Host: www.webxml.com.cn
3
Content-Type: text/xml;
charset
=
utf
-8
4
Content-Length: length
5
SOAPAction: "http://WebXml.com.cn/getWeatherbyCityName"
6
7
<?xml
version
=
"1.0"
encoding
=
"utf-8"
?>
8
<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/"
>
9
<soap:Body>
10
<getWeatherbyCityName
xmlns
=
"http://WebXml.com.cn/"
>
11
<theCityName>
string
</theCityName>
12
</getWeatherbyCityName>
13
</soap:Body>
14
</soap:Envelope>
请求方法:
15
- (
void
) soap1_1
16
{
17
NSString *province=[NSString stringWithFormat:@
"上海"
];
18
//设置 soap 请求信息
19
NSString *soapString=[[NSString alloc] initWithFormat:@
"<?xml version=\"1.0\"
encoding=\"utf-8\"?>"
20
"<soap:Envelope
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
21
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
22
"<soap:Body>"
23
"<getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
24
"<theCityName>%@</theCityName>"
25
"</getWeatherbyCityName>"