ASIHTTPRequest访问。NET的WebService 基于soap协议
1.通过浏览器浏览WebService,会大概提供如下的信息:
2.构建soap消息体:
NSString *soapMessage =
[NSString stringWithFormat:
@"<?xml version="1.0"
encoding="utf-8"?>\n"
"<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/">"
"<soap:Body>\n"
"<ExecuteDataset
xmlns="http://tempuri.org/">"
"<sql>%@</sql>"
"</ExecuteDataset>"
"</soap:Body>\n"
"</soap:Envelope>",sql];//就是把上述中的那段xml填进来
NSString * wsURL =
@"http://192.168.9.12:8082/ZTService.asmx";//ZTService.asmx就相当与.NET那边一个文件
//请求发送到的路径
NSString
*msgLength = [NSString stringWithFormat:@"%d", [soapMessage
length]];
NSURL *url =
[NSURL URLWithString:[NSString
stringWithFormat:@"%@",wsURL]];
2.构建soap消息体:
ASIHTTPRequest * theRequest = [ASIHTTPRequest
requestWithURL:url];