我正在解析soap web服务以进行身份验证,但它没有返回任何NSData,因此我可以为它编写xx解析器。
请让我知道我做错了什么。
这是我的代码:
**
-(void)getAdvertisment
{
NSString* soapMesasge=
[NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-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/\">"
"<soap:Body>"
"<GetAdvertisement xmlns=\"http://tempuri.org/\" />"
"</soap:Body>"
"</soap:Envelope>"];**
NSURL* url=[NSURL URLWithString:@"http://codeexsolutions.com/HosService/ServiceHOSProvider.asmx"];
NSMutableURLRequest* theRequest=[NSMutableURLRequest requestWithURL:url];
NSString* msgLength=[NSString stringWithFormat:@"%d",[soapMesasge length]];
[theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://tempuri.org/GetAdvertisement" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMesasge dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection)
{
webData =[[NSMutableData alloc]retain];
}
else
{
// Inform the user that the connection failed.
}
}
答案 0 :(得分:0)
NSURLConnection是一种异步方法 - 您是否实现了实际侦听和检索数据所需的其余委托方法?
您可以查看documentation here
在上面的示例中,webData将始终为空,由您来填充它...