New to configuring anything server side ... thanks in advance for your help!
I am trying to get a simple HelloWorld REST api working in VisualStudio2008 / .NET 3.5; eventually I'll be using it to CRUD test data/results back to the server from a variety of mobile devices running on a local wireless lan.
I've found a number of other questions who's answers change related parts of my app.config, but none seem to apply to this specific issue (and trial and error hasn't yielded any results)
Here is my ServiceContract:
[ServiceContract]
public interface IRestService
{
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xml/{id}")]
string XMLData(string id); //Implemented as 'return "you requested " + id;'
[OperationContract]
[WebGet]
string Test(); //Implemented as 'return "foobar";'
[OperationContract]
[WebGet]
string Test2(string foo); //Implemented as 'return "foobar=" + foo;'
}
And here is my app.config
<services>
<service name="MyRestService.IRestServiceImpl" behaviorConfiguration="MyServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost/foo/bar"/>
</baseAddresses>
</host>
<endpoint address ="" binding="webHttpBinding" contract="MyRestService.IRestService" behaviorConfiguration="myRestBehavior" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="myRestBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
I'm running via f5 in visualstudio (which I think means I don't have any .svc/IIS stuff to worry about?), and attempting to connect via
http://localhost/foo/bar/Test
http://localhost/foo/bar/Test2 ( /ParamIgnored if I add one )
http://localhost/foo/bar/XMLData/123
on my browser.
Thanks much
您已经覆盖了要在xml / {id}上访问的XMLData端点,但是您将其称为XMLData / {id}。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.