状态500:调用WCF时System.ServiceModel.ServiceActivationException异常
问题描述:
我想从android客户端发送一个字符串到.NET服务器。以下是服务器端代码: - IService1.cs状态500:调用WCF时System.ServiceModel.ServiceActivationException异常
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfImageUpload
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(UriTemplate = "/JsonData",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
JsonString SendData(JsonString JsonImage);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class JsonString
{
[DataMember]
public string ImageData { get; set; }
}
}
Service1.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfImageUpload
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public JsonString SendData(JsonString JsonImage)
{
JsonString jsonStringObject = new JsonString();
jsonStringObject.ImageData = "ImageData";
return jsonStringObject;
}
}
}
的Web.config
<configuration>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="Default" name="WcfImageUpload.Service1">
<endpoint address="" behaviorConfiguration="webBehavior" binding="basicHttpsBinding" contract="WcfImageUpload.IService1" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
当我使用的是Chrome测试服务应用程序称为PostMan,我们得到以下错误: -
500 System.ServiceModel.ServiceActivationException
我试图发送格式的JSON -
{的ImageData:“测试字符串”}
可能是什么错误的原因是什么?
答
同时运行SP2013 JSOM非同步功能
clientContext.executeQueryAsync(Function.createDelegate(this, OnQuerySuccess), Function.createDelegate(this, OnQueryFail));
我只是有这个问题,并通过重置IIS解决它。
只需以管理员身份打开Windows PowerShell并运行iisreset
即可。
+3
谢谢,我解决了这个问题。 – Nit
信息是怎么说的以及你如何解释这条信息? – usr
消息说: - 500 System.ServiceModel.ServiceActivationException 我还没有解释的消息,我不知道它的意思,或者我应该从中推断出什么,如果你是一位专家善意地倾诉一些问题。 – Sreekanth
还有更多。每个异常都有一个堆栈跟踪和一条消息。你没有看到完整的例外。调试应用程序和/或启用WCF传输故障详细信息(http://msdn.microsoft.com/en-us/library/ff649234.aspx)。 – usr