iOS请求webservice接口需要明确知道什么信息

混昏黄 2016-09-06 02:26:44
公司只给了一个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];
}
...全文
498 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
偶说撒浪嘿 2016-09-18
  • 打赏
  • 举报
回复
楼主问题解决了么,我也是这样写的,但是返回的是bad request

29,031

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧