我创建了一个 Azure WCF 服务,我想为 RESTful 请求提供服务。其中一个需要一个 IList 列表作为参数,但我不能让它变得奇怪,我不知道我是否使用 curl 错误或定义了服务错误。我给你代码:
接口类:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "generate", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
HttpResponseMessage Generate(IList<string> valami);
service.svc.cs:
public HttpResponseMessage Generate(IList<string> valami)
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
}
网络配置:
<configuration>
<configSections>
</configSections>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
这就是我使用 curl 的方式:
curl.exe -i -X POST http://127.0.0.1:81/PowerpointService.svc/generate -H "Content-Type: application/json" -d @ilistcontent.json
ilistcontent.json 是:["egy","ketto","harom","negy"]
感谢您的任何帮助!