2011-03-26 171 views
0

我解析SOAP Web服务进行身份验证,但它没有返回任何NSData,因此我可以为它编写xml解析器。肥皂web服务

请让我知道我做错了什么。

这里是我的代码:

** 
-(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

这是上面 – 2011-03-26 06:24:42

+0

的代码,你可以编辑自己的问题,如果你喜欢。 – gideon 2011-03-26 06:27:59

+0

[soap web服务解析]的可能重复(http://stackoverflow.com/questions/5456212/soap-web-service-parsing) – 2011-03-31 20:08:18

回答

0

NSURLConnection的是一个异步方法 - 你实现的实际侦听和检索数据的委托方法的休息吗?

你不妨审查documentation here

在你上面的例子,WEBDATA永远是空的,它是由你来填充它...