公司只给了一个wsdl接口能够请求出数据吗
NSString *soapMsg = [NSString stringWithFormat:
@"<?xml version='1.0' encoding='GB2312' standalone='yes' ?>"
@"<soap:Envelope "
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap:Body>"
"< 方法名怎么在wsdl接口里面找到 xmlns=\"命名空间怎么找到">"
"</方法名>"
"</soap:Body>"
"</soap:Envelope>"];
NSURL *url = [NSURL URLWithString: @"http://x.x.x.x:x/soap/Service?wsdl"];
// 根据上面的URL创建一个请求
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
// 添加请求的详细信息,与请求报文前半部分的各字段对应
[req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
// 设置请求行方法为POST,与请求报文第一行对应
[req setHTTPMethod:@"POST"];
// 将SOAP消息加到请求中 [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
// 创建连接
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
webData = [NSMutableData data];
}
NSString *soapMsg = [NSString stringWithFormat:
@"<?xml version='1.0' encoding='GB2312' standalone='yes' ?>"
@"<soap:Envelope "
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap:Body>"
"< 方法名怎么在wsdl接口里面找到 xmlns=\"命名空间怎么找到">"
"</方法名>"
"</soap:Body>"
"</soap:Envelope>"];
NSURL *url = [NSURL URLWithString: @"http://x.x.x.x:x/soap/Service?wsdl"];
// 根据上面的URL创建一个请求
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
// 添加请求的详细信息,与请求报文前半部分的各字段对应
[req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
// 设置请求行方法为POST,与请求报文第一行对应
[req setHTTPMethod:@"POST"];
// 将SOAP消息加到请求中 [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
// 创建连接
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
webData = [NSMutableData data];
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货