Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a wcf service. That is working fine when i am using simply in .net by adding as a webservice. But i want to make it able to use for iPhone app as JSON call. For testing i have used it in .net with JSON but its not working.

i know this kind of question is asked before, i have looked in for this cant find solution for me.

my configuration:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="servicebehavior">
      <serviceMetadata httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="endpointBehavior">
      <enableWebScript />
      <webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json" />
    </behavior>
  </endpointBehaviors>

</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
  <service name="MyService" behaviorConfiguration="servicebehavior">
    <endpoint address=""
              behaviorConfiguration="endpointBehavior"
              binding="webHttpBinding"
              contract="IMyService" />
  </service>
</services>

interface code:

[ServiceContract]
public interface IGolfPyramidService
{



    [WebInvoke(UriTemplate = "/Test", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    [OperationContract]
    string Test();

}

Myservice.cs code:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService : IMyService
{        
    public string Test()
    {
        return "success";
    }
}

i want to make it possible to call the method using url format like : http://example.com/MyService.svc/test

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
314 views
Welcome To Ask or Share your Answers For Others

1 Answer

if you are beginner then this will guide you create json and xml enabled web service which can be consumed by IOS and android.
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...