Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:09:00+00:00 2026-05-28T11:09:00+00:00

I am trying to use a web service built on asp.net wcf from iPhone

  • 0

I am trying to use a web service built on asp.net wcf from iPhone to POST some data in the form of xml but I am getting the error code 400. I have checked its description and it looks from it that I am not able to create a proper request. can someone please help me in correcting my code which is following:

NSString *urlString = [NSString stringWithFormat:@"http://172.xxx.xxx.xxx:1230/Service.svc/updateTimesheet"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];

NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:@"<TimesheetHour><ContractNote>111</ContractNote><TimesheetHourId>222</TimesheetHourId><TimesheetId>333</TimesheetId><WorkedOn>444</WorkedOn><PlacementOvertimeId>555</PlacementOvertimeId><HoursWorked>666</HoursWorked><PerformancevalueId>777</PerformancevalueId></TimesheetHour>"] dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postBody];

NSHTTPURLResponse* urlResponse = nil;  
NSError *error = [[NSError alloc] init];  
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];  
NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Response Code: %d", [urlResponse statusCode]);
if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) {
    NSLog(@"Response: %@", result);
    //here you get the response 
}

EDIT1:
server has a method updateTimesheet which expects a class as parameter. The request is defined as XM and response is defined as JSON

EDIT2:
below is my code for wcf service:

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "updateTimesheet", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
string UpdateTimesheetHours(string ts);

[DataContract]
public class TimesheetHour
{
private int _TimesheetHourId;
private int _TimesheetId;
private DateTime _WorkedOn;
private int _PlacementOvertimeId;
private decimal _HoursWorked;
private string _contractorNote = string.Empty;
private int _performancevalueId = 0;

[DataMember]
public string ContractorNote
{
    get { return _contractorNote; }
    set { _contractorNote = value; }
}
[DataMember]
public int TimesheetHourId
{
    get { return _TimesheetHourId; }
    set { _TimesheetHourId = value; }
}
[DataMember]
public int TimesheetId
{
    get { return _TimesheetId; }
    set { _TimesheetId = value; }
}
[DataMember]
public DateTime WorkedOn
{
    get { return _WorkedOn; }
    set { _WorkedOn = value; }
}
[DataMember]
public int PlacementOvertimeId
{
    get { return _PlacementOvertimeId; }
    set { _PlacementOvertimeId = value; }
}
[DataMember]
public decimal HoursWorked
{
    get { return _HoursWorked; }
    set { _HoursWorked = value; }
}
[DataMember]
public int PerformancevalueId
{
    get { return _performancevalueId; }
    set { _performancevalueId = value; }
}

}
public string UpdateTimesheetHours(TimesheetHour string)
{
return “success”;
}

EDIT3
My XML

<TimesheetHour>
<ContractNote>111</ContractNote>
<TimesheetHourId>222</TimesheetHourId>
<TimesheetId>333</TimesheetId>
<WorkedOn>444</WorkedOn>
<PlacementOvertimeId>555</PlacementOvertimeId>
<HoursWorked>666</HoursWorked>
<PerformancevalueId>777</PerformancevalueId>

i am calling a function on server which expects a string as paremeter and its request type is defined as XML
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:09:00+00:00Added an answer on May 28, 2026 at 11:09 am

    Get WireShark or Charles and inspect your request and the server response in more detail. WireShark is free and X11 and Charles has a 30 trial and is native.

    Personally I use Charles, down load, launch and it is catching your network traffic, it’s that easy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
I am trying to use Autofac and Autofac.Integrations.Web to register ASP.NET MVC controllers. I
I have a WCF ASP.Net 4.0 web service we'll call WebService. WebService is consuming
We're trying to use Axis2 to call a web service that cannot use HTTP/1.1
I am trying to use the tranlsation webservice from MyMemory: http://mymemory.translated.net/doc/spec.php Unfortunately, Zend_Soap_Client does
I'm trying to use a data view web part (via SPD 2007) to consume
I'm trying to use the new WCF Web API Preview 6 with Basic Authentication.
I'm trying to use a Web Service using PHP and SOAP. The Web Service
I am building an ASP.NET web service that will be used internally in my
I'm trying to use HTTPWebRequest to access a web service, and am having problems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.