xmlns:soap12
=
"http://www.w3.org/2003/05/soap-envelope"
>
59
<soap12:Body>
60
<getWeatherbyCityName
xmlns
=
"http://WebXml.com.cn/"
>
61
<theCityName>
string
</theCityName>
62
</getWeatherbyCityName>
63
</soap12:Body>
64
</soap12:Envelope>
请求方法:
65
- (
void
) soap1_2
66
{
67
NSString *province=[NSString stringWithFormat:@
"上海"
];
68
//设置 soap 请求信息
69
NSString *soapString=[[NSString alloc] initWithFormat:@
"<?xml version=\"1.0\"
encoding=\"utf-8\"?>"
70
"<soap12:Envelope
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
71
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
72
"<soap12:Body>"
73
"<getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
74
"<theCityName>%@</theCityName>"
75
"<theCityName>%@</theCityName>"
76
"</getWeatherbyCityName>"
77
"</soap12:Body>"
78
"</soap12:Envelope>"
,province];
79
80
81
NSLog(@
"%@"
,soapString);
82
//soap 请求地址
83
NSURL *url=[[NSURL alloc]
initWithString:@
"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"
];
84
//请求
85
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
86
//设置请求头部
87
////设置 ContentType
88
[request addValue:@
"text/xml; charset=utf-8"
forHTTPHeaderField:@
"Content-
Type"
];
89
////设置 SOAPAction
90
[request addValue:@
"http://WebXml.com.cn/getWeatherbyCityName"
forHTTPHeaderField:@
"SOAPAction"
];
91
//设置 Content-length
92
[request addValue:[NSString stringWithFormat:@
"%d"
,[soapString length]]