comment envoyer/recevoir du savon objet avec objective-c pour ipad
J'ai essayé d'écrire un objectif c application pour ipad pour envoyer/recevoir des web service soap. J'ai écrit un code, mais il donne une erreur. le webservice est le travail en ligne.
voici mon code,
-(IBAction)invokeService
{
[txt1 resignFirstResponder];
NSString *soapFormat = [NSString stringWithFormat:
@"<?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"
"<GetUserList xmlns=\"http://tempuri.org/\" />\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];
NSLog(@"The request format is %@",soapFormat);
NSURL *locationOfWebService = [NSURL URLWithString:@"http://servicing2.rotanet.com/service1.asmx"];
NSLog(@"web url = %@",locationOfWebService);
NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];
[theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"GetUserList" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
//the below encoding is used to send data over the net
[theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
if (connect) {
webData = [[NSMutableData alloc]init];
startActivityIndicator;
}
else {
NSLog(@"No Connection established");
}
}
J'obtiens ce message d'erreur
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault> <faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: GetUserList.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) </faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
ce que je fais mal?
OriginalL'auteur Arif YILMAZ | 2013-05-08
Vous devez vous connecter pour publier un commentaire.
Disclaimer: je suis auteur de WSClient++ et c'est un produit commercial.
http://wsclient.neurospeech.com
De la création de simples requêtes SOAP sont faciles, cependant lorsque vous avez complexes graphe d'objets, de traiter avec les Dictionnaires et XML brut, peut prendre beaucoup de temps, WSClient++ génère Objectif de code source C pour le SAVON proxy avec chaque type complexe. Vous venez de faire un seul appel de méthode pour récupérer les résultats.
OriginalL'auteur Akash Kava