title: objective-c: Webservice, How to tell about specific method to access
body: <p>I am trying to access <a href="http://services-staging.cmtnyc.com/payment/payment.asmx" rel="nofollow">http://services-staging.cmtnyc.com/payment/payment.asmx</a> web service and </p>
  
  <p><strong>AuthorizeCreditTrip</strong> I checked this webservice on .Net application and its working fine but in objective-c it does not responds with the same data.</p>
  
  <p>The web service exposes 5 methods and I want to access 4th. But I think this code do not specify that which methood to access . <code>forHTTPHeaderField:@"SOAPAction"</code> tells but I do not think that its correct link to put here.</p>
  
  <p>Does not responds means it sends nothing in response.</p>
  
  <p>I think that I am unable to set valid <strong>SOAPAction</strong></p>
  
  <pre><code>-(IBAction)sendData
  {
      NSString *soapMsg = [NSString stringWithFormat: @"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;"
                           "​​&lt;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/\"&gt;" 
                           "&lt;soap:Header&gt;"
                           "&lt;AuthenticationHeader xmlns=\"http://services.cmtnyc.com/payment\"&gt;"
                           "&lt;Username&gt;validusername&lt;/Username&gt;"
                           "&lt;Password&gt;validpass&lt;/Password&gt;"
                           "&lt;DataSource&gt;validsource&lt;/DataSource&gt;"
                           "&lt;/AuthenticationHeader&gt;"
                           "&lt;/soap:Header&gt;"
                           "​​​​​​&lt;soap:Body&gt;"
                           "&lt;AuthorizeCreditTrip xmlns=\"http://services.cmtnyc.com/payment\"&gt;"
                           "&lt;requestId&gt;%d&lt;/requestId&gt;"
                           "&lt;deviceId&gt;abcd&lt;/deviceId&gt;"
                           "&lt;userId&gt;3003&lt;/userId&gt;"
                           "&lt;jobId&gt;000047&lt;/jobId&gt;"
                           "&lt;paymentAmt&gt;1&lt;/paymentAmt&gt;"
                           "&lt;fareAmt&gt;0&lt;/fareAmt&gt;"
                           "&lt;tipAmt&gt;0&lt;/tipAmt&gt;"
                           "&lt;tollAmt&gt;0&lt;/tollAmt&gt;"
                           "&lt;surchargeAmt&gt;0&lt;/surchargeAmt&gt;"
                           "&lt;taxAmt&gt;0&lt;/taxAmt&gt;"
                           "&lt;convenienceFeeAmt&gt;0&lt;/convenienceFeeAmt&gt;"
                           "&lt;swipeData&gt;&lt;/swipeData&gt;"
                           "&lt;accountNumber&gt;validaccount&lt;/accountNumber&gt;"
                           "&lt;expiryDate&gt;validdate&lt;/expiryDate&gt;"
                           "&lt;zipCode&gt;73000&lt;/zipCode&gt;"
                           "&lt;cvv2&gt;227&lt;/cvv2&gt;"
                           "&lt;cardReaderMethod&gt;0&lt;/cardReaderMethod&gt;"
                           "&lt;encryptionKeyVersion&gt;0&lt;/encryptionKeyVersion&gt;"
                           "&lt;encryptedToken&gt;&lt;/encryptedToken&gt;"
                           "&lt;encryptionAlgorithm&gt;0&lt;/encryptionAlgorithm&gt;"
                           "&lt;pickupDate&gt;2011-09-12&lt;/pickupDate&gt;"
                           "&lt;pickupLatitude&gt;0&lt;/pickupLatitude&gt;"
                           "&lt;pickupLongitude&gt;0&lt;/pickupLongitude&gt;"
                           "&lt;dropoffDate&gt;2011-09-16&lt;/dropoffDate&gt;"
                           "&lt;dropoffLatitude&gt;0&lt;/dropoffLatitude&gt;"
                           "&lt;dropoffLongitude&gt;0&lt;/dropoffLongitude&gt;"
                           "&lt;passengerCount&gt;0&lt;/passengerCount&gt;"
                           "&lt;tripDistance&gt;124&lt;/tripDistance&gt;"
                           "&lt;tripDuration&gt;0&lt;/tripDuration&gt;"
                           "&lt;readyToSettle&gt;false&lt;/readyToSettle&gt;"
                           "&lt;/AuthorizeCreditTrip&gt;"
                           "&lt;/soap:Body&gt;"
                           "&lt;/soap:Envelope&gt;",55258];
  
      NSURL *url = [NSURL URLWithString: @"http://services-staging.cmtnyc.com/payment/payment.asmx"];
      NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
  
      NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
      [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
      [req addValue:@"http://services.cmtnyc.com/payment/AuthorizeCreditTrip" forHTTPHeaderField:@"SOAPAction"];
      [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; //---set the HTTP method and body--- 
      [req setHTTPMethod:@"POST"]; 
      [req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
  
      NSLog(@"%@", soapMsg); 
  
      conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
      if (conn) 
      { 
          webData = [[NSMutableData data] retain];
      }
  
  }
  
  -(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *) response {
      [webData setLength: 0];
  }
  
  -(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data 
  { 
      [webData appendData:data];
  }
  
  -(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error {
      [webData release]; 
      [connection release];
  }
  
  -(void) connectionDidFinishLoading:(NSURLConnection *) connection 
  { 
      NSLog(@"..DONE. Received Bytes: %d", [webData length]); 
      NSString *theXML = [[NSString alloc]    //---shows the XML---
                          initWithBytes:[webData mutableBytes] length:[webData length]
                          encoding:NSUTF8StringEncoding];
      NSLog(@"....%@",theXML);
      [theXML release];                                                                                       
  
      //  [activityIndicator stopAnimating];                                                                                                                                        
      [connection release];                                                                                                                                    
      [webData release];  
  }
  </code></pre>