Webservice SVC – objective-c

J'ai renvoyé ce lien et l' ai trouvé très utile mais quand j'ai commencé à essayer tous les possibles, j'ai échoué à get la sortie désirée.

NSSsortingng *soapMessage = [NSSsortingng ssortingngWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<SOAP:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "<SOAP:Body>\n" "<BindCategory xmlns=\"http://tempuri.org/\">\n" "</SOAP:Body>\n" "</SOAP:Envelope>\n" ]; NSLog(@"soapMessage: \n%@",soapMessage); NSURL *url = [NSURL URLWithSsortingng:@"http://assetwebservice.sudesi.in/Service/"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSSsortingng *msgLength = [NSSsortingng ssortingngWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: @"http://tempuri.org/IService/BindCategory" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8SsortingngEncoding]]; 

Je pense que je dois faire une erreur mineure. Je reçois la sortie suivante.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>404 (Page Not Found) Error - Ever feel like you're in the wrong place?</title> <link href="http://p3nlhclust404.shr.prod.phx3.secureserver.net/SharedContent/404-etc-styles.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div class="body-404"> <h1> <span>Ever feel you're in the wrong place</span> </h1> <div class="info-container"> <div class="inner-border clear-fix"> <h2 class="info-top"> 404 (Page Not Found) Error </h2> <div class="site-owner-404"> <h3>If you're the <strong>site owner,</strong> one of two things happened:</h3> <ol> <li> 1) You entered an incorrect URL into your browser's address bar, or </li> <li> 2) You haven't uploaded content. </li> </ol> </div> <div class="site-visitor-404"> <h3>If you're a <strong>visitor</strong> and not sure what happened:</h3> <ol> <li> 1) You entered or copyd the URL incorrectly or </li> <li> 2) The link you used to get here is faulty. </li> <li class="last"> (It's an excellent idea to let the link owner know.) </li> </ol> </div> </div> </div> </div> </body> </html> 

Est-ce que quelqu'un peut aider à comprendre ce que je fais? Toute aide est grandement appréciée?

Hey les gars ont découvert la solution. La deuxième ligne du message soap a été corrigée.

 "<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/\">\n" "<soap:Body>\n" 

Il manquait également l'extension .svc dans la string d'URL. Je l'ai corrigé avec la déclaration. http://assetwebservice.sudesi.in/service.svc Voyez bien le s de service.svc est minuscule alors que dans le paramètre soapaction il est en majuscule.

Voici le message de soap entier avec les parameters d'en-tête http.

 NSSsortingng *soapMessage = [NSSsortingng ssortingngWithFormat: @"<?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/\">\n" "<soap:Body>\n" "<BindCategory xmlns=\"http://tempuri.org/\">\n" "</BindCategory>\n" "</soap:Body>\n" "</soap:Envelope>\n" ]; NSLog(@"soapMessage: \n%@",soapMessage); NSURL *url = [NSURL URLWithSsortingng:@"http://assetwebservice.sudesi.in/service.svc"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSSsortingng *msgLength = [NSSsortingng ssortingngWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: @"http://tempuri.org/IService/BindCategory" forHTTPHeaderField:@"soapaction"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8SsortingngEncoding]]; 

Une chose me NSLog encore, c'est que même si c'est une requête GET, elle me lance "ERROR in Connection" NSLog & réussit quand je la change en POST