hi all
i have been struggling with this for a while. i have followed lots of tuturials and basically they are always the same , but mine just doesnt work.
Interface :
[ServiceContract]
public interface IRestServiceImpl
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "XML")]
String DoWorkXML();
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "JSON")]
String DoWorkJSON();
}
Implementation :
public class RestServiceImpl : IRestServiceImpl
{
public String DoWorkXML()
{
return "Dados XML";
}
public String DoWorkJSON()
{
return "Dados JSON";
}
}
my webconfig :
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="RestService.ResServiceImpl" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl"
behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
1 . as soon as i do the third step (webconfig file) the vs2010 automatic client (the little application vs2010 creates) stops working (gives some error).
2 - when i go to http://localhost:43658/RestServiceImpl.svc on my browser , i dont have the wsdl option. actualy it states that "Metadata publishing for this service is currently disabled. "
(if i revert webconfig back to the original 1 and 2 works ok)
3 - all the tuturials i followed are to use GET method, so they all say .....goto http://localhost:43658/RestServiceImpl.svc/XML and http://localhost:43658/RestServiceImpl.svc/JSON , but when i try this ( with original webconfig or changed with third step it doesnt matter ) it always returns page not found.
what am i doing wrong ?
thks in advanced
rui