【发布时间】:2011-03-28 08:09:12
【问题描述】:
我正在尝试解析soap Web服务以进行身份验证,以下是代码
currentElement = [[NSString alloc] init];
NSString* email=[NSString stringWithFormat:@"sbhushan@gmail.com"];
NSString* password=[NSString stringWithFormat:@"5Pb&Q?4t"];
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>"
"<Authentication xmlns=\"http://tempuri.org/\">"
"<userId>%@</userId>"
"<password>%@</password>"
"</Authentication>"
"</soap:Body>"
"</soap:Envelope>",email,password];
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/Authentication" 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.
}
并实现了所有解析的委托方法,但没有被调用
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [网络数据追加数据:数据]; }
或者没有得到任何数据请帮忙
【问题讨论】:
标签: iphone