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 5842569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:02:05+00:00 2026-05-22T12:02:05+00:00

I’m trying to post to my WCF Service from an iPhone app. I have

  • 0

I’m trying to post to my WCF Service from an iPhone app. I have the app posting to the service and trying to send data in the form of a service data contract in XML like below:

NSData *myPostData = [[NSString stringWithFormat:@"<AddMediaItem xmlns='http://www.example.com'><Item xmlns:a='http://www.example.com/MediaItem'><a:MediaType>iPhone</a:MediaType><a:Description>Description</a:Description><a:Name>Test</a:Name><a:ImageType>JPEG</a:ImageType></Item></AddMediaItem>"] dataUsingEncoding:NSUTF8StringEncoding];

NSMutableData *myMutablePostData = [NSMutableData dataWithData:myPostData];

[request setPostBody:myMutablePostData];  
[request setRequestMethod:@"POST"];  
[request addRequestHeader:@"Content-Type" value:@"application/xml"];  

[request setDidFinishSelector:@selector(uploadFinished:)];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDelegate:self];
[request startAsynchronous];

For testing purposes, I’ve setup my service to return the data contract that I send to the service. However, when it returns, some of the values seem to be NULLs although from the code above, I am giving them values.

What also seems strange is that the Name data member always has a value, but the other 3 I’m sending return NULL or with the correct values based on the order they appear in the XML I post to the service.

Below is the code for my service contract:

[ServiceContract(Namespace = "http://www.example.com")]
public interface IImageDiaryService
{

    [OperationContract]
    [WebInvoke(UriTemplate = "AddMediaItem", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
    MediaItem AddMediaItem(MediaItem Item);

}

Below is my code for my MediaItem data contract:

[DataContract(Namespace = "http://www.example.com/MediaItem")]
public class MediaItem
{

    [DataMember]
    public Int32 Id { get; set; }

    [DataMember]
    public String Name { get; set; }

    [DataMember]
    public String Description { get; set; }

    [DataMember]
    public String ImageData { get; set; }

    [DataMember]
    public String ImageType { get; set; }

    [DataMember]
    public String MediaType { get; set; }

}

Do let me know if you need any further code.

Any help is much appreciated.

  • 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-22T12:02:05+00:00Added an answer on May 22, 2026 at 12:02 pm

    The order is important in data contracts – by default the data members are ordered alphabetically, but you can override it by using the Order property of [DataMember]. Try reordering the fields and you’ll get the values populated correctly

    <AddMediaItem xmlns='http://www.example.com'>
      <Item xmlns:a='http://www.example.com/MediaItem'>
        <a:Description>Description</a:Description>
        <a:ImageType>JPEG</a:ImageType>
        <a:MediaType>iPhone</a:MediaType>
        <a:Name>Test</a:Name>
      </Item>
    </AddMediaItem>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.