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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…