xml - SOAP in iOS Application -


i'm trying develop app uses data soap service. first time use soap service. after reading several tutorials thought able set request service in right way errors in response. what's wrong ?!

nsstring *soapmessage = [nsstring stringwithformat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"                  "<env:envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"urn:lottery.intf-ilottery\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:enc=\"http://www.w3.org/2003/05/soap-encoding\">\n"                  "<env:body>\n"                  "<ns1:getupcominglotteries env:encodingstyle=\"http://www.w3.org/2003/05/soap-encoding\">\n"                  "<entityid xsi:type=\"xsd:int\">2</entityid>\n"                  "<password xsi:type=\"xsd:string\">smart@winners</password>\n"                  "<sortby xsi:type=\"xsd:int\">0</sortby>\n"                  "<limit xsi:type=\"xsd:int\">0</limit>\n"                  "</ns1:getupcominglotteries>\n"                  "</env:body>\n"                  "</env:envelope>"];   nsurl *srequesturl = [nsurl urlwithstring:@"xxxxxxxxx"]; nsmutableurlrequest *myrequest = [nsmutableurlrequest requestwithurl:srequesturl]; nsstring *smessagelength = [nsstring stringwithformat:@"%d", [soapmessage length]];  [myrequest addvalue: @"text/xml; charset=utf-8" forhttpheaderfield:@"content-type"]; [myrequest addvalue: @"urn:lottery.intf-ilottery/getupcominglotteries" forhttpheaderfield:@"soapaction"]; [myrequest addvalue: smessagelength forhttpheaderfield:@"content-length"];  [myrequest sethttpmethod:@"post"]; [myrequest sethttpbody: [soapmessage datausingencoding:nsutf8stringencoding]];  nserror *error; nsurlresponse *response; nsdata *urldata=[nsurlconnection sendsynchronousrequest:myrequest returningresponse:&response error:&error]; nsstring *str=[[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding]; 

download attached project here // in .h file

#import "tbxml.h"  @property(retain,nonatomic)nsstring *xmlstring;  @property(nonatomic,retain)nsmutabledata *webresponsedata; 

// in .m file

-(void)method_getupcominglotteries {        nsstring *soapmessage = [nsstring stringwithformat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"                              "<env:envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"urn:lottery.intf-ilottery\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:enc=\"http://www.w3.org/2003/05/soap-encoding\">\n"                              "<env:body>\n"                              "<ns1:getupcominglotteries env:encodingstyle=\"http://www.w3.org/2003/05/soap-encoding\">\n"                              "<entityid xsi:type=\"xsd:int\">2</entityid>\n"                              "<password xsi:type=\"xsd:string\">smart@winners</password>\n"                              "<sortby xsi:type=\"xsd:int\">0</sortby>\n"                              "<limit xsi:type=\"xsd:int\">0</limit>\n"                              "</ns1:getupcominglotteries>\n"                              "</env:body>\n"                              "</env:envelope>"];       nsurl *srequesturl = [nsurl urlwithstring:@"xxxxxxxxx"];     nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:srequesturl];     nsstring *smessagelength = [nsstring stringwithformat:@"%d", [soapmessage length]];      [request addvalue: @"text/xml; charset=utf-8" forhttpheaderfield:@"content-type"];     [request addvalue: @"urn:lottery.intf-ilottery/getupcominglotteries" forhttpheaderfield:@"soapaction"];     [request addvalue: smessagelength forhttpheaderfield:@"content-length"];      [request sethttpmethod:@"post"];        [request sethttpbody:[soapmessage datausingencoding:nsutf8stringencoding]];      nslog(@"soapmessage===\n %@",soapmessage);      nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:request delegate:self];      if( theconnection ) {         nslog(@"hiii");         [self showupdating];         self.webresponsedata = [nsmutabledata data];     }else {         nslog(@"some error occurred in connection");          [self shownetworkerror];     }  }   - (void)connectiondidfinishloading:(nsurlconnection *)connection {     nslog(@"received bytes server: %lu", (unsigned long)[self.webresponsedata length]);      nsstring * strxml = [[nsstring alloc] initwithbytes: [self.webresponsedata mutablebytes] length:[self.webresponsedata length] encoding:nsutf8stringencoding];      nslog(@"---- %@" ,strxml);      tbxml *sourcexml = [[tbxml alloc] initwithxmlstring:strxml error:nil];     tbxmlelement *rootelement = sourcexml.rootxmlelement;     tbxmlelement *entryelement = [tbxml childelementnamed:@"soap:body" parentelement:rootelement];     }  -(void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response {                 [self.webresponsedata  setlength:0];            }  -(void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data {                [self.webresponsedata  appenddata:data];     }  -(void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error {                nslog(@"some error in connection. please try again.");                 [self shownetworkerror];             } 

or open firefox install soa client extension test api on there

enter image description here

enter image description here

updates on check in soa client following header

<?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><getupcominglotteries xmlns="http://tempuri.org/"><entityid>2</entityid><password>smart@winners</password><sortby>0</sortby><limit>0</limit></getupcominglotteries></soap:body></soap:envelope> 

and following response (means server error might be)

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <title>500 - internal server error.</title> <style type="text/css"> <!-- body{margin:0;font-size:.7em;font-family:verdana, arial, helvetica, sans-serif;background:#eeeeee;} fieldset{padding:0 15px 10px 15px;}  h1{font-size:2.4em;margin:0;color:#fff;} h2{font-size:1.7em;margin:0;color:#cc0000;}  h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}  #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet ms", verdana, sans-serif;color:#fff; background-color:#555555;} #content{margin:0 0 0 2%;position:relative;} .content-container{background:#fff;width:96%;margin-top:8px;padding:10px;position:relative;} --> </style> </head> <body> <div id="header"><h1>server error</h1></div> <div id="content">  <div class="content-container"><fieldset>   <h2>500 - internal server error.</h2>   <h3>there problem resource looking for, , cannot displayed.</h3>  </fieldset></div> </div> </body> </html> 

enter image description here


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -