我正在尝试为sharepoint 2013制作服务PSI扩展,但是在客户端中有一些显示错误,PSI扩展dll正在激活正确,但.... 请帮帮我~~~ !!!
错误:
mscorlib.dll中发生未处理的“System.ServiceModel.ProtocolException”类型异常 附加信息:内容类型text / html; charset =响应消息的UTF-8与绑定的内容类型不匹配(text / xml; charset = utf-8)。 如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。 响应的前1024个字节是:' #content {FONT-SIZE:0.7em; PADDING-BOTTOM:2em; MARGIN-LEFT:30px} BODY {MARGIN-TOP:0px; MARGIN-LEFT:0px;颜色:#000000; FONT-FAMILY:Verdana;背景颜色:白色} P {MARGIN-TOP:0px; MARGIN-BOTTOM:12px;颜色:#000000; FONT-FAMILY:Verdana} PRE {BORDER-RIGHT:
MARGIN-TOP:-5px; PADDING-LEFT:5px; FONT-SIZE:1.2em; PADDING-BOTTOM: 为5px; BORDER-LEFT:#f0f0e0 1px solid; PADDING-TOP:5px; BORDER-BOTTOM:
15像素; FONT-WEIGHT:正常; FONT-SIZE:26px; MARGIN-BOTTOM:0px; PADDING-BOTTOM:
3px的; MARGIN-LEFT:-30px;宽度:100%;颜色:#ffffff; PADDING-TOP:10px;字体系列:
宋体; BACKGROUND-COLOR:#003366} .intro {MARGIN-LEFT:-15px} TimesheetExt Service<'。
服务器堆栈跟踪:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request,HttpWebResponse response,HttpChannelFactory 1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory
1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)
在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)
在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
在[0]处重新抛出异常: 在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) 在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type) at TestTimesheetExt.SvcTimesheetExt.ITimesheetExt.ReadTimesheetListForCurrentUser(ReadTimesheetListForCurrentUserRequest request) 在D:\ Project \ C#*** \ Source \ PSIExtension \ TestTimesheetExt \ Service References \ SvcTimesheetExt \ Reference.cs:line 1529中的TestTimesheetExt.SvcTimesheetExt.TimesheetExtClient.TestTimesheetExt.SvcTimesheetExt.ITimesheetExt.ReadTimesheetListForCurrentUser(ReadTimesheetListForCurrentUserRequest request) 在D:\ Project \ C#*** \ Source \ PSIExtension \ TestTimesheetExt \ Service References \ SvcTimesheetExt \ Reference.cs:line 1535中的TestTimesheetExt.SvcTimesheetExt.TimesheetExtClient.ReadTimesheetListForCurrentUser(String pwaUrl) 在D:\ Project \ C#*** \ Source \ PSIExtension \ TestTimesheetExt \ Program.cs:第37行的TestTimesheetExt.Program.Main(String [] args)
来源
1. PSI Extension config.
private static void SetClientEndpoints(string pwaUrl)
{
const int MAXSIZE = 500000000;
const string svcRouter = "_vti_bin/PSI/ProjectServer.svc";
Uri pwaUri = GetServerUri(pwaUrl);
pwaUrl = pwaUri.Scheme + Uri.SchemeDelimiter + pwaUri.Host + ":"
+ pwaUri.Port + pwaUri.AbsolutePath;
//Console.WriteLine("URL: {0}", pwaUrl);
BasicHttpBinding binding = null;
if (pwaUri.Scheme.Equals(Uri.UriSchemeHttps))
{
// Create binding for HTTPS.
binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
}
else
{
// Create binding for HTTP.
binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
}
binding.Name = "basicHttpConf";
binding.AllowCookies = true;
binding.MessageEncoding = WSMessageEncoding.Text;
binding.OpenTimeout = TimeSpan.FromHours(1);
binding.ReceiveTimeout = TimeSpan.FromHours(1);
binding.SendTimeout = TimeSpan.FromHours(1);
// If the TransferMode is buffered, the MaxBufferSize and
// MaxReceived MessageSize must be the same value.
binding.TransferMode = TransferMode.Buffered;
binding.MaxBufferSize = MAXSIZE;
binding.MaxReceivedMessageSize = MAXSIZE;
binding.ReaderQuotas.MaxArrayLength = MAXSIZE;
binding.ReaderQuotas.MaxNameTableCharCount = MAXSIZE;
binding.TextEncoding = UTF8Encoding.UTF8;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
// binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
binding.Security.Transport.Realm = "";
// The endpoint address is the ProjectServer.svc router for all public PSI calls.
EndpointAddress address = new EndpointAddress(pwaUrl + svcRouter);
resourceClient = new SvcResource.ResourceClient(binding, address);
resourceClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
= TokenImpersonationLevel.Impersonation;
resourceClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;
timesheetClient = new SvcTimeSheet.TimeSheetClient(binding, address);
timesheetClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
= TokenImpersonationLevel.Impersonation;
timesheetClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;
}
2. Web.config
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
maxSizeOfMessageToLog="4194304" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="extensionBasicHttpConf"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="true"
maxBufferSize="4194304"
maxReceivedMessageSize="500000000"
textEncoding="utf-8"
transferMode="StreamedResponse"
messageEncoding="Text">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"
proxyCredentialType="None"
realm="" />
</security>
</binding>
<binding name="mexHttpBinding"
transferMode="StreamedResponse" useDefaultWebProxy="true">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="PSIExtensionServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Microsoft.SDK.Project.Samples.PSIExtensions.TimesheetExt"
behaviorConfiguration="PSIExtensionServiceBehavior">
<endpoint address="http://***.com/_vti_bin/psi/PSIExtensions.svc"
binding="basicHttpBinding"
bindingConfiguration="extensionBasicHttpConf"
contract="Microsoft.SDK.Project.Samples.PSIExtensions.ITimesheetExt" />
<endpoint address="mex"
binding="basicHttpBinding"
bindingConfiguration="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
3. app.config (client)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="basicHttpBehavior">
<clientCredentials>
<windows allowedImpersonationLevel="Impersonation"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferSize="500000000"
maxReceivedMessageSize="500000000" messageEncoding="Text" textEncoding="utf-8" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://***.com/_vti_bin/psi/PSIExtensions.svc"
behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf"
contract="SvcTimesheetExt.ITimesheetExt" name="basicHttp_TimesheetExt" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
有人帮助我.. 感谢。