开发者

soap web service parsing

i am trying to parse soap web service for authentication and following is the code

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/\">"
                 开发者_C百科      "<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.
}   

and imlemented all the delegate method of parsing but do not getting call in

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; }

or not getting any data please help


hi Friend your method looks OK dont know why not working , u see any data on consol?? try this or take a look on webservices may be data not come from there

NSString *soapMessage = [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><GetClientData xmlns=\"http://tempuri.org/\"><pSearch>%@</pSearch></GetClientData></soap:Body></soap:Envelope>\n", nameInput.text];
NSURL *url = [NSURL URLWithString:@"http://192.168.1.162/iphone/service.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:  @"http://tempuri.org/GetClientData" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if( theConnection )
{
    webData = [[NSMutableData data] retain];
}
else
{
    NSLog(@"theConnection is NULL");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜