I'm trying to make my app send data to a WCF RESTful webservice.

At this point I'm not getting any error message from ASIHTTPRequest but the web service not doing anything either.

Could you guys take a look at it and see if you can spot something?


NSURL *url = [NSURL URLWithString:@""]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; NSData *myPostData = [[NSString stringWithFormat:@"<Product><Description>desc1</Description><Id></Id><Name>some body</Name></Product>"] dataUsingEncoding:NSUTF8StringEncoding]; NSMutableData *myMutablePostData = [NSMutableData dataWithData:myPostData]; [request setPostBody:myMutablePostData]; [request setRequestMethod:@"POST"]; [request addRequestHeader:@"Content-Type" value:@"application/xml"]; [request setDelegate:self]; [request startSynchronous];



public class Product { [DataMember] public string Id { get; set; }

[DataMember] public string Name { get; set; } [DataMember] public string Description { get; set; } }


[OperationContract] [WebInvoke(UriTemplate = "/create", Method = "POST", RequestFormat=WebMessageFormat.Xml, BodyStyle=WebMessageBodyStyle.Bare)] void CreateProduct(Product product);




string insertString = "insert into tbldata (desc,Name) values (@desc,@Name)"; MySqlCommand myCommand = new MySqlCommand(insertString, myConnection); myCommand.Parameters.Add("@desc", MySqlDbType.VarChar, 12); myCommand.Parameters.Add("@Name", MySqlDbType.VarChar, 40); myCommand.Parameters["@desc"].Value = product.Description; myCommand.Parameters["@Name"].Value = product.Name; myCommand.ExecuteNonQuery();

-------------Problems Reply------------

Your request looks okay to me, but you could try testing it with another tool, like curl from the command line to be sure. Here's something to try:

curl -D headers.txt -X POST -H 'Content-Type:application/xml' -d '<Product><Description>desc1</Description><Id></Id><Name>somebody</Name></Product>'

Check stdout for the response body and headers.txt for the response headers. You should get the same thing you're getting in your iOS app.

In terms of the server-side response, try responding with a different status code or body.

Category:iphone Views:4 Time:2011-03-01

Related post

  • How does WCF wrap xml body messages? 2010-11-12

    I'm running into a problem getting my WCF service to work with other clients. The ServiceContract looks like this: [ServiceContract] public interface IMyService { [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, R

  • WCF - Viewing xml request/response to a secure webservice 2010-03-11

    I have a WCF service application and in this app I am doing calls to a third party web service over a secure connection. I have been trying to view the request response streams using fiddler but I have given up on it after trying more than half day a

  • WCF REST Xml Response Typing 2010-12-06

    I have a WCF REST service that exposes a couple dozen objects and based on the url format routes calls though 3 different method. For example: Protected Function [get](ByVal objType As String, ByVal id As String, ByVal propertyList As String, ByVal t

  • WCF and XML, returning XML from stored procedure 2010-12-17

    I am returning XML from a stored procedure, that I want to capture in WCF and pass on to WPF view. When I add function import, whats should be selected in returns a collection of, I selected string for now. And then what should be the return type of

  • WCF webmethod xml string problem 2011-01-18

    I have a WCF web service that returns a string to a Java based client. <OperationContract()> Function SomeSvc(ByVal fileString As String) As String fileString is a bunch of xml. When the client gets the response my xmlstring is encoded as text.

  • WCF custom XML serialization 2011-03-06

    In WCF, if I have code like this and I'm returning it in XML format, the XML is auto generated. Is it possible for me to expicitly specify which XML will be used for the serialization of the CustomerEntity? [OperationContract] [WebInvoke(Method = "GE

  • WCF DataContractSerialzer xml to object incomplete results 2011-05-25

    I'm creating a wcf wrapper service that returns xml from another web service. What I'm noticing is that not all the xml from the source is being serialized to my object. Here's the source xml: <?xml version="1.0" standalone="yes"?> <methodRe

  • RESTful WCF Webservice XML Return Standards 2011-08-16

    I created a RESTful WCF web service and the returned content whether XML, JSON, plain text etc. is automatically being wrapped inside a root XML element: <string xmlns="">.....content.....</

  • Submitting WCF-generated XML through SoapUI 2012-03-06

    I have a WCF service that I'm testing with SoapUI. I'm using a VS-generated proxy class on the client, and I'm using an IClientMessageInspector class to intercept the XML just before the request and save it. Later on, I paste this XML into SoapUI to

  • Sending GET requests from a .NET client to a non-WCF, plain XML web service 2012-03-07

    I trying to write a C# client for a web service API (documentation here, PDF warning). Each request to the API is an HTTP GET call, with parameters encoded in the URI. The response is a well-formed XML document with a Content-Type of “text/xml”. Ever

  • Extraneous wcf body xml namespace declarations 2010-07-22

    I generated a set of web service proxy objects with the .Net 3.5 svcutil.exe tool. The soap body element has 2 extraneous xml namespace alias declarations. Specifically schema and schema instance namespaces (, http://

  • Wierd names on WCF's xml schema 2012-05-02

    I'm stuck with this problem in my WCF services that are being published via IIS. Since I'm not english native, maybe I lack the right terms to find the right answer. I have a generic class called Result which encapsulates an operation result code and

  • Issues with XML output for List collections by WCF service with Datacontract 2011-11-11

    I am new to WCF and trying to output some XML in a specific format. Presently my ServiceEvents object holds a collection of ServiceEvent objects (See classes and DataContracts below). When I fetch these objects via WCF the XML output for the collecti

  • Generated code from XSD does not accept valid XML in WCF REST endpoint 2012-02-10

    I have an XSD and I want to define a WCF REST endpoint to recieve an element from the XSD. I'll explain what I am doing Consider the following Schema <xs:schema xmlns="" xmlns:xs=""> <xs:element name="dir">

  • WCF: WTF! Does WCF raise the bar or just the complexity level? 2008-09-08

    I understand the value of the three-part service/host/client model offered by WCF. But is it just me or does it seem like WCF took something pretty direct and straightforward (the ASMX model) and made a mess out of it? Is there an alternative to usin

  • WCF Service invoking - without any reference added 2009-03-17

    I want to invoke a wcf service for testing on the http layer. I do not want to add a service reference and create a proxy and invoke. I want to create a new web test(VSTS) which sends a http request to the service and posts(Http post) the request in

  • Calling WCF service from a remote javascript 2009-06-14

    I have a WCF service (XML+JSON) running on http://servicehost:8080/myService. My ASP.NET application with jQuery is running on http://webapp/Login.aspx I want jQuery to use Ajax and call the URL http://servicehost:8080/myService. The browser does not

  • How can I add a prefix to a WCF ServiceContract Namespace 2010-03-22

    I'm trying to implement an UPnP MediaServer in WCF. I'm slowly getting there, but now I've hit a brick wall. I need to add a prefix to the ServiceContract namespace. Right now I have the following: [ServiceContract(Namespace = "urn:schemas-upnp-org:s

  • Convert string in xml document 2011-01-04

    I am getting some xml in a string variable through a wcf webservice. I need to confirm that the string xml I am getting is a valid xml or not. and I would also like to convert this string to xml document for further processing. Please let me know how

Copyright (C), All Rights Reserved.

processed in 0.100 (s). 11 q(s)