C# WebInvoke POST停止安装服务

C# WebInvoke POST停止安装服务,c#,json,wcf,C#,Json,Wcf,我是c#的新手对不起 我正在尝试创建一个WCF Rest服务,以便在web服务器上获取和放置文件。以下操作非常有效: [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "GetMediaFile?shopNumber={shopNumber}&fileName={fileName}")] Stream Get

我是c#的新手对不起

我正在尝试创建一个WCF Rest服务,以便在web服务器上获取和放置文件。以下操作非常有效:

         [OperationContract]
    [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "GetMediaFile?shopNumber={shopNumber}&fileName={fileName}")]
    Stream GetMediaFile(string shopNumber, string fileName);
在添加以下操作之前,一切都按预期进行

 [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat =        WebMessageFormat.Json, UriTemplate = "PutMediaFile?shopNumber={shopNumber}&fileName={fileName}")]
    string PutMediaFile(string shopNumber, string fileName, Stream mediaFile);
我通过单击绿色箭头来安装服务,绿色箭头将启动安装服务的工具。我需要在IOS设备上进行测试

问题是,添加POST方法后,在服务安装过程中出现以下错误:

 "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata"
接着是更深入的解释:

 "Error: Cannot obtain Metadata from http://localhost/MpiPhotoStore/PhotoStoreService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error    URI: http://localhost/MpiPhotoStore/PhotoStoreService.svc    Metadata contains a reference that cannot be resolved: 'http://localhost/MpiPhotoStore/PhotoStoreService.svc'.    There was no endpoint listening at http://localhost/MpiPhotoStore/PhotoStoreService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.    The remote server returned an error: (404) Not Found.HTTP GET Error    URI: http://localhost/MpiPhotoStore/PhotoStoreService.svc    There was an error downloading 'http://localhost/MpiPhotoStore/PhotoStoreService.svc'.    The request failed with the error message:--<HTML><HEAD><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Service</TITLE></HEAD><BODY><DIV id="content"><P class="heading1">Service</P><BR/><P class="intro">The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</P></DIV></BODY></HTML>--."
“错误:无法从中获取元数据http://localhost/MpiPhotoStore/PhotoStoreService.svc 如果这是Windows(R)您可以访问的通信基础服务,请检查您是否已在指定地址启用元数据发布。请参阅MSDN文档,以帮助启用元数据发布。http://go.microsoft.com/fwlink/?LinkId=65455.WS-元数据交换错误URI:http://localhost/MpiPhotoStore/PhotoStoreService.svc元数据包含无法解析的引用:'http://localhost/MpiPhotoStore/PhotoStoreService.svc“。没有端点正在侦听http://localhost/MpiPhotoStore/PhotoStoreService.svc 这可能会接受消息。这通常是由于地址或SOAP操作不正确造成的。有关详细信息,请参阅InnerException(如果存在)ils。远程服务器返回错误:(404)未找到。HTTP获取错误URI:http://localhost/MpiPhotoStore/PhotoStoreService.svc    下载“”时出错http://localhost/MpiPhotoStore/PhotoStoreService.svc“。请求失败,错误消息为:——#内容{FONT-SIZE:0.7em;PADDING-BOTTOM:2em;MARGIN-LEFT:30px}正文{MARGIN-TOP:0px;MARGIN-LEFT:0px;颜色:#000000;字体系列:Verdana;背景色:白色}P{MARGIN-TOP:0px;MARGIN-BOTTOM:12px;颜色:#000000;字体系列:Verdana}PRE{BORDER-RIGHT:#f0f0e0 1px solid;PADDING-RIGHT:5px;BORDER-TOP:#f0f0e0 1px solid;MARGIN-TOP:-5px;PADDING-LEFT:5px;FONT-SIZE:1.2em;PADDING-BOTTOM:5px;BORDER-LEFT:#f0f0e0 1px solid;PADDING-TOP:5px;BORDER-BOTTOM:#f0e0 1px solid;FONT-FAMILY:Courier New;BACKGROUND-COLOR:e5ecc}。heading1{MARGIN-TOP:0px;PADDING-LEFT:15px;FONT-WEIGHT:normal;FONT-SIZE:26px;MARGIN-BOTTOM:0px;PADDING-BOTTOM:3px;MARGIN-LEFT:-30px;WIDTH:100%;COLOR:#ffffff;PADDING-TOP:10px;FONT-FAMILY:Tahoma;BACKGROUND-COLOR:#003366}.intro{MARGIN-LEFT:-15px}服务

服务“>由于内部错误,服务器无法处理请求。有关错误的详细信息,请启用IncludeExceptionDetailInFaults(从ServiceBehaviorAttribute或从配置行为)以将异常信息发送回客户端,或根据Microsoft.NET Framework SDK文档打开跟踪并检查服务器跟踪日志。

--。”
就像我说的,我有一个2 GET操作和1 DELETE操作,它们都可以正常工作

这是我的Web.Config

 <?xml version="1.0"?>
 <configuration>

 <appSettings>
 <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
 <add key="RootFilePath" value="\\OMMACDEV02VM1\Images"/>
 </appSettings>
 <system.web>
  <compilation debug="true" targetFramework="4.0" />
  </system.web>
 <system.serviceModel>
 <protocolMapping>
  <add scheme="http" binding="webHttpBinding"/>
 </protocolMapping>
 <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>
  <endpointBehaviors>
    <behavior>
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我已经读过关于mex端点的文章,但我现在只关注JSON。Web.Config对于其他所有方法都很好


帮助!!!!!!!!!!!!!!!

问题出在web.config文件中:

 <?xml version="1.0"?>
 <configuration>
<appSettings>
 <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="RootFilePath" value="\\OMMACDEV02VM1\Images"/>
</appSettings>
<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding maxReceivedMessageSize="10485760" />
  </webHttpBinding>
</bindings>
<services>
  <service name="MpiPhotoStore.PhotoStore" behaviorConfiguration="ServiceBehaviour">
    <endpoint address ="" binding="webHttpBinding" contract="MpiPhotoStore.IPhotoStoreService" behaviorConfiguration="web">
    </endpoint>
    </service>
  </services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
</system.serviceModel>
 </configuration>